Xmipp  v3.23.11-Nereus
image_peak_high_contrast.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Federico P. de Isidro Gomez fp.deisidro@cnb.csic.es
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef __IMAGE_PEAK_HIGH_CONTRAST
27 #define __IMAGE_PEAK_HIGH_CONTRAST
28 
29 #include <iostream>
30 #include <core/xmipp_program.h>
31 #include <core/xmipp_image.h>
32 #include <core/metadata_vec.h>
33 #include <core/xmipp_fft.h>
34 #include <core/xmipp_fftw.h>
35 #include <math.h>
36 #include <limits>
37 #include <complex>
38 #include <data/fourier_filter.h>
39 #include <data/filters.h>
40 #include <string>
41 #include "symmetrize.h"
42 #include <data/morphology.h>
43 #include <data/point3D.h>
44 #include <data/point2D.h>
45 #include <data/basic_pca.h>
46 
47 #define VERBOSE_OUTPUT
48 // #define DEBUG_OUTPUT_FILES
49 // #define DEBUG_DIM
50 // #define DEBUG_PREPROCESS
51 // #define DEBUG_HCC
52 // #define DEBUG_FILTERLABEL
53 // #define DEBUG_CLUSTER
54 // #define DEBUG_COORDS_IN_SLICE
55 // #define DEBUG_DIST
56 // #define DEBUG_CENTER_COORDINATES
57 // #define DEBUG_REMOVE_DUPLICATES
58 // #define DEBUG_FILTER_COORDINATES
59 // #define DEBUG_RADIAL_AVERAGE
60 // #define DEBUG_MAHALANOBIS_DISTANCE
61 
63 {
64 
65 public:
69 
71  double fiducialSize;
72 
74  double samplingRate;
75 
77  int boxSize;
78 
81 
83  double sdThr; // Number of SD over the mean to consider a coordinate value as an outlier
84  int numberOfCoordinatesThr; // Minimum number of coordinates to keep a label
85  double mirrorCorrelationThr; // Minimum correlation between a fiducial and its mirror
86  double mahalanobisDistanceThr; // Maximum mahalanobis distance (empirical value)
87 
89  bool relaxedMode; // Relaxed mode keeps coordinates when none of them pass the mirror correlation filter
90  int relaxedModeThr = 0; // Number of coordinates to run relaxed mode
91 
94 
97 
100 
101 
102 private:
104  size_t xSize;
105  size_t ySize;
106  size_t zSize;
107  size_t nSize;
108 
110  size_t normDim;
111 
113  std::vector<int> centerOfMassX;
114  std::vector<int> centerOfMassY;
115  std::vector<int> centerOfMassZ;
116 
118  std::vector<Point3D<double>> coordinates3D;
119 
120 public:
121 
122  // --------------------- IN/OUT FUNCTIONS -----------------------------
123 
127  void readParams();
128 
132  void defineParams();
133 
137  void writeOutputCoordinates();
138 
139 
140  // ---------------------- MAIN FUNCTIONS -----------------------------
141 
146  void preprocessVolume(MultidimArray<double> &inputTomo);
147 
154 
160  void clusterHCC();
161 
166  void centerCoordinates(MultidimArray<double> volFiltered);
167 
173 
179 
180 
181  // --------------------------- UTILS functions ----------------------------
182 
186  void generateSideInfo();
187 
193  bool filterLabeledRegions(std::vector<int> coordinatesPerLabelX, std::vector<int> coordinatesPerLabelY, double centroX, double centroY) const;
194 
199  std::vector<size_t> getCoordinatesInSliceIndex(size_t slice);
200 
205  void radialAverage(MultidimArray<float> &feature, MultidimArray<float> &radialAverage, size_t numSlices) const;
206 
210  void mahalanobisDistance(std::vector<MultidimArray<float>> &setOfFeatures_RA, MultidimArray<double> &mahalanobisDistance_List) const;
211 
212  // --------------------------- MAIN ----------------------------------
213 
217  void run();
218 };
219 
220 #endif
void mahalanobisDistance(std::vector< MultidimArray< float >> &setOfFeatures_RA, MultidimArray< double > &mahalanobisDistance_List) const
void preprocessVolume(MultidimArray< double > &inputTomo)
void filterCoordinatesByCorrelation(MultidimArray< double > volFiltered)
void centerCoordinates(MultidimArray< double > volFiltered)
void getHighContrastCoordinates(MultidimArray< double > &volFiltered)
void radialAverage(MultidimArray< float > &feature, MultidimArray< float > &radialAverage, size_t numSlices) const
std::vector< size_t > getCoordinatesInSliceIndex(size_t slice)
bool filterLabeledRegions(std::vector< int > coordinatesPerLabelX, std::vector< int > coordinatesPerLabelY, double centroX, double centroY) const