Xmipp  v3.23.11-Nereus
forward_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_FORWARD_ART_ZERNIKE3D
28 #define _PROG_FORWARD_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 #include <data/blobs.h>
37 
38 
41 {
42 public:
52  int L1, L2;
56  double Ts;
58  int RmaxDef;
59  // Phase Flipped
61  // Ignore CTF
62  bool ignoreCTF;
63  // Regularization ART
64  double lambda;
65  // Save each # iter
66  int save_iter;
67  // Correct CTF
68  bool useCTF;
69  // Apply Zernike
70  bool useZernike;
71  // Flag for enable/disabled image
73 
74 public:
76  bool resume;
77  // Number of ART iterations
78  int niter;
79  // Sort last N projections
81  // 2D and 3D masks in real space
83  // Volume size
84  size_t Xdim;
85  // Input image
87  // INput image
89  // Spherical mask
91  // Theoretical projection
93  // Weight Image
95  // Difference Image
97  // Transformation matrix
99  // Original angles
100  double rot, tilt, psi;
101  // Original shift
102  double shiftX, shiftY;
103  // Original flip
104  bool flip;
105  // CTF Check
106  bool hasCTF;
107  // Original defocus
109  // CTF
111  // CTF filter
113  // Vector Size
114  int vecSize;
115  // Vector containing the degree of the spherical harmonics
116  std::vector<double> clnm;
117  // Show optimization
119  // Row ids ordered in a orthogonal fashion
121  // Save iter counter
123  // Image counter
124  size_t num_images;
126  // Current ART iteration
128  // Volume dimensions
130  // Blob
132  struct blobtype blob;
133  double blob_r;
134  double sigma, sigma4;
135  // Gaussian projection table
137 
138  // Gaussian projection2 table
140 
141  // Filter
143 public:
144  enum class Mode { Proj, Vol };
145 
148 
151 
153  void readParams();
154 
156  void show();
157 
159  void defineParams();
160 
163  void preProcess();
164 
168  void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut);
169 
171  void numCoefficients(int l1, int l2, int &vecSize);
172 
174  void fillVectorTerms(int l1, int l2, Matrix1D<int> &vL1, Matrix1D<int> &vN,
175  Matrix1D<int> &vL2, Matrix1D<int> &vM);
176 
179  const MultidimArray<double> &mV,
180  double rot, double tilt, double psi);
181 
182  void recoverVol();
183  virtual void finishProcessing();
184 
185  double bspline1(double x);
186 
187  private:
188  enum class Direction { Forward, Backward };
189 
190  // ART algorithm
191  template <Direction DIRECTION>
192  void artModel();
193 
194  // Apply Zernike codeformation
195  template<bool USESZERNIKE, Direction DIRECTION>
196  void zernikeModel();
197 
198  // Spaltting at position r
199  void splattingAtPos(std::array<double, 2> r, double weight,
202 
203  void updateVoxel(std::array<double, 3> r, double &voxel, MultidimArray<double> &mV);
204 
205  virtual void run();
206 
207  // Sort images in an orthogonal fashion
208  void sortOrthogonal();
209 
210 };
212 #endif
Matrix1D< double > gaussianProjectionTable
std::vector< double > clnm
void defineParams()
Define parameters.
void readParams()
Read argument from command line.
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
~ProgForwardArtZernike3D()
Destructor.
MultidimArray< int > Vmask
doublereal * x
Matrix1D< double > gaussianProjectionTable2
FileName fnOutDir
Output directory.
MultidimArray< size_t > ordered_list
void fillVectorTerms(int l1, int l2, Matrix1D< int > &vL1, Matrix1D< int > &vN, Matrix1D< int > &vL2, Matrix1D< int > &vM)
Zernike and SPH coefficients allocation.
MultidimArray< int > mask2D
ProgForwardArtZernike3D()
Empty constructor.
void numCoefficients(int l1, int l2, int &vecSize)
Length of coefficients vector.
void deformVol(MultidimArray< double > &mP, MultidimArray< double > &mW, const MultidimArray< double > &mV, double rot, double tilt, double psi)
Deform a volumen using Zernike-Spherical harmonic basis.