Xmipp  v3.23.11-Nereus
mpi_classify_FTTRI.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar coss@cnb.csic.es (2012)
4  * Wang Xia wangxia@lsec.cc.ac.cn
5  * Guoliang Xu xuguo@lsec.cc.ac.cn
6  *
7  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22  * 02111-1307 USA
23  *
24  * All comments concerning this program package may be sent to the
25  * e-mail address 'xmipp@cnb.csic.es'
26  ***************************************************************************/
27 #ifndef _PROG_CLASSIFY_FTTRI
28 #define _PROG_CLASSIFY_FTTRI
29 
30 #include "parallel/xmipp_mpi.h"
31 #include "core/xmipp_image.h"
32 #include "core/metadata_vec.h"
33 
37 
40 {
41 public:
42  std::vector<size_t> memberIdx;
43  std::vector<int> neighbours;
44 };
45 
48 {
49 public:
52 
55 
57  double pad;
58 
60  double fmax;
61 
63  size_t Rmax;
64 
66  double zoom;
67 
69  double sigma1;
70 
72  double sigma2;
73 
75  size_t nref;
76 
78  size_t nMinImages;
79 
81  int Niter;
82 
84  bool doPhase;
85 public:
86  // Name of the invariants;
88  // Final size of the invariant
89  int FTTRIXdim;
90  int FTTRIYdim;
91  // Mpi node
92  std::shared_ptr<MpiNode> node;
93  // FileTaskDistributor
95  // MetaData In
97  // Object Ids
98  std::vector<size_t> imgsId;
99  // Padded size
100  int padXdim;
101  // Set of classes
102  std::vector< EpsilonClass > epsilonClasses;
103  // Initial range for epsilon
104  double dMin, dMax;
105  // Copy of bestObjective
107  // Copy of bestEpsilon
108  double bestEpsilon;
109  // Copy of bestClass
110  std::vector< EpsilonClass > bestEpsilonClasses;
111  // Epsilon of each class
113  // Epsilon max is the maximum of all class epsilons
114  double epsilonMax;
115  // Assigned to class
117  // Assigned to class init
119  // All FTTRI centroids are loaded in memory
121  // All Image centroids are loaded in memory
123 public:
125  ProgClassifyFTTRI(int argc, char **argv);
126 
128  void readParams();
129 
131  void show();
132 
134  void defineParams();
135 
137  void produceSideInfo();
138 
140  void produceFTTRI();
141 
143  void estimateEpsilonInitialRange();
144 
146  double fttri_distance(const MultidimArray<double> &fttri_i,
147  const MultidimArray<double> &fttri_j);
148 
150  void skipRandomNumberOfUnassignedClasses(
151  size_t &currentPointer, size_t remaining);
152 
154  size_t wrapperFitness(double epsilon);
155 
157  void epsilonClassification(double epsilon);
158 
160  void searchOptimalEpsilon();
161 
163  void removeSmallClasses();
164 
166  int findFarthestFTTRI(const MultidimArray<double> &fttriSeed,
167  const EpsilonClass &class_i);
168 
169  int findFarthest(const MultidimArray<double> &seed,
170  const EpsilonClass &class_i, bool FTTRI);
171 
173  void splitLargeClasses(bool FTTRI);
174 
176  void splitLargeFTTRIClasses();
177 
179  void computeClassNeighbours(bool FTTRI);
180 
181 
183  size_t reassignImagesToClasses(bool FTTRI);
184 
186  void writeResults(bool FTTRI);
187 
189  void alignImagesWithinClasses();
190 
192  void computeClassCentroids(bool FTTRI);
193 
195  void run();
196 };
198 #endif
double sigma1
First weight.
double zoom
Zoom factor for polar conversion.
double pad
Padding factor.
double wrapperFitness(double *p, void *params)
int Niter
Number of iterations.
double fmax
Maximum frequency (normalized to 0.5)
std::shared_ptr< MpiNode > node
std::vector< size_t > memberIdx
size_t Rmax
Maximum frequency in pixels.
size_t nMinImages
Minimum number of images in a class.
std::vector< size_t > imgsId
std::vector< int > neighbours
Image< double > fttriCentroids
Matrix1D< unsigned char > notAssigned
Matrix1D< double > classEpsilon
MpiTaskDistributor * taskDistributor
size_t nref
Desired number of classes.
FileName fnRoot
Output rootname.
std::vector< EpsilonClass > bestEpsilonClasses
FileName fnIn
Input selfile.
bool doPhase
Do phase optimization.
Matrix1D< unsigned char > notAssigned0
Image< double > imageCentroids
double epsilon
std::vector< EpsilonClass > epsilonClasses
double sigma2
Second weight.