Xmipp  v3.23.11-Nereus
image_rotational_pca.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar coss@cnb.csic.es (2002)
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 #ifndef _PROG_IMAGE_ROTATIONAL_PCA
26 #define _PROG_IMAGE_ROTATIONAL_PCA
27 
28 #include "core/metadata_vec.h"
29 #include "core/matrix2d.h"
30 #include "core/xmipp_program.h"
31 #include "core/xmipp_filename.h"
32 #include "core/xmipp_threads.h"
33 #include "core/xmipp_image.h"
34 
35 #define IS_MASTER (rank == 0)
36 
42 {
43 public:
49  int Neigen;
51  int Nits;
53  double psi_step;
57  double shift_step;
59  int maxNimgs;
61  int Nthreads;
63  int rank;
64 
65 public:
66  // Input metadata
67  std::vector<MetaDataVec> MD;
68  // Number of images
69  size_t Nimg;
70  // Number of angles
71  int Nangles;
72  // Number of shifts
73  int Nshifts;
74  // Image size
75  size_t Xdim;
76  // Number of pixels
77  int Npixels;
78  // Mpi node
79  //MpiNode *node;
80  // H buffer
81  std::vector<double *> Hbuffer;
82  // H buffer destination addresses
83  std::vector<double *> HbufferDestination;
84  // Buffer maximum length
85  static const int HbufferMax=20;
86  // Mpi file lock
87  std::unique_ptr<Mutex> fileMutex;
88  // Thread mutex
89  std::unique_ptr<Mutex> threadMutex;
90  // SVD matrix
92  // SVD matrix
94 public:
95  // Input image
96  std::vector< Image<double> > I;
97  // Rotated and shifted image
98  std::vector< MultidimArray<double> > Iaux;
99  // Geometric transformation
100  std::vector< Matrix2D<double> > A;
101  // H block
102  std::vector< Matrix2D<double> > Hblock;
103  // W node
104  std::vector< Matrix2D<double> > Wnode;
105  // W transpose
107  // Mask
109  // FileTaskDistributor
110  std::unique_ptr<ThreadTaskDistributor> taskDistributor;
111  // Thread Manager
112  std::unique_ptr<ThreadManager> thMgr;
113  // Vector of object ids
114  std::vector<size_t> objId;
115 public:
118 
121 
123  void readParams();
124 
126  void show();
127 
129  void defineParams();
130 
132  void produceSideInfo();
133 
135  void writeToHBuffer(int idx, double *dest);
136 
138  void flushHBuffer();
139 
141  void clearHbuffer();
142 
146  void applyT();
147 
151  void applyTt();
152 
157  int QR();
158 
160  void run();
161 
162  /********************** Following functions should be overwritten in MPI version ******/
164  virtual void selectPartFromMd(MetaData &MDin);
165 
167  virtual void comunicateMatrix(Matrix2D<double> &W);
168 
170  virtual void createMutexes(size_t Nimgs);
171 
173  virtual void allReduceApplyT(Matrix2D<double> &Wnode_0);
174 
176  virtual void comunicateQrDim(int &qrDim);
177 
179  virtual void mapMatrix(int qrDim);
180 
182  virtual void applySVD();
183 
185  virtual void copyHtoF(int block);
186 };
188 #endif
void produceSideInfo()
Produce side info.
ProgImageRotationalPCA()
Empty constructor.
std::vector< Matrix2D< double > > Wnode
virtual void copyHtoF(int block)
std::unique_ptr< ThreadManager > thMgr
virtual void createMutexes(size_t Nimgs)
std::vector< Matrix2D< double > > A
std::vector< double * > Hbuffer
virtual void selectPartFromMd(MetaData &MDin)
std::vector< Matrix2D< double > > Hblock
MultidimArray< unsigned char > mask
virtual void comunicateQrDim(int &qrDim)
virtual void allReduceApplyT(Matrix2D< double > &Wnode_0)
std::vector< Image< double > > I
std::vector< MetaDataVec > MD
std::unique_ptr< Mutex > threadMutex
std::vector< double * > HbufferDestination
std::unique_ptr< ThreadTaskDistributor > taskDistributor
std::vector< size_t > objId
std::unique_ptr< Mutex > fileMutex
virtual void mapMatrix(int qrDim)
void readParams()
Read argument from command line.
void writeToHBuffer(int idx, double *dest)
std::vector< MultidimArray< double > > Iaux
virtual void comunicateMatrix(Matrix2D< double > &W)
Matrix2D< double > Wtranspose