Xmipp  v3.23.11-Nereus
common_lines.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar S. Sorzano (coss@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 _PROG_COMMONLINES_HH
27 #define _PROG_COMMONLINES_HH
28 
29 #include "core/matrix1d.h"
30 #include "core/matrix2d.h"
31 #include "core/metadata_vec.h"
32 #include "core/xmipp_program.h"
33 
34 template<typename T>
36 
40 /* Parameters -------------------------------------------------------------- */
43 {
44 public:
46  double angi=0.0;
48  double angj=0.0;
50  double distanceij=-1;
54  int jmax=0;
56  double percentile=-1;
57 };
58 
61 {
62 public:
74  double lpf;
76  double hpf;
78  double stepAng;
79 
81  double mem;
83  int Nthr;
85  int Nmpi;
87  int rank;
88 public:
90  ProgCommonLine(): rank(0) {};
91 
93  void readParams();
94 
96  void defineParams();
97 
99  void produceSideInfo();
100 
102  void processBlock(int i, int j);
103 
105  void getAndPrepareBlock(int i,
106  std::vector< MultidimArray<std::complex<double> > > &blockRTFs,
107  std::vector<MultidimArray<double> > &blockRTs);
108 
110  void show();
111 
113  void qualifyCommonLines();
114 
116  void solveForShifts();
117 
119  void writeResults();
120 
122  void run();
123 public:
124  // Block size
125  int Nblock;
126 
127  // Input selfile
129 
130  // Number of images
131  int Nimg;
132 
133  // Xdim size of the images
134  size_t Xdim;
135 
136  // Common line matrix
137  std::vector<CommonLine> CLmatrix;
138 
139  // Estimated shifts
141 };
142 
143 #define POW2(x) (x*x)
144 
145 
153 {
154 public:
155  size_t nRays; //Number of rays in Fourier space
156  int k[2]; //image projection indexes;
157  int idx[2]; //commonlines indexes in k1 and k2;
158  DVector vector; //direction vector
159 
160  CommonLineInfo(int n, int k1=0, int k2=0)
161  {
162  nRays = n;
163  setImages(k1, k2);
164  idx[0] = idx[1] = 0;
165  vector.initZeros(3);
166  }
167 
168  int getImage(int i)
169  {
170  return k[i];
171  }
172 
173  int getIndex(int i)
174  {
175  return idx[i];
176  }
177 
178  void setImages(int k1, int k2)
179  {
180  k[0] = k1;
181  k[1] = k2;
182  }
183 
184  void setIndex(int i, double theta)
185  {
186  idx[i] = ROUND(theta/TWOPI * nRays) % nRays;
187  }
188 }
189 ;//class CommonLineInfo
190 
191 void randomQuaternions(int k, DMatrix &qArray);
192 
193 void saveMatrix(const char *fn, DMatrix &array);
194 
195 void quaternionToMatrix(const DVector &q, DMatrix &rotMatrix);
196 
197 void quaternionCommonLines(const DMatrix &quaternions, CommonLineInfo &clInfo);
198 
199 void commonlineMatrixCheat(const DMatrix &quaternions, size_t nRays,
200  DMatrix &clMatrix, DMatrix &clCorr);
201 
202 void anglesRotationMatrix(size_t nRays, int i, int j, DMatrix &U);
203 
204 constexpr signed int SMALL_TRIANGLE = -101;
208 int tripletRotationMatrix(const DMatrix &clMatrix, size_t nRays, int k1, int k2, int k3, DMatrix &R);
209 
210 void computeSyncMatrix(const DMatrix &clMatrix, size_t nRays, DMatrix &sMatrix);
211 
212 void rotationsFromSyncMatrix(const DMatrix &sMatrix);
213 
214 
215 
217 
218 #endif
double lpf
Low pass filter.
Definition: common_lines.h:74
String outputStyle
Output style.
Definition: common_lines.h:68
void setIndex(int i, double theta)
Definition: common_lines.h:184
void quaternionCommonLines(const DMatrix &quaternions, CommonLineInfo &clInfo)
void setImages(int k1, int k2)
Definition: common_lines.h:178
constexpr signed int SMALL_TRIANGLE
Definition: common_lines.h:204
CommonLine Parameters.
Definition: common_lines.h:60
void commonlineMatrixCheat(const DMatrix &quaternions, size_t nRays, DMatrix &clMatrix, DMatrix &clCorr)
int getImage(int i)
Definition: common_lines.h:168
#define TWOPI
Definition: xmipp_macros.h:111
double hpf
High pass filter.
Definition: common_lines.h:76
MetaDataVec SF
Definition: common_lines.h:128
double angj
Angle of the best common line in image j.
Definition: common_lines.h:48
void randomQuaternions(int k, DMatrix &qArray)
void anglesRotationMatrix(size_t nRays, int i, int j, DMatrix &U)
Commonline.
Definition: common_lines.h:42
#define i
double angi
Angle of the best common line in image i.
Definition: common_lines.h:46
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
double theta
double mem
Memory limit.
Definition: common_lines.h:81
std::vector< CommonLine > CLmatrix
Definition: common_lines.h:137
int Nthr
Number of threads.
Definition: common_lines.h:83
int tripletRotationMatrix(const DMatrix &clMatrix, size_t nRays, int k1, int k2, int k3, DMatrix &R)
void computeSyncMatrix(const DMatrix &clMatrix, size_t nRays, DMatrix &sMatrix)
int Nmpi
Number of processors.
Definition: common_lines.h:85
void quaternionToMatrix(const DVector &q, DMatrix &rotMatrix)
double stepAng
Angular sampling.
Definition: common_lines.h:78
#define ROUND(x)
Definition: xmipp_macros.h:210
void initZeros()
Definition: matrix1d.h:592
double outlierFraction
Outlier fraction.
Definition: common_lines.h:72
double distanceij
Distance between both common lines.
Definition: common_lines.h:50
Matrix1D< double > shift
Definition: common_lines.h:140
#define j
int rank
MPI Rank.
Definition: common_lines.h:87
FileName fn_sel
input file
Definition: common_lines.h:64
void saveMatrix(const char *fn, DMatrix &array)
std::string String
Definition: xmipp_strings.h:34
FileName fn_out
output file
Definition: common_lines.h:66
int getIndex(int i)
Definition: common_lines.h:173
CommonLineInfo(int n, int k1=0, int k2=0)
Definition: common_lines.h:160
void rotationsFromSyncMatrix(const DMatrix &sMatrix)
double percentile
Percentile (good common lines have very high percentiles)
Definition: common_lines.h:56
int * n
bool scaleDistance
Scale output measure.
Definition: common_lines.h:70