Xmipp  v3.23.11-Nereus
art_zernike3d.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: David Herreros Calero dherreros@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 
27 #ifndef _PROG_ART_ZERNIKE3D
28 #define _PROG_ART_ZERNIKE3D
29 
31 #include <core/matrix1d.h>
32 #include <core/xmipp_image.h>
33 #include <data/fourier_filter.h>
35 #include <core/xmipp_error.h>
36 
37 
40 {
41 public:
49  int L1, L2;
53  double Ts;
55  int RmaxDef;
56  // Phase Flipped
58  // Ignore CTF
59  bool ignoreCTF;
60  // Regularization ART
61  float lambda;
62  // Save each # iter
63  int save_iter;
64  // Correct CTF
65  bool useCTF;
66  // Apply Zernike
67  bool useZernike;
68  // Flag for enable/disabled image
70 
71 public:
73  bool resume;
74  // Number of ART iterations
75  int niter;
76  // Sort last N projections
78  // 2D and 3D masks in real space
80  // Volume size
81  int Xdim;
82  // Input image
84  // INput image
86  // Spherical mask
88  // Theoretical projection
90  // Weight Image
92  // Difference Image
94  // Transformation matrix
96  // Original angles
97  float rot, tilt, psi;
98  // Original shift
99  float shiftX, shiftY;
100  // Original flip
101  bool flip;
102  // CTF Check
103  bool hasCTF;
104  // Original defocus
106  // CTF
108  // CTF filter
110  // Vector Size
111  int vecSize;
112  // Vector containing the degree of the spherical harmonics
114  // Show optimization
116  // Row ids ordered in a orthogonal fashion
118  // Save iter counter
120  // Image counter
122  // Current ART iteration
124  // Volume dimensions
126 public:
129 
131  void readParams();
132 
134  void show();
135 
137  void defineParams();
138 
141  void preProcess();
142 
146  void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut);
147 
149  void numCoefficients(int l1, int l2);
150 
152  void fillVectorTerms(int l1, int l2);
153 
156  const MultidimArray<float> &mV,
157  float rot, float tilt, float psi);
158 
159  private:
160  enum class Direction { Forward, Backward };
161 
162  // ART algorithm
163  template <Direction DIRECTION>
164  void artModel();
165 
166  // Apply Zernike codeformation
167  template<bool USESZERNIKE, Direction DIRECTION>
168  void zernikeModel();
169 
170  // Interpolation weights + interpolation in 3D
171  template<bool INTERPOLATE>
172  float weightsInterpolation3D(float x, float y, float z, std::array<float, 8> &w);
173 
174  // Remove overdeformation from coefficients
175  void removeOverdeformation();
176 
177  virtual void finishProcessing();
178 
179  virtual void run();
180 
181  // Sort images in an orthogonal fashion
182  void sortOrthogonal();
183 
184 };
186 #endif
void show()
Show.
Image< float > P
Definition: art_zernike3d.h:89
void defineParams()
Define parameters.
MultidimArray< int > mask2D
Definition: art_zernike3d.h:79
void readParams()
Read argument from command line.
static double * y
Matrix1D< int > vN
Definition: art_zernike3d.h:51
doublereal * w
Image< double > I
Definition: art_zernike3d.h:85
doublereal * x
FileName fnOutDir
Output directory.
Definition: art_zernike3d.h:47
MultidimArray< size_t > ordered_list
Image< float > Idiff
Definition: art_zernike3d.h:93
Matrix1D< int > vL2
Definition: art_zernike3d.h:51
FourierFilter FilterCTF
Matrix1D< int > vM
Definition: art_zernike3d.h:51
MultidimArray< int > Vmask
Definition: art_zernike3d.h:87
ProgArtZernike3D()
Empty constructor.
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
Matrix1D< float > clnm
double z
CTFDescription ctf
Image< float > W
Definition: art_zernike3d.h:91
Image< float > V
Definition: art_zernike3d.h:83
Image< float > Vrefined
Definition: art_zernike3d.h:83
Matrix2D< float > A
Definition: art_zernike3d.h:95
Image< float > Ifilteredp
Definition: art_zernike3d.h:83
Matrix1D< int > vL1
Definition: art_zernike3d.h:51
void numCoefficients(int l1, int l2)
Length of coefficients vector.
void fillVectorTerms(int l1, int l2)
Zernike and SPH coefficients allocation.
void deformVol(MultidimArray< float > &mP, MultidimArray< float > &mW, const MultidimArray< float > &mV, float rot, float tilt, float psi)
Deform a volumen using Zernike-Spherical harmonic basis.