Xmipp  v3.23.11-Nereus
forward_art_zernike3d_subtomos.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_SUBTOMOS
28 #define _PROG_FORWARD_ART_ZERNIKE3D_SUBTOMOS
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:
51  // Metadata with already processed images
52  // FileName fnDone;
54  int L1, L2;
58  double Ts;
60  int RmaxDef;
61  // Phase Flipped
63  // Ignore CTF
64  bool ignoreCTF;
65  // Regularization ART
66  double lambda;
67  // Save each # iter
68  int save_iter;
69  // Correct CTF
70  bool useCTF;
71  // Apply Zernike
72  bool useZernike;
73  // Flag for enable/disabled image
75  // Tilt angles
76  double t1, t2;
77 
78 public:
80  bool resume;
81  // Number of ART iterations
82  int niter;
83  // Sort last N projections
85  // 2D and 3D masks in real space
87  // Volume size
88  size_t Xdim;
89  // Input image
91  // INput image
93  // Spherical mask
95  // Theoretical projection
97  // Weight Image
99  // Difference Image
101  // Transformation matrix
103  // Original angles
104  double rot, tilt, psi;
105  // Original shift
106  double shiftX, shiftY, shiftZ;
107  // Original flip
108  bool flip;
109  // CTF Check
110  bool hasCTF;
111  // Original defocus
113  // CTF
115  // CTF filter
117  // Vector Size
118  int vecSize;
119  // Vector containing the degree of the spherical harmonics
120  std::vector<double> clnm;
121  // Show optimization
123  // Row ids ordered in a orthogonal fashion
125  // Save iter counter
127  // Image counter
129  // Current ART iteration
131  // Volume dimensions
133  // Blob
135  struct blobtype blob;
136  double blob_r;
137  double sigma, sigma4;
138  // Gaussian projection table
140  // Fourier transformer
142 public:
143  enum class Mode { Proj, Vol };
144 
147 
150 
152  void readParams();
153 
155  void show();
156 
158  void defineParams();
159 
162  void preProcess();
163 
169  // virtual void createWorkFiles();
170 
174  void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut);
175 
177  void numCoefficients(int l1, int l2, int &vecSize);
178 
180  void fillVectorTerms(int l1, int l2, Matrix1D<int> &vL1, Matrix1D<int> &vN,
181  Matrix1D<int> &vL2, Matrix1D<int> &vM);
182 
185  const MultidimArray<double> &mV,
186  double rot, double tilt, double psi);
187 
188  void recoverVol();
189  virtual void finishProcessing();
190 
192 
193  // void updateCTFImage(double defocusU, double defocusV, double angle);
194 
195  private:
196  enum class Direction { Forward, Backward };
197 
198  // ART algorithm
199  template <Direction DIRECTION>
200  void artModel();
201 
202  // Apply Zernike codeformation
203  template<bool USESZERNIKE, Direction DIRECTION>
204  void zernikeModel();
205 
206  // Spaltting at position r
207  void splattingAtPos(std::array<double, 3> r, double weight,
210 
211  void updateVoxel(std::array<double, 3> r, double &voxel, MultidimArray<double> &mV);
212 
213  // virtual void checkPoint();
214 
215  virtual void run();
216 
217  // Sort images in an orthogonal fashion
218  void sortOrthogonal();
219 
220 };
222 #endif
void fillVectorTerms(int l1, int l2, Matrix1D< int > &vL1, Matrix1D< int > &vN, Matrix1D< int > &vL2, Matrix1D< int > &vM)
Zernike and SPH coefficients allocation.
void readParams()
Read argument from command line.
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
void numCoefficients(int l1, int l2, int &vecSize)
Length of coefficients vector.
~ProgForwardArtZernike3DSubtomos()
Destructor.
void applyMissingWedge(MultidimArray< double > &mV)
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.