Xmipp  v3.23.11-Nereus
mpi_angular_class_average.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: AUTHOR_NAME (aerey@cnb.csic.es)
3  *
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 MPI_ANGULAR_CLASS_AVERAGE_H_
27 #define MPI_ANGULAR_CLASS_AVERAGE_H_
28 
29 //mpirun -np 5 xmipp_mpi_angular_class_average --nJobs 70
30 
31 #include "parallel/xmipp_mpi.h"
32 #include "core/metadata_db.h"
33 #include "core/xmipp_image.h"
34 #include "data/polar.h"
35 
36 //Tags already defined in xmipp
37 //#define TAG_WORK 0
38 //#define TAG_STOP 1
39 constexpr int TAG_I_FINISH_WRITTING = 12;
40 constexpr int TAG_MAY_I_WRITE = 13;
41 constexpr int TAG_YES_YOU_MAY_WRITE = 14;
42 constexpr int TAG_DO_NOT_DARE_TO_WRITE = 15;
43 constexpr int TAG_I_AM_FREE = 16;
44 
45 constexpr int lockWeightIndexesSize = 5;
46 constexpr int index_lockIndex = 0;
47 constexpr int index_weight = 1;
48 constexpr int index_weights1 = 2;
49 constexpr int index_weights2 = 3;
50 constexpr int index_ref3d = 4;
51 
52 constexpr int ArraySize = 8;
53 constexpr int index_DefGroup = 0;
54 constexpr int index_2DRef = 1;
55 constexpr int index_3DRef = 2;
56 constexpr int index_Order = 3;
57 constexpr int index_Count = 4;
58 constexpr int index_jobId = 5;
59 constexpr int index_Rot = 6;
60 constexpr int index_Tilt = 7;
61 
62 constexpr int AVG_OUPUT_SIZE = 10;
63 
64 constexpr int split0 = 0;
65 constexpr int split1 = 1;
66 constexpr int split2 = 2;
67 
70 
72 {
73 public:
74  // Seed
75  unsigned int master_seed;
76 
77  // Metadata with the list of jobs
79 
87  std::string col_select;
93  bool do_mirrors;
95  bool do_split;
97  size_t paddim;
99  double pad;
105  bool do_add;
112 
118  int Ri, Ro;
120  int nr_iter;
122  double eps;
124  double max_shift;
131 
133  int ctfNum;
135  int ref3dNum;
137  size_t Xdim, Ydim, Zdim, Ndim;
138 
140  size_t mpi_job_size;
141 
142  //Lock structure
147 
149 
150  MpiProgAngularClassAverage(int argc, char **argv);
151 
153 // void read(int argc, char** argv);
154 
155  void readParams();
156 
157  void defineParams();
158 
159  void run();
160 
163  void mpi_process_loop(double * Def_3Dref_2Dref_JobNo);
164 
167  void mpi_process(double * Def_3Dref_2Dref_JobNo);
168 
171  void mpi_produceSideInfo();
172 
175  void mpi_preprocess();
176 
179  void filterInputMetadata();
180 
183  void saveDiscardedImages();
184 
187  void initFileNames();
188 
191  void initDimentions();
192 
195  void initWeights();
196 
199  void initOutputFiles();
200 
203  void mpi_postprocess();
204 
207  void createJobList();
208 
211  void mpi_write(
212  size_t dirno,
213  int ref3dIndex,
214  Image<double> avg,
215  Image<double> avg1,
216  Image<double> avg2,
217  double w1,
218  double w2,
219  double old_w,
220  double old_w1,
221  double old_w2);
222 
225  void mpi_writeController(
226  size_t dirno,
227  Image<double> avg,
228  Image<double> avg1,
229  Image<double> avg2,
230  const MetaDataDb& SFclass,
231  const MetaDataDb& SFclass1,
232  const MetaDataDb& SFclass2,
233  const MetaDataDb& SFclassDiscarded,
234  const MetaDataDb& _DF,
235  double w1,
236  double w2,
237  double w,
238  int lockIndex);
239 
242  void mpi_writeFile(
243  Image<double> avg,
244  size_t dirno,
245  FileName fileNameStk,
246  double w_old);
247 
250  void getPolar(
252  Polar<std::complex <double> > &fP,
253  bool conjugated=false,
254  float xoff = 0.,
255  float yoff = 0.);
256 
259  void reAlignClass(
260  Image<double> &avg1,
261  Image<double> &avg2,
262  MetaData &SFclass1,
263  MetaData &SFclass2,
264  std::vector<Image<double> > imgs,
265  std::vector<int> splits,
266  std::vector<int> numbers,
267  size_t dirno,
268  double * my_output);
269 
273 
274 };
276 #endif /* MPI_ANGULAR_CLASS_AVERAGE_H_ */
277 
278 
279 
void mpi_process_loop(double *Def_3Dref_2Dref_JobNo)
constexpr int index_2DRef
constexpr int index_lockIndex
void mpi_write(size_t dirno, int ref3dIndex, Image< double > avg, Image< double > avg1, Image< double > avg2, double w1, double w2, double old_w, double old_w1, double old_w2)
constexpr int index_DefGroup
void mpi_writeFile(Image< double > avg, size_t dirno, FileName fileNameStk, double w_old)
constexpr int AVG_OUPUT_SIZE
constexpr int TAG_YES_YOU_MAY_WRITE
constexpr int index_weights1
void reAlignClass(Image< double > &avg1, Image< double > &avg2, MetaData &SFclass1, MetaData &SFclass2, std::vector< Image< double > > imgs, std::vector< int > splits, std::vector< int > numbers, size_t dirno, double *my_output)
doublereal * w
constexpr int index_Count
constexpr int TAG_DO_NOT_DARE_TO_WRITE
constexpr int index_Order
int argc
Original command line arguments.
Definition: xmipp_program.h:86
MultidimArray< double > weightArray
MultidimArray< double > weightArrays1
constexpr int index_weight
void getPolar(MultidimArray< double > &img, Polar< std::complex< double > > &fP, bool conjugated=false, float xoff=0., float yoff=0.)
constexpr int lockWeightIndexesSize
void mpi_writeController(size_t dirno, Image< double > avg, Image< double > avg1, Image< double > avg2, const MetaDataDb &SFclass, const MetaDataDb &SFclass1, const MetaDataDb &SFclass2, const MetaDataDb &SFclassDiscarded, const MetaDataDb &_DF, double w1, double w2, double w, int lockIndex)
const char ** argv
Definition: xmipp_program.h:87
constexpr int ArraySize
constexpr int index_3DRef
constexpr int TAG_MAY_I_WRITE
constexpr int index_Tilt
constexpr int TAG_I_FINISH_WRITTING
MultidimArray< double > weightArrays2
constexpr int index_ref3d
void mpi_process(double *Def_3Dref_2Dref_JobNo)
constexpr int TAG_I_AM_FREE
constexpr int index_weights2
void applyWienerFilter(MultidimArray< double > &img)
constexpr int split1
Definition: polar.h:67
constexpr int split2
constexpr int index_jobId
constexpr int split0
constexpr int index_Rot