ProSHADE: src/proshade/ProSHADE_peakSearch.cpp Source File

| ProSHADE 0.7.5.4 (MAR 2021) Protein Shape Detection

ProSHADE_peakSearch.cpp
Go to the documentation of this file.
1
23 //==================================================== ProSHADE
24 #include "ProSHADE_peakSearch.hpp"
25
38 std::vector< proshade_double* > ProSHADE_internal_peakSearch::findAllPointsAboveNeighbours ( proshade_complex* map, proshade_unsign dim, proshade_signed peakSize, proshade_double* medianIQR )
39 {
40 //================================================ Initialise local variables
41 std::vector< proshade_double* > ret;
42 std::vector< proshade_double > nonPeakVals;
43 proshade_double* retHlp = NULL;
44 proshade_double pointHeight = 0.0;
45 proshade_signed x, y, z, peakX, peakY, peakZ, newIter, ptrIter;
46 proshade_signed xDim = pow ( dim, 2 );
47 proshade_signed yDim = dim;
48 bool breakPeak;
49
50 //================================================ Check all points
51 for ( proshade_unsign iter = 0; iter < ( pow( static_cast<proshade_unsign> ( dim ), 3 ) ); iter++ )
52 {
53 //============================================ Find point height
54 pointHeight = pow( map[iter][0], 2.0 ) + pow( map[iter][1], 2.0 );
55
56 //============================================ Find the x, y and z
57 x = std::floor ( iter / xDim );
58 y = std::floor ( ( iter - x * xDim ) / yDim );
59 z = iter - x * xDim - y * yDim;
60
61 //==================================== Initialise the output pointer
62 if ( retHlp == NULL )
63 {
64 retHlp = new proshade_double[static_cast<proshade_unsign>( pow( ((peakSize*2)+1), 3) * 4 )];
65 ProSHADE_internal_misc::checkMemoryAllocation ( retHlp, __FILE__, __LINE__, __func__ );
66 }
67
68 //============================================ Get the X surrounding values and check for all being lower than point in question
69 breakPeak = false;
70 ptrIter = 4;
71 for ( proshade_signed xCh = -peakSize; xCh <= +peakSize; xCh++ )
72 {
73 if ( breakPeak ) { break; }
74 for ( proshade_signed yCh = -peakSize; yCh <= +peakSize; yCh++ )
75 {
76 if ( breakPeak ) { break; }
77 for ( proshade_signed zCh = -peakSize; zCh <= +peakSize; zCh++ )
78 {
79 if ( breakPeak ) { break; }
80 if ( ( xCh == 0 ) && ( yCh == 0 ) && ( zCh == 0 ) ) { continue; }
81
82 //================================ Find the nieghbout peak indices (with periodicity)
83 peakX = x + xCh; if ( peakX >= yDim ) { peakX = yDim - 1; }; if ( peakX < 0 ) { peakX = 0; }
84 peakY = y + yCh; if ( peakY >= yDim ) { peakY = yDim - 1; }; if ( peakY < 0 ) { peakY = 0; }
85 peakZ = z + zCh; if ( peakZ >= yDim ) { peakZ = yDim - 1; }; if ( peakZ < 0 ) { peakZ = 0; }
86 newIter = peakX * xDim + peakY * yDim + peakZ;
87
88 //================================ If neighbour has higher value than index in question, break out
89 if ( ( pow ( map[newIter][0], 2.0 ) + pow( map[newIter][1], 2.0 ) ) > pointHeight ) { breakPeak = true; break; }
90
91 //================================ Save neighbour values for optimisation of peaks later
92 retHlp[ptrIter] = static_cast<proshade_double> ( peakX );
93 retHlp[ptrIter+1] = static_cast<proshade_double> ( peakY );
94 retHlp[ptrIter+2] = static_cast<proshade_double> ( peakZ );
95 retHlp[ptrIter+3] = pow ( map[newIter][0], 2.0 ) + pow( map[newIter][1], 2.0 );
96 ptrIter += 4;
97 }
98 }
99 }
100 if ( breakPeak ) { ProSHADE_internal_misc::addToDoubleVector ( &nonPeakVals, pointHeight ); continue; }
101
102 //============================================ If passing, save for returning
103 retHlp[0] = x;
104 retHlp[1] = y;
105 retHlp[2] = z;
106 retHlp[3] = pointHeight;
107 ProSHADE_internal_misc::addToDblPtrVector ( &ret, retHlp );
108 retHlp = NULL;
109 }
110
111 //================================================ Save non-peak median and IQR
112 ProSHADE_internal_maths::vectorMedianAndIQR ( &nonPeakVals, medianIQR );
113
114 //================================================ Release memory if need be
115 if ( retHlp != NULL ) { delete[] retHlp; }
116
117 //================================================ Done
118 return ( ret );
119
120 }
121
132 void ProSHADE_internal_peakSearch::pointsAboveNeighboursRemoveSmallHeight ( std::vector< proshade_double* >* pointVec, proshade_double* medianIQR, proshade_double noIQRs )
133 {
134 //================================================ Determine the threshold
135 proshade_double backgroundThreshold = std::min ( std::max ( medianIQR[0] + ( medianIQR[1] * noIQRs ), 0.05 ), 0.3 );
136
137 //================================================ Check for passing the threshold
138 for ( proshade_signed iter = static_cast<proshade_signed> ( pointVec->size()-1 ); iter >= 0 ; iter-- )
139 {
140 if ( pointVec->at(iter)[3] <= backgroundThreshold )
141 {
142 delete[] pointVec->at(iter);
143 pointVec->erase ( pointVec->begin() + iter );
144 }
145 }
146
147 //================================================ Done
148 return ;
149
150 }
151
161 void ProSHADE_internal_peakSearch::allocatePeakOptimisationMemory ( proshade_double*& avgMat, proshade_double*& hlpMat, proshade_double*& eA, proshade_double*& eB, proshade_double*& eG, proshade_double*& uAV )
162 {
163 //================================================ Allocate the memory
164 avgMat = new proshade_double [9];
165 hlpMat = new proshade_double [9];
166 eA = new proshade_double;
167 eB = new proshade_double;
168 eG = new proshade_double;
169 uAV = new proshade_double [18];
170
171 //================================================ Check the memory allocation
172 ProSHADE_internal_misc::checkMemoryAllocation ( avgMat, __FILE__, __LINE__, __func__ );
173 ProSHADE_internal_misc::checkMemoryAllocation ( hlpMat, __FILE__, __LINE__, __func__ );
174 ProSHADE_internal_misc::checkMemoryAllocation ( eA, __FILE__, __LINE__, __func__ );
175 ProSHADE_internal_misc::checkMemoryAllocation ( eB, __FILE__, __LINE__, __func__ );
176 ProSHADE_internal_misc::checkMemoryAllocation ( eG, __FILE__, __LINE__, __func__ );
177 ProSHADE_internal_misc::checkMemoryAllocation ( uAV, __FILE__, __LINE__, __func__ );
178
179 //================================================ Done
180 return ;
181
182 }
183
193 void ProSHADE_internal_peakSearch::releasePeakOptimisationMemory ( proshade_double*& avgMat, proshade_double*& hlpMat, proshade_double*& eA, proshade_double*& eB, proshade_double*& eG, proshade_double*& uAV )
194 {
195 //================================================ Release the memory
196 delete[] avgMat;
197 delete[] hlpMat;
198 delete[] eA;
199 delete[] eB;
200 delete[] eG;
201 delete[] uAV;
202
203 //================================================ Done
204 return ;
205
206 }
207
221 void ProSHADE_internal_peakSearch::optimisePeakPositions ( std::vector< proshade_double* >* pointVec, proshade_signed peakSize, proshade_signed band )
222 {
223 //================================================ Initialise local variables
224 proshade_double *avgMat, *hlpMat, *eulA, *eulB, *eulG, *uAndV;
225 proshade_unsign noPoints = pow( ( ( peakSize * 2 ) + 1 ), 3 ) * 4;
226 proshade_double matWeight;
227
228 //================================================ Allocate the required memory
229 allocatePeakOptimisationMemory ( avgMat, hlpMat, eulA, eulB, eulG, uAndV );
230
231 //================================================ For each peak
232 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( pointVec->size() ); iter++ )
233 {
234 //============================================ Re-set loop
235 for ( proshade_unsign i = 0; i < 9; i++ ) { avgMat[i] = 0.0; }
236 matWeight = 0.0;
237
238 //============================================ For each neighbout and the point itself
239 for ( proshade_unsign it = 0; it < noPoints; it += 4 )
240 {
241 //======================================== Get the Euler angles
242 ProSHADE_internal_maths::getEulerZXZFromSOFTPosition ( band, pointVec->at(iter)[it+0], pointVec->at(iter)[it+1], pointVec->at(iter)[it+2], eulA, eulB, eulG );
243
244 //======================================== Convert Euler angles to rotation matrix
245 ProSHADE_internal_maths::getRotationMatrixFromEulerZXZAngles ( *eulA, *eulB, *eulG, hlpMat );
246
247 //======================================== Add the matrix to the sum
248 for ( proshade_unsign i = 0; i < 9; i++ ) { avgMat[i] += hlpMat[i] * pointVec->at(iter)[it+3]; }
249
250 //======================================== Find matrix weight
251 matWeight += pointVec->at(iter)[it+3];
252 }
253
254 //============================================ Normalise weighted sum matrix by sum of weights
255 for ( proshade_unsign i = 0; i < 9; i++ ) { avgMat[i] /= matWeight; }
256
257 //============================================ Decompose the average matrix using SVD
258 ProSHADE_internal_maths::complexMatrixSVDUandVOnly ( avgMat, 3, uAndV, false );
259 if ( uAndV[0] == -777.7 )
260 {
261 //======================================== SVD Failed. Just use the central value
262 ProSHADE_internal_maths::getEulerZXZFromSOFTPosition ( band, pointVec->at(iter)[0], pointVec->at(iter)[1], pointVec->at(iter)[2], eulA, eulB, eulG );
263 matWeight = pointVec->at(iter)[3];
264 pointVec->at(iter) = new proshade_double [4];
265 ProSHADE_internal_misc::checkMemoryAllocation ( pointVec->at(iter), __FILE__, __LINE__, __func__ );
266 pointVec->at(iter)[0] = *eulA;
267 pointVec->at(iter)[1] = *eulB;
268 pointVec->at(iter)[2] = *eulG;
269 pointVec->at(iter)[3] = matWeight;
270
271 continue ;
272 }
273
274 //============================================ SVD Succeeded. Compute U * V^T
275 for ( proshade_unsign i = 0; i < 9; i++ ) { avgMat[i] = 0.0; }
276 ProSHADE_internal_maths::multiplyTwoSquareMatrices ( uAndV, uAndV+9, avgMat, 3 );
277
278 //============================================ Convert to Euler
279 ProSHADE_internal_maths::getEulerZXZFromRotMatrix ( avgMat, eulA, eulB, eulG );
280
281 //============================================ Save over input
282 matWeight = pointVec->at(iter)[3];
283 delete[] pointVec->at(iter);
284 pointVec->at(iter) = new proshade_double [4];
285 ProSHADE_internal_misc::checkMemoryAllocation ( pointVec->at(iter), __FILE__, __LINE__, __func__ );
286 pointVec->at(iter)[0] = *eulA;
287 pointVec->at(iter)[1] = *eulB;
288 pointVec->at(iter)[2] = *eulG;
289 pointVec->at(iter)[3] = matWeight;
290 }
291
292 //================================================ Release memory
293 releasePeakOptimisationMemory ( avgMat, hlpMat, eulA, eulB, eulG, uAndV );
294
295 //================================================ Done
296 return ;
297
298 }
299
315 std::vector< proshade_double* > ProSHADE_internal_peakSearch::getAllPeaksNaive ( proshade_complex* map, proshade_unsign dim, proshade_signed peakSize, proshade_double noIQRs )
316 {
317 //================================================ Find all indices with higher value than all neighbours
318 std::vector< proshade_double* > allHigherIndices;
319 proshade_double* nonPeakMedianIQR = new proshade_double[2];
320 ProSHADE_internal_misc::checkMemoryAllocation ( nonPeakMedianIQR, __FILE__, __LINE__, __func__ );
321 allHigherIndices = findAllPointsAboveNeighbours ( map, dim, peakSize, nonPeakMedianIQR );
322
323 //================================================ Remove all indices with too small height
324 pointsAboveNeighboursRemoveSmallHeight ( &allHigherIndices, nonPeakMedianIQR, noIQRs );
325
326 //================================================ Optimise the peaks using the neighbour values
327 optimisePeakPositions ( &allHigherIndices, peakSize, dim/2 );
328
329 //================================================ Release memory
330 delete[] nonPeakMedianIQR;
331
332 //================================================ Done
333 return ( allHigherIndices );
334
335 }
336
351 void ProSHADE_internal_peakSearch::getBestPeakEulerAngsNaive ( proshade_complex* map, proshade_unsign dim, proshade_double* eulA, proshade_double* eulB, proshade_double* eulG, ProSHADE_settings* settings )
352 {
353 //================================================ Report progress
354 ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 2, "Looking for Euler angles of highest peak." );
355
356 //================================================ Get all peaks
357 std::vector< proshade_double* > allPeaks = getAllPeaksNaive ( map, dim, settings->peakNeighbours, settings->noIQRsFromMedianNaivePeak );
358
359 //================================================ Report progress
360 std::stringstream hlpSSP;
361 hlpSSP << "Found " << allPeaks.size() << " possible peaks.";
362 ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 3, hlpSSP.str() );
363
364 //================================================ Sanity check
365 if ( allPeaks.size() == 0 )
366 {
367 *eulA = 0.0;
368 *eulB = 0.0;
369 *eulG = 0.0;
370 return ;
371 }
372
373 //================================================ Find the highest peak from the list
374 proshade_double highestPeak = 0.0;
375 proshade_unsign highestPeakIndex = 0;
376 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign>( allPeaks.size() ); iter++ )
377 {
378 if ( allPeaks.at(iter)[3] > highestPeak ) { highestPeak = allPeaks.at(iter)[3]; highestPeakIndex = iter; }
379 }
380
381 //================================================ Get Euler ZXZ for the highest peak
382 *eulA = allPeaks.at(highestPeakIndex)[0];
383 *eulB = allPeaks.at(highestPeakIndex)[1];
384 *eulG = allPeaks.at(highestPeakIndex)[2];
385
386 //================================================ Release memory
387 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( allPeaks.size() ); iter++ )
388 {
389 delete[] allPeaks.at(iter);
390 }
391
392 //================================================ Report progress
393 std::stringstream hlpSS;
394 hlpSS << "Optimal Euler angles are " << *eulA << " ; " << *eulB << " ; " << *eulG << " with peak height " << highestPeak;
395 ProSHADE_internal_messages::printProgressMessage ( settings->verbose, 3, hlpSS.str() );
396
397 //================================================ Done
398 return ;
399
400 }
401
418 void ProSHADE_internal_peakSearch::allocateSmoothingZScoreMemory ( proshade_unsign dim, proshade_double*& scoreOverVals, proshade_signed*& signals, proshade_double*& filteredY, proshade_double*& avgFilter, proshade_double*& stdFilter, proshade_double*& subVec, proshade_double*& medianIQR, proshade_double*& YZMap, proshade_double*& XZMap, proshade_double*& XYMap, proshade_unsign smLag )
419 {
420 //================================================ Allocate the memory
421 signals = new proshade_signed[dim];
422 scoreOverVals = new proshade_double[dim];
423 filteredY = new proshade_double[dim];
424 avgFilter = new proshade_double[dim];
425 stdFilter = new proshade_double[dim];
426 subVec = new proshade_double[smLag];
427 medianIQR = new proshade_double[2];
428 YZMap = new proshade_double[dim * dim * dim];
429 XZMap = new proshade_double[dim * dim * dim];
430 XYMap = new proshade_double[dim * dim * dim];
431
432 //================================================ Check memory allocation
433 ProSHADE_internal_misc::checkMemoryAllocation ( signals, __FILE__, __LINE__, __func__ );
434 ProSHADE_internal_misc::checkMemoryAllocation ( scoreOverVals, __FILE__, __LINE__, __func__ );
435 ProSHADE_internal_misc::checkMemoryAllocation ( filteredY, __FILE__, __LINE__, __func__ );
436 ProSHADE_internal_misc::checkMemoryAllocation ( avgFilter, __FILE__, __LINE__, __func__ );
437 ProSHADE_internal_misc::checkMemoryAllocation ( stdFilter, __FILE__, __LINE__, __func__ );
438 ProSHADE_internal_misc::checkMemoryAllocation ( subVec, __FILE__, __LINE__, __func__ );
439 ProSHADE_internal_misc::checkMemoryAllocation ( medianIQR, __FILE__, __LINE__, __func__ );
440 ProSHADE_internal_misc::checkMemoryAllocation ( YZMap, __FILE__, __LINE__, __func__ );
441 ProSHADE_internal_misc::checkMemoryAllocation ( XZMap, __FILE__, __LINE__, __func__ );
442 ProSHADE_internal_misc::checkMemoryAllocation ( XYMap, __FILE__, __LINE__, __func__ );
443
444 //================================================ Done
445 return ;
446
447 }
448
462 void ProSHADE_internal_peakSearch::releaseSmoothingZScoreMemory ( proshade_double*& scoreOverVals, proshade_signed*& signals, proshade_double*& filteredY, proshade_double*& avgFilter, proshade_double*& stdFilter, proshade_double*& subVec, proshade_double*& medianIQR, proshade_double*& YZMap, proshade_double*& XZMap, proshade_double*& XYMap )
463 {
464 //================================================ Release the memory
465 delete[] scoreOverVals;
466 delete[] signals;
467 delete[] filteredY;
468 delete[] avgFilter;
469 delete[] stdFilter;
470 delete[] subVec;
471 delete[] medianIQR;
472 delete[] YZMap;
473 delete[] XZMap;
474 delete[] XYMap;
475
476 //================================================ Done
477 return ;
478
479 }
480
500 void ProSHADE_internal_peakSearch::getSmoothedZScore1D ( proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed* signals, proshade_double* filteredY, proshade_double* avgFilter, proshade_double* stdFilter, proshade_double* subVec, proshade_double* medianIQR, proshade_double* scoreOverVals )
501 {
502 //================================================ Re-set the run
503 for ( proshade_unsign i = 0; i < dim; i++ ) { signals[i] = 0; avgFilter[i] = 0.0; stdFilter[i] = 0.0; filteredY[i] = 0.0; }
504 for ( proshade_unsign i = 0; i < smoothingLag; i++ ) { subVec[i] = scoreOverVals[i-smoothingLag+dim]; }
505 ProSHADE_internal_maths::arrayMedianAndIQR ( subVec, smoothingLag, medianIQR );
506 avgFilter[0] = medianIQR[0];
507 stdFilter[0] = medianIQR[1];
508
509 //================================================ Find peaks for 1D array
510 for ( proshade_unsign i = 0; i < dim; i++)
511 {
512 //============================================ Is this peak?
513 if ( std::abs ( scoreOverVals[i] - avgFilter[i]) > ZScoreThreshold * stdFilter[i] )
514 {
515 if ( scoreOverVals[i] > avgFilter[i] )
516 {
517 signals[i] = 1;
518 }
519 else
520 {
521 signals[i] = -1;
522 }
523
524 //======================================== Decrease influence for this window
525 if ( i != 0 ) { filteredY[i] = 0.5 * scoreOverVals[i] + (1 - 0.5) * filteredY[i - 1]; }
526 else { filteredY[i] = 0.5 * scoreOverVals[i]; }
527 }
528 else
529 {
530 signals[i] = 0;
531 filteredY[i] = scoreOverVals[i];
532 }
533
534 //============================================ Filters adjustments
535 for ( proshade_signed subIt = 0; subIt < static_cast<proshade_signed> ( smoothingLag ); subIt++ )
536 {
537 if ( ( static_cast<proshade_signed>(i) + static_cast<proshade_signed>(subIt) - static_cast<proshade_signed>(smoothingLag) + 1 ) < 0 )
538 {
539 subVec[subIt] = scoreOverVals[( static_cast<proshade_signed>(i) + static_cast<proshade_signed>(subIt) -
540 static_cast<proshade_signed>(smoothingLag) + 1 ) + dim];
541 }
542 else
543 {
544 subVec[subIt] = filteredY[( static_cast<proshade_signed>(i) + static_cast<proshade_signed>(subIt) -
545 static_cast<proshade_signed>(smoothingLag) + 1 )];
546 }
547 }
548 ProSHADE_internal_maths::arrayMedianAndIQR ( subVec, smoothingLag, medianIQR );
549 avgFilter[i+1] = medianIQR[0];
550 stdFilter[i+1] = medianIQR[1];
551 }
552
553 //================================================ Done
554 return ;
555
556 }
557
577 void ProSHADE_internal_peakSearch::getXAxisArraysSmoothedZScorePeaks ( proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed* signals, proshade_double* filteredY, proshade_double* avgFilter, proshade_double* stdFilter, proshade_double* subVec, proshade_double* medianIQR, proshade_double* scoreOverVals, proshade_complex* map, proshade_double* YZMap )
578 {
579 //================================================ For each YZ point
580 for ( proshade_unsign yIt = 0; yIt < dim; yIt++ )
581 {
582 for ( proshade_unsign zIt = 0; zIt < dim; zIt++ )
583 {
584 //======================================== Get all X values for this YZ position
585 for ( proshade_unsign xIt = 0; xIt < dim; xIt++ )
586 {
587 scoreOverVals[xIt] = pow ( map[xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt][0], 2.0 ) +
588 pow ( map[xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt][1], 2.0 );
589 }
590
591 //======================================== Run 1D smoothed Z score algorithm
592 getSmoothedZScore1D ( dim, smoothingLag, ZScoreThreshold, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, scoreOverVals );
593
594 //======================================== Save signals to YZMap
595 for ( proshade_unsign xIt = 0; xIt < dim; xIt++ )
596 {
597 YZMap[xIt * static_cast<proshade_unsign> (4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt] = signals[xIt];
598 }
599 }
600 }
601
602 //================================================ Done
603 return ;
604
605 }
606
626 void ProSHADE_internal_peakSearch::getYAxisArraysSmoothedZScorePeaks ( proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed* signals, proshade_double* filteredY, proshade_double* avgFilter, proshade_double* stdFilter, proshade_double* subVec, proshade_double* medianIQR, proshade_double* scoreOverVals, proshade_complex* map, proshade_double* XZMap )
627 {
628 //================================================ For each XZ point
629 for ( proshade_unsign xIt = 0; xIt < dim; xIt++ )
630 {
631 for ( proshade_unsign zIt = 0; zIt < dim; zIt++ )
632 {
633 //======================================== Get all Y values for this XZ position
634 for ( proshade_unsign yIt = 0; yIt < dim; yIt++ )
635 {
636 scoreOverVals[yIt] = pow ( map[xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt][0], 2.0 ) +
637 pow ( map[xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt][1], 2.0 );
638 }
639
640 //======================================== Run 1D smoothed Z score algorithm
641 getSmoothedZScore1D ( dim, smoothingLag, ZScoreThreshold, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, scoreOverVals );
642
643 //======================================== Save signals to YZMap
644 for ( proshade_unsign yIt = 0; yIt < dim; yIt++ )
645 {
646 XZMap[xIt * static_cast<proshade_unsign> (4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt] = signals[xIt];
647 }
648 }
649 }
650
651 //================================================ Done
652 return ;
653
654 }
655
675 void ProSHADE_internal_peakSearch::getZAxisArraysSmoothedZScorePeaks ( proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed* signals, proshade_double* filteredY, proshade_double* avgFilter, proshade_double* stdFilter, proshade_double* subVec, proshade_double* medianIQR, proshade_double* scoreOverVals, proshade_complex* map, proshade_double* XYMap )
676 {
677 //================================================ For each XZ point
678 for ( proshade_unsign xIt = 0; xIt < dim; xIt++ )
679 {
680 for ( proshade_unsign yIt = 0; yIt < dim; yIt++ )
681 {
682 //======================================== Get all Y values for this XZ position
683 for ( proshade_unsign zIt = 0; zIt < dim; zIt++ )
684 {
685 scoreOverVals[yIt] = pow ( map[xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt][0], 2.0 ) +
686 pow ( map[xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt][1], 2.0 );
687 }
688
689 //======================================== Run 1D smoothed Z score algorithm
690 getSmoothedZScore1D ( dim, smoothingLag, ZScoreThreshold, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, scoreOverVals );
691
692 //======================================== Save signals to YZMap
693 for ( proshade_unsign zIt = 0; zIt < dim; zIt++ )
694 {
695 XYMap[xIt * static_cast<proshade_unsign> (4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt] = signals[xIt];
696 }
697 }
698 }
699
700 //================================================ Done
701 return ;
702
703 }
704
720 void ProSHADE_internal_peakSearch::findAllPointNeighbours ( proshade_double* YZMap, proshade_double* XZMap, proshade_double* XYMap, proshade_unsign* visitedMap, proshade_signed dim, proshade_signed x, proshade_signed y, proshade_signed z, std::vector< proshade_unsign >* retVals )
721 {
722 //================================================ Initialise local variables
723 proshade_signed newIter = 0;
724 proshade_signed peakX, peakY, peakZ;
725 proshade_signed xDim = static_cast<proshade_signed>(4 * pow ( ( dim / 2 ), 2 ));
726
727 //================================================ Iterate through all neighbours
728 for ( proshade_signed xCh = -1; xCh <= +1; xCh++ )
729 {
730 for ( proshade_signed yCh = -1; yCh <= +1; yCh++ )
731 {
732 for ( proshade_signed zCh = -1; zCh <= +1; zCh++ )
733 {
734 //==================================== Do not use this point
735 if ( ( xCh == 0 ) && ( yCh == 0 ) && ( zCh == 0 ) ) { continue; }
736
737 //==================================== Find the nieghbout peak indices (with periodicity)
738 peakX = x + xCh; if ( peakX >= dim ) { peakX -= dim; }; if ( peakX < 0 ) { peakX += dim; }
739 peakY = y + yCh; if ( peakY >= dim ) { peakY -= dim; }; if ( peakY < 0 ) { peakY += dim; }
740 peakZ = z + zCh; if ( peakZ >= dim ) { peakZ -= dim; }; if ( peakZ < 0 ) { peakZ += dim; }
741 newIter = peakX * xDim + peakY * dim + peakZ;
742
743 //==================================== If already visited, next point
744 if ( visitedMap[newIter] == 1 ) { continue; }
745 else { visitedMap[newIter] = 1; }
746
747 //==================================== If not peak, next point
748 if ( ( YZMap[newIter] + XZMap[newIter] + XYMap[newIter] ) != 3 ) { continue; }
749
750 //==================================== This is a valid neighbour! Save
751 ProSHADE_internal_misc::addToUnsignVector ( retVals, newIter );
752
753 //==================================== ... and recurse!
754 findAllPointNeighbours ( YZMap, XZMap, XYMap, visitedMap, dim, peakX, peakY, peakZ, retVals );
755 }
756 }
757 }
758
759 //================================================ Done
760 return ;
761
762 }
763
778 void ProSHADE_internal_peakSearch::findAllDisconnectedIslands ( proshade_complex* map, proshade_double* YZMap, proshade_double* XZMap, proshade_double* XYMap, proshade_unsign dim, std::vector< proshade_unsign >* allIslandBests )
779 {
780 //================================================ Initialise local variables
781 std::vector< proshade_unsign > ret;
782 std::vector< proshade_unsign > thisIsland;
783 proshade_unsign* visitedMap = new proshade_unsign[dim*dim*dim];
784 ProSHADE_internal_misc::checkMemoryAllocation ( visitedMap, __FILE__, __LINE__, __func__ );
785 for ( proshade_unsign i = 0; i < ( dim * dim * dim ); i++ ) { visitedMap[i] = 0; }
786 proshade_unsign index, maxIndex;
787 proshade_double maxHeight;
788
789 //================================================ For each point
790 for ( proshade_unsign xIt = 0; xIt < dim; xIt++ )
791 {
792 for ( proshade_unsign yIt = 0; yIt < dim; yIt++ )
793 {
794 for ( proshade_unsign zIt = 0; zIt < dim; zIt++ )
795 {
796 //==================================== Find index
797 index = xIt * static_cast<proshade_unsign>(4 * pow ( ( dim / 2 ), 2 )) + yIt * dim + zIt;
798
799 //==================================== If already visited, next point
800 if ( visitedMap[index] == 1 ) { continue; }
801 else { visitedMap[index] = 1; }
802
803 //==================================== If not peak, next point
804 if ( ( YZMap[index] + XZMap[index] + XYMap[index] ) != 3 ) { continue; }
805
806 //==================================== This is a new island! Save this point
807 thisIsland.clear ( );
808 ProSHADE_internal_misc::addToUnsignVector ( &thisIsland, index );
809
810 //==================================== ... and find all neighbours
811 findAllPointNeighbours ( YZMap, XZMap, XYMap, visitedMap, static_cast<proshade_signed>(dim), static_cast<proshade_signed>(xIt), static_cast<proshade_signed>(yIt), static_cast<proshade_signed>(zIt), &thisIsland );
812
813 //==================================== Find the largest of the island peaks
814 maxHeight = 0.0;
815 maxIndex = 0;
816 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( thisIsland.size() ); iter++ )
817 {
818 if ( ( pow( map[thisIsland.at(iter)][0], 2.0 ) + pow( map[thisIsland.at(iter)][1], 2.0) ) > maxHeight )
819 {
820 maxHeight = pow( map[thisIsland.at(iter)][0], 2.0 ) + pow( map[thisIsland.at(iter)][1], 2.0 );
821 maxIndex = thisIsland.at(iter);
822 }
823 }
824
825 //==================================== Save the results
826 ProSHADE_internal_misc::addToUnsignVector ( allIslandBests, maxIndex );
827 }
828 }
829 }
830
831 //================================================ Release memory
832 delete[] visitedMap;
833
834 //================================================ Done
835 return ;
836
837 }
838
853 void ProSHADE_internal_peakSearch::findAllSmoothedZScorePeaksWithNeighbours ( proshade_complex* map, proshade_double* YZMap, proshade_double* XZMap, proshade_double* XYMap, proshade_signed dim, proshade_signed peakSize, std::vector< proshade_double* >* allPeaksWithNeighbours )
854 {
855 //================================================ Initialise local variables
856 proshade_signed x, y, z, peakX, peakY, peakZ, newIter, ptrIter;
857 proshade_unsign noNeighbours = pow( ((peakSize*2)+1), 3) * 4;
858
859 //================================================ Find all islands and their best representative
860 std::vector < proshade_unsign > allPeaksRepresentatives;
861 findAllDisconnectedIslands ( map, YZMap, XZMap, XYMap, dim, &allPeaksRepresentatives );
862
863 //================================================ For each peak
864 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( allPeaksRepresentatives.size() ); iter++ )
865 {
866 //============================================ Reset loop
867 ptrIter = 0;
868
869 //============================================ Determine x, y and z
870 z = ( allPeaksRepresentatives.at(iter) % (dim*dim) ) % dim;
871 y = ( allPeaksRepresentatives.at(iter) - z ) % (dim*dim) / dim;
872 x = ( allPeaksRepresentatives.at(iter) - z - ( y * dim ) ) / (dim*dim);
873
874 //============================================ Allocate the memory
875 proshade_double* neighbours = new proshade_double[noNeighbours];
876 ProSHADE_internal_misc::checkMemoryAllocation ( neighbours, __FILE__, __LINE__, __func__ );
877 ProSHADE_internal_misc::addToDblPtrVector ( allPeaksWithNeighbours, neighbours );
878
879 //============================================ Find all neighbours
880 for ( proshade_signed xCh = -peakSize; xCh <= +peakSize; xCh++ )
881 {
882 for ( proshade_signed yCh = -peakSize; yCh <= +peakSize; yCh++ )
883 {
884 for ( proshade_signed zCh = -peakSize; zCh <= +peakSize; zCh++ )
885 {
886 //================================ Find the nieghbout peak indices (with periodicity)
887 peakX = x + xCh; if ( peakX >= dim ) { peakX -= dim; }; if ( peakX < 0 ) { peakX += dim; }
888 peakY = y + yCh; if ( peakY >= dim ) { peakY -= dim; }; if ( peakY < 0 ) { peakY += dim; }
889 peakZ = z + zCh; if ( peakZ >= dim ) { peakZ -= dim; }; if ( peakZ < 0 ) { peakZ += dim; }
890 newIter = peakX * (dim*dim) + peakY * dim + peakZ;
891
892 //================================ Save neighbour values for optimisation of peaks later
893 allPeaksWithNeighbours->at(iter)[ptrIter] = static_cast<proshade_double> ( peakX );
894 allPeaksWithNeighbours->at(iter)[ptrIter+1] = static_cast<proshade_double> ( peakY );
895 allPeaksWithNeighbours->at(iter)[ptrIter+2] = static_cast<proshade_double> ( peakZ );
896 allPeaksWithNeighbours->at(iter)[ptrIter+3] = pow ( map[newIter][0], 2.0 ) + pow( map[newIter][1], 2.0 );
897 ptrIter += 4;
898 }
899 }
900 }
901
902 //============================================ Release memory
903 delete[] neighbours;
904 }
905
906 //================================================ Done
907 return ;
908
909 }
910
922 std::vector< proshade_double* > ProSHADE_internal_peakSearch::getAllPeaksSmoothedZ ( proshade_complex* map, proshade_unsign dim, proshade_double smoothingFraction, proshade_double noIQRs, proshade_signed peakSize )
923 {
924 //================================================ Initialise local variables
925 std::vector< proshade_double* > allHigherIndices;
926 proshade_unsign smoothingLag = std::floor ( smoothingFraction * dim );
927 proshade_double ZScoreThreshold = noIQRs;
928 proshade_signed *signals;
929 proshade_double *scoreOverVals, *filteredY, *avgFilter, *stdFilter, *subVec, *medianIQR, *YZMap, *XZMap, *XYMap;
930
931 //================================================ Sanity check
932 if ( dim <= smoothingLag + 2)
933 {
934 // throw error
935 }
936
937 //================================================ Allocate required memory
938 allocateSmoothingZScoreMemory ( dim, scoreOverVals, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, YZMap, XZMap, XYMap, smoothingLag );
939
940 //================================================ Get smoothed Z score peaks for X-axis arrays
941 getXAxisArraysSmoothedZScorePeaks ( dim, smoothingLag, ZScoreThreshold, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, scoreOverVals, map, YZMap );
942
943 //================================================ Get smoothed Z score peaks for Y-axis arrays
944 getYAxisArraysSmoothedZScorePeaks ( dim, smoothingLag, ZScoreThreshold, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, scoreOverVals, map, XZMap );
945
946 //================================================ Get smoothed Z score peaks for Y-axis arrays
947 getZAxisArraysSmoothedZScorePeaks ( dim, smoothingLag, ZScoreThreshold, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, scoreOverVals, map, XYMap );
948
949 //================================================ Put all dimension peaks together and detect disconnected islands
950 findAllSmoothedZScorePeaksWithNeighbours ( map, YZMap, XZMap, XYMap, dim, peakSize, &allHigherIndices );
951
952 //================================================ Optimise the peaks using the neighbour values
953 optimisePeakPositions ( &allHigherIndices, peakSize, dim/2 );
954
955 //================================================ Release the required memory
956 releaseSmoothingZScoreMemory ( scoreOverVals, signals, filteredY, avgFilter, stdFilter, subVec, medianIQR, YZMap, XZMap, XYMap );
957
958 //================================================ Done
959 return ( allHigherIndices );
960
961 }
962
975 void ProSHADE_internal_peakSearch::getBestPeakEulerAngsSmoothedZ ( proshade_complex* map, proshade_unsign dim, proshade_double smoothingFraction, proshade_double noIQRs, proshade_signed peakSize, proshade_double* eulA, proshade_double* eulB, proshade_double* eulG )
976 {
977 //================================================ Get all peaks
978 std::vector< proshade_double* > allPeaks = getAllPeaksSmoothedZ ( map, dim, smoothingFraction, noIQRs, peakSize );
979
980 //================================================ Find the highest peak from the list
981 proshade_double highestPeak = 0.0;
982 proshade_unsign highestPeakIndex = 0;
983 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign>( allPeaks.size() ); iter++ )
984 {
985 if ( allPeaks.at(iter)[4] > highestPeak ) { highestPeak = allPeaks.at(iter)[4]; highestPeakIndex = iter; }
986 }
987
988 //================================================ Get Euler ZXZ from Angle-axis
989 proshade_double* rotMat = new proshade_double[9];
990 ProSHADE_internal_misc::checkMemoryAllocation ( rotMat, __FILE__, __LINE__, __func__ );
991 ProSHADE_internal_maths::getRotationMatrixFromAngleAxis ( rotMat, allPeaks.at(highestPeakIndex)[0], allPeaks.at(highestPeakIndex)[1], allPeaks.at(highestPeakIndex)[2], allPeaks.at(highestPeakIndex)[3] );
992 ProSHADE_internal_maths::getEulerZXZFromRotMatrix ( rotMat, eulA, eulB, eulG );
993
994 //================================================ Release memory
995 delete[] rotMat;
996 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( allPeaks.size() ); iter++ )
997 {
998 delete[] allPeaks.at(iter);
999 }
1000
1001 //================================================ Done
1002 return ;
1003
1004 }
ProSHADE_settings::noIQRsFromMedianNaivePeak
proshade_double noIQRsFromMedianNaivePeak
When doing peak searching, how many IQRs from the median the threshold for peak height should be (in ...
Definition: ProSHADE_settings.hpp:165
ProSHADE_internal_peakSearch::releaseSmoothingZScoreMemory
void releaseSmoothingZScoreMemory(proshade_double *&scoreOverVals, proshade_signed *&signals, proshade_double *&filteredY, proshade_double *&avgFilter, proshade_double *&stdFilter, proshade_double *&subVec, proshade_double *&medianIQR, proshade_double *&YZMap, proshade_double *&XZMap, proshade_double *&XYMap)
This function releases the memory required for smoothed Z score computation.
Definition: ProSHADE_peakSearch.cpp:462
ProSHADE_internal_misc::addToDblPtrVector
void addToDblPtrVector(std::vector< proshade_double * > *vecToAddTo, proshade_double *elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:143
ProSHADE_internal_peakSearch::getSmoothedZScore1D
void getSmoothedZScore1D(proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed *signals, proshade_double *filteredY, proshade_double *avgFilter, proshade_double *stdFilter, proshade_double *subVec, proshade_double *medianIQR, proshade_double *scoreOverVals)
This function computes the 1D peaks for a 1D input array and returns array of int's as signal.
Definition: ProSHADE_peakSearch.cpp:500
ProSHADE_internal_maths::getEulerZXZFromRotMatrix
void getEulerZXZFromRotMatrix(proshade_double *rotMat, proshade_double *eA, proshade_double *eB, proshade_double *eG)
This function converts rotation matrix to the Euler ZXZ angles representation.
Definition: ProSHADE_maths.cpp:1394
ProSHADE_internal_peakSearch::getAllPeaksNaive
std::vector< proshade_double * > getAllPeaksNaive(proshade_complex *map, proshade_unsign dim, proshade_signed peakSize, proshade_double noIQRs)
This function finds peaks in the 3D map using the "naive" approach.
Definition: ProSHADE_peakSearch.cpp:315
ProSHADE_internal_peakSearch::getAllPeaksSmoothedZ
std::vector< proshade_double * > getAllPeaksSmoothedZ(proshade_complex *map, proshade_unsign dim, proshade_double smoothingFraction, proshade_double noIQRs, proshade_signed peakSize)
This function finds peaks in the 3D map using the smoothed Z score approach.
Definition: ProSHADE_peakSearch.cpp:922
ProSHADE_internal_maths::getRotationMatrixFromEulerZXZAngles
void getRotationMatrixFromEulerZXZAngles(proshade_double eulerAlpha, proshade_double eulerBeta, proshade_double eulerGamma, proshade_double *matrix)
Function to find the rotation matrix from Euler angles (ZXZ convention).
Definition: ProSHADE_maths.cpp:1005
ProSHADE_internal_peakSearch::getYAxisArraysSmoothedZScorePeaks
void getYAxisArraysSmoothedZScorePeaks(proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed *signals, proshade_double *filteredY, proshade_double *avgFilter, proshade_double *stdFilter, proshade_double *subVec, proshade_double *medianIQR, proshade_double *scoreOverVals, proshade_complex *map, proshade_double *XZMap)
This function runs the 1D smoothed Z score algorithm on all Y-axis arrays as its inputs.
Definition: ProSHADE_peakSearch.cpp:626
ProSHADE_internal_peakSearch::findAllPointNeighbours
void findAllPointNeighbours(proshade_double *YZMap, proshade_double *XZMap, proshade_double *XYMap, proshade_unsign *visitedMap, proshade_signed dim, proshade_signed x, proshade_signed y, proshade_signed z, std::vector< proshade_unsign > *retVals)
This is a support function for the Z-score peak detection. It is currently not being used.
Definition: ProSHADE_peakSearch.cpp:720
ProSHADE_internal_peakSearch::allocatePeakOptimisationMemory
void allocatePeakOptimisationMemory(proshade_double *&avgMat, proshade_double *&hlpMap, proshade_double *&eA, proshade_double *&eB, proshade_double *&eG, proshade_double *&uAV)
This function allocates and checks all the peak optimisation memory.
Definition: ProSHADE_peakSearch.cpp:161
ProSHADE_settings::verbose
proshade_signed verbose
Should the software report on the progress, or just be quiet? Value between -1 (nothing) and 4 (loud)
Definition: ProSHADE_settings.hpp:188
ProSHADE_internal_misc::addToDoubleVector
void addToDoubleVector(std::vector< proshade_double > *vecToAddTo, proshade_double elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:77
ProSHADE_internal_peakSearch::getBestPeakEulerAngsNaive
void getBestPeakEulerAngsNaive(proshade_complex *map, proshade_unsign dim, proshade_double *eulA, proshade_double *eulB, proshade_double *eulG, ProSHADE_settings *settings)
This function finds the highest peaks optimised Euler angles using the "naive" approach.
Definition: ProSHADE_peakSearch.cpp:351
ProSHADE_internal_peakSearch::pointsAboveNeighboursRemoveSmallHeight
void pointsAboveNeighboursRemoveSmallHeight(std::vector< proshade_double * > *pointVec, proshade_double *medianIQR, proshade_double noIQRs)
This function clears the 'higher than neighbour' vector from background values.
Definition: ProSHADE_peakSearch.cpp:132
ProSHADE_internal_peakSearch::findAllSmoothedZScorePeaksWithNeighbours
void findAllSmoothedZScorePeaksWithNeighbours(proshade_complex *map, proshade_double *YZMap, proshade_double *XZMap, proshade_double *XYMap, proshade_signed dim, proshade_signed peakSize, std::vector< proshade_double * > *allPeaksWithNeighbours)
This function firstly determines the highest peak of all smoothed Z score islands and then returns th...
Definition: ProSHADE_peakSearch.cpp:853
ProSHADE_internal_peakSearch::getXAxisArraysSmoothedZScorePeaks
void getXAxisArraysSmoothedZScorePeaks(proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed *signals, proshade_double *filteredY, proshade_double *avgFilter, proshade_double *stdFilter, proshade_double *subVec, proshade_double *medianIQR, proshade_double *scoreOverVals, proshade_complex *map, proshade_double *YZMap)
This function runs the 1D smoothed Z score algorithm on all X-axis arrays as its inputs.
Definition: ProSHADE_peakSearch.cpp:577
ProSHADE_internal_maths::getRotationMatrixFromAngleAxis
void getRotationMatrixFromAngleAxis(proshade_double *rotMat, proshade_double x, proshade_double y, proshade_double z, proshade_double ang)
This function converts the axis-angle representation to the rotation matrix representation.
Definition: ProSHADE_maths.cpp:1343
ProSHADE_settings
This class stores all the settings and is passed to the executive classes instead of a multitude of p...
Definition: ProSHADE_settings.hpp:89
ProSHADE_internal_peakSearch::getZAxisArraysSmoothedZScorePeaks
void getZAxisArraysSmoothedZScorePeaks(proshade_unsign dim, proshade_unsign smoothingLag, proshade_double ZScoreThreshold, proshade_signed *signals, proshade_double *filteredY, proshade_double *avgFilter, proshade_double *stdFilter, proshade_double *subVec, proshade_double *medianIQR, proshade_double *scoreOverVals, proshade_complex *map, proshade_double *XYMap)
This function runs the 1D smoothed Z score algorithm on all Z-axis arrays as its inputs.
Definition: ProSHADE_peakSearch.cpp:675
ProSHADE_internal_peakSearch::getBestPeakEulerAngsSmoothedZ
void getBestPeakEulerAngsSmoothedZ(proshade_complex *map, proshade_unsign dim, proshade_double smoothingFraction, proshade_double noIQRs, proshade_signed peakSize, proshade_double *eulA, proshade_double *eulB, proshade_double *eulG)
This function finds the highest peaks optimised Euler angles using the smoothed Z score approach.
Definition: ProSHADE_peakSearch.cpp:975
ProSHADE_settings::peakNeighbours
proshade_unsign peakNeighbours
Number of points in any direction that have to be lower than the considered index in order to conside...
Definition: ProSHADE_settings.hpp:164
ProSHADE_internal_misc::checkMemoryAllocation
void checkMemoryAllocation(chVar checkVar, std::string fileP, unsigned int lineP, std::string funcP, std::string infoP="This error may occurs when ProSHADE requests memory to be\n : allocated to it and this operation fails. This could\n : happen when not enough memory is available, either due to\n : other processes using a lot of memory, or when the machine\n : does not have sufficient memory available. Re-run to see\n : if this problem persists.")
Checks if memory was allocated properly.
Definition: ProSHADE_misc.hpp:65
ProSHADE_internal_maths::getEulerZXZFromSOFTPosition
void getEulerZXZFromSOFTPosition(proshade_signed band, proshade_signed x, proshade_signed y, proshade_signed z, proshade_double *eulerAlpha, proshade_double *eulerBeta, proshade_double *eulerGamma)
Function to find Euler angles (ZXZ convention) from index position in the inverse SOFT map.
Definition: ProSHADE_maths.cpp:961
ProSHADE_internal_peakSearch::optimisePeakPositions
void optimisePeakPositions(std::vector< proshade_double * > *pointVec, proshade_signed peakSize, proshade_signed band)
This function optimises all the peaks in the input vector using the values of their neighbours.
Definition: ProSHADE_peakSearch.cpp:221
ProSHADE_internal_maths::vectorMedianAndIQR
void vectorMedianAndIQR(std::vector< proshade_double > *vec, proshade_double *&ret)
Function to get vector median and inter-quartile range.
Definition: ProSHADE_maths.cpp:147
ProSHADE_peakSearch.hpp
This header file declares functions required for 3D map peak searching.
ProSHADE_internal_misc::addToUnsignVector
void addToUnsignVector(std::vector< proshade_unsign > *vecToAddTo, proshade_unsign elementToAdd)
Adds the element to the vector.
Definition: ProSHADE_misc.cpp:99
ProSHADE_internal_peakSearch::releasePeakOptimisationMemory
void releasePeakOptimisationMemory(proshade_double *&avgMat, proshade_double *&hlpMap, proshade_double *&eA, proshade_double *&eB, proshade_double *&eG, proshade_double *&uAV)
This function deletes all the peak optimisation memory.
Definition: ProSHADE_peakSearch.cpp:193
ProSHADE_internal_peakSearch::allocateSmoothingZScoreMemory
void allocateSmoothingZScoreMemory(proshade_unsign dim, proshade_double *&scoreOverVals, proshade_signed *&signals, proshade_double *&filteredY, proshade_double *&avgFilter, proshade_double *&stdFilter, proshade_double *&subVec, proshade_double *&medianIQR, proshade_double *&YZMap, proshade_double *&XZMap, proshade_double *&XYMap, proshade_unsign smLag)
This function allocates the memory required for smoothed Z score computation.
Definition: ProSHADE_peakSearch.cpp:418
ProSHADE_internal_peakSearch::findAllDisconnectedIslands
void findAllDisconnectedIslands(proshade_complex *map, proshade_double *YZMap, proshade_double *XZMap, proshade_double *XYMap, proshade_unsign dim, std::vector< proshade_unsign > *allIslandBests)
This function combines the three Z score maps, locates individual islands and returns a vector of hig...
Definition: ProSHADE_peakSearch.cpp:778
ProSHADE_internal_maths::multiplyTwoSquareMatrices
void multiplyTwoSquareMatrices(proshade_double *A, proshade_double *B, proshade_double *res, proshade_unsign dim=3)
Function to compute matrix multiplication.
Definition: ProSHADE_maths.cpp:1613
ProSHADE_internal_peakSearch::findAllPointsAboveNeighbours
std::vector< proshade_double * > findAllPointsAboveNeighbours(proshade_complex *map, proshade_unsign dim, proshade_signed peakSize, proshade_double *medianIQR)
This function finds all indices with higher value then all neighbours.
Definition: ProSHADE_peakSearch.cpp:38
ProSHADE_internal_messages::printProgressMessage
void printProgressMessage(proshade_signed verbose, proshade_signed messageLevel, std::string message)
General stdout message printing.
Definition: ProSHADE_messages.cpp:70
ProSHADE_internal_maths::complexMatrixSVDUandVOnly
void complexMatrixSVDUandVOnly(proshade_double *mat, int dim, proshade_double *uAndV, bool fail=true)
Function to compute the real matrix SVD and return the U and V matrices.
Definition: ProSHADE_maths.cpp:869
ProSHADE_internal_maths::arrayMedianAndIQR
void arrayMedianAndIQR(proshade_double *vec, proshade_unsign vecSize, proshade_double *&ret)
Function to get array median and inter-quartile range.
Definition: ProSHADE_maths.cpp:198