Xmipp  v3.23.11-Nereus
Public Types | Public Member Functions | Public Attributes | List of all members
ProgParallelForwardArtZernike3D Class Reference

#include <parallel_forward_art_zernike3d.h>

Inheritance diagram for ProgParallelForwardArtZernike3D:
Inheritance graph
[legend]
Collaboration diagram for ProgParallelForwardArtZernike3D:
Collaboration graph
[legend]

Public Types

enum  Mode { Mode::Proj, Mode::Vol }
 

Public Member Functions

 ProgParallelForwardArtZernike3D ()
 Empty constructor. More...
 
 ~ProgParallelForwardArtZernike3D ()
 Destructor. More...
 
void readParams ()
 Read argument from command line. More...
 
void show ()
 Show. More...
 
void defineParams ()
 Define parameters. More...
 
void preProcess ()
 
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. More...
 
void fillVectorTerms (int l1, int l2, Matrix1D< int > &vL1, Matrix1D< int > &vN, Matrix1D< int > &vL2, Matrix1D< int > &vM)
 Zernike and SPH coefficients allocation. More...
 
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. More...
 
void recoverVol ()
 
virtual void finishProcessing ()
 
- Public Member Functions inherited from XmippMetadataProgram
MetaDatagetInputMd ()
 
MetaDataVecgetOutputMd ()
 
 XmippMetadataProgram ()
 Empty constructor. More...
 
virtual int tryRead (int argc, const char **argv, bool reportErrors=true)
 
virtual void init ()
 
virtual void setup (MetaData *md, const FileName &o="", const FileName &oroot="", bool applyGeo=false, MDLabel label=MDL_IMAGE)
 
virtual ~XmippMetadataProgram ()
 
void setMode (WriteModeMetaData _mode)
 
void setupRowOut (const FileName &fnImgIn, const MDRow &rowIn, const FileName &fnImgOut, MDRow &rowOut) const
 Prepare rowout. More...
 
virtual void wait ()
 Wait for the distributor to finish. More...
 
virtual void checkPoint ()
 For very long programs, it may be needed to write checkpoints. More...
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Public Attributes

FileName fnVolR
 
FileName fnMaskRF
 
FileName fnMaskRB
 
FileName fnVolO
 
FileName fnOutDir
 Output directory. More...
 
int L1
 
int L2
 
Matrix1D< int > vL1
 
Matrix1D< int > vN
 
Matrix1D< int > vL2
 
Matrix1D< int > vM
 
double Ts
 
int RmaxDef
 
bool phaseFlipped
 
bool ignoreCTF
 
double lambda
 
int save_iter
 
bool useCTF
 
bool useZernike
 
int flagEnabled
 
bool resume
 
int niter
 
int sort_last_N
 
MultidimArray< int > mask2D
 
size_t Xdim
 
Image< double > V
 
Image< double > Vrefined
 
Image< double > Vout
 
Image< double > Ifilteredp
 
Image< double > I
 
MultidimArray< int > VRecMaskF
 
MultidimArray< int > VRecMaskB
 
std::vector< Image< double > > P
 
std::vector< Image< double > > W
 
std::vector< std::unique_ptr< std::atomic< double * > > > p_busy_elem
 
std::vector< std::unique_ptr< std::atomic< double * > > > w_busy_elem
 
Image< double > Idiff
 
Matrix2D< double > A
 
double rot
 
double tilt
 
double psi
 
double shiftX
 
double shiftY
 
bool flip
 
bool hasCTF
 
double defocusU
 
double defocusV
 
double defocusAngle
 
CTFDescription ctf
 
FourierFilter FilterCTF
 
int vecSize
 
std::vector< double > clnm
 
bool showOptimization
 
MultidimArray< size_t > ordered_list
 
int current_save_iter
 
size_t num_images
 
size_t current_image
 
int current_iter
 
int initX
 
int endX
 
int initY
 
int endY
 
int initZ
 
int endZ
 
int loop_step
 
std::vector< double > sigma
 
FourierFilter filter
 
FourierFilter filter2
 
ctpl::thread_pool m_threadPool
 
int threads
 
- Public Attributes inherited from XmippMetadataProgram
FileName fn_in
 Filenames of input and output Metadata. More...
 
FileName fn_out
 
FileName baseName
 
FileName pathBaseName
 
FileName oextBaseName
 
bool apply_geo
 Apply geo. More...
 
size_t ndimOut
 Output dimensions. More...
 
size_t zdimOut
 
size_t ydimOut
 
size_t xdimOut
 
DataType datatypeOut
 
size_t mdInSize
 Number of input elements. More...
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippMetadataProgram
virtual void initComments ()
 
virtual void postProcess ()
 
virtual bool getImageToProcess (size_t &objId, size_t &objIndex)
 
void show () const override
 
virtual void startProcessing ()
 
virtual void writeOutput ()
 
virtual void showProgress ()
 
virtual void defineLabelParam ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippMetadataProgram
WriteModeMetaData mode
 Metadata writing mode: OVERWRITE, APPEND. More...
 
FileName oext
 Output extension and root. More...
 
FileName oroot
 
MDLabel image_label
 MDLabel to be used to read/write images, usually will be MDL_IMAGE. More...
 
bool produces_an_output
 Indicate that a unique final output is produced. More...
 
bool produces_a_metadata
 Indicate that the unique final output file is a Metadata. More...
 
bool each_image_produces_an_output
 Indicate that an output is produced for each image in the input. More...
 
bool allow_apply_geo
 
bool decompose_stacks
 Input Metadata will treat a stack file as a set of images instead of a unique file. More...
 
bool delete_output_stack
 Delete previous output stack file prior to process images. More...
 
bool get_image_info
 Get the input image file dimensions to further operations. More...
 
bool save_metadata_stack
 Save the associated output metadata when output file is a stack. More...
 
bool track_origin
 Include the original input image filename in the output stack. More...
 
bool keep_input_columns
 Keep input metadata columns. More...
 
bool remove_disabled
 Remove disabled images from the input selfile. More...
 
bool allow_time_bar
 Show process time bar. More...
 
bool input_is_metadata
 Input is a metadata. More...
 
bool single_image
 Input is a single image. More...
 
bool input_is_stack
 Input is a stack. More...
 
bool output_is_stack
 Output is a stack. More...
 
bool create_empty_stackfile
 
bool delete_mdIn
 
size_t time_bar_step
 Some time bar related counters. More...
 
size_t time_bar_size
 
size_t time_bar_done
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

Predict Continuous Parameters.

Definition at line 42 of file parallel_forward_art_zernike3d.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Proj 
Vol 

Definition at line 148 of file parallel_forward_art_zernike3d.h.

148 { Proj, Vol };

Constructor & Destructor Documentation

◆ ProgParallelForwardArtZernike3D()

ProgParallelForwardArtZernike3D::ProgParallelForwardArtZernike3D ( )

Empty constructor.

Definition at line 38 of file parallel_forward_art_zernike3d.cpp.

39 {
40  resume = false;
41  produces_a_metadata = true;
43  showOptimization = false;
44 }
bool each_image_produces_an_output
Indicate that an output is produced for each image in the input.
bool produces_a_metadata
Indicate that the unique final output file is a Metadata.

◆ ~ProgParallelForwardArtZernike3D()

ProgParallelForwardArtZernike3D::~ProgParallelForwardArtZernike3D ( )
default

Destructor.

Member Function Documentation

◆ defineParams()

void ProgParallelForwardArtZernike3D::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippMetadataProgram.

Definition at line 120 of file parallel_forward_art_zernike3d.cpp.

121 {
122  addUsageLine("Template-based canonical volume reconstruction through Zernike3D coefficients");
123  defaultComments["-i"].clear();
124  defaultComments["-i"].addComment("Metadata with initial alignment");
125  defaultComments["-o"].clear();
126  defaultComments["-o"].addComment("Refined volume");
128  addParamsLine(" [--ref <volume=\"\">] : Reference volume");
129  addParamsLine(" [--maskf <m=\"\">] : ART forward model reconstruction mask");
130  addParamsLine(" [--maskb <m=\"\">] : ART backward model reconstruction mask");
131  addParamsLine(" [--odir <outputDir=\".\">] : Output directory");
132  addParamsLine(" [--sampling <Ts=1>] : Sampling rate (A/pixel)");
133  addParamsLine(" [--RDef <r=-1>] : Maximum radius of the deformation (px). -1=Half of volume size");
134  addParamsLine(" [--l1 <l1=3>] : Degree Zernike Polynomials=1,2,3,...");
135  addParamsLine(" [--l2 <l2=2>] : Harmonical depth of the deformation=1,2,3,...");
136  addParamsLine(" [--blobr <b=4>] : Blob radius for forward mapping splatting");
137  addParamsLine(" [--step <step=1>] : Voxel index step");
138  addParamsLine(" [--sigma <Matrix1D=\"2\">] : Gaussian sigma");
139  addParamsLine(" [--useZernike] : Correct heterogeneity with Zernike3D coefficients");
140  addParamsLine(" [--useCTF] : Correct CTF during ART reconstruction");
141  addParamsLine(" [--phaseFlipped] : Input images have been phase flipped");
142  addParamsLine(" [--regularization <l=0.01>] : ART regularization weight");
143  addParamsLine(" [--niter <n=1>] : Number of ART iterations");
144  addParamsLine(" [--save_iter <s=0>] : Save intermidiate volume after #save_iter iterations");
145  addParamsLine(" [--sort_last <N=2>] : The algorithm sorts projections in the most orthogonally possible way. ");
146  addParamsLine(" : The most orthogonal way is defined as choosing the projection which maximizes the ");
147  addParamsLine(" : dot product with the N previous inserted projections. Use -1 to sort with all ");
148  addParamsLine(" : previous projections");
149  addParamsLine(" [--resume] : Resume processing");
150  addParamsLine(" [--thr <N=-1>] : Maximal number of the processing CPU threads");
151  addExampleLine("A typical use is:", false);
152  addExampleLine("xmipp_parallel_forward_art_zernike3d -i anglesFromContinuousAssignment.xmd --ref reference.vol -o assigned_anglesAndDeformations.xmd --l1 3 --l2 2");
153 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)
std::map< String, CommentList > defaultComments
Definition: xmipp_program.h:83

◆ deformVol()

void ProgParallelForwardArtZernike3D::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.

◆ fillVectorTerms()

void ProgParallelForwardArtZernike3D::fillVectorTerms ( int  l1,
int  l2,
Matrix1D< int > &  vL1,
Matrix1D< int > &  vN,
Matrix1D< int > &  vL2,
Matrix1D< int > &  vM 
)

Zernike and SPH coefficients allocation.

Definition at line 386 of file parallel_forward_art_zernike3d.cpp.

388 {
389  int idx = 0;
390  vL1.initZeros(vecSize);
391  vN.initZeros(vecSize);
392  vL2.initZeros(vecSize);
393  vM.initZeros(vecSize);
394  for (int h = 0; h <= l2; h++)
395  {
396  int totalSPH = 2 * h + 1;
397  int aux = std::floor(totalSPH / 2);
398  for (int l = h; l <= l1; l += 2)
399  {
400  for (int m = 0; m < totalSPH; m++)
401  {
402  VEC_ELEM(vL1, idx) = l;
403  VEC_ELEM(vN, idx) = h;
404  VEC_ELEM(vL2, idx) = h;
405  VEC_ELEM(vM, idx) = m - aux;
406  idx++;
407  }
408  }
409  }
410 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
__host__ __device__ float2 floor(const float2 v)
void initZeros()
Definition: matrix1d.h:592
int m

◆ finishProcessing()

void ProgParallelForwardArtZernike3D::finishProcessing ( )
virtual

Reimplemented from XmippMetadataProgram.

Definition at line 310 of file parallel_forward_art_zernike3d.cpp.

311 {
312  recoverVol();
313  Vout.write(fnVolO);
314 }
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)

◆ numCoefficients()

void ProgParallelForwardArtZernike3D::numCoefficients ( int  l1,
int  l2,
int &  vecSize 
)

Length of coefficients vector.

Definition at line 368 of file parallel_forward_art_zernike3d.cpp.

369 {
370  for (int h = 0; h <= l2; h++)
371  {
372  int numSPH = 2 * h + 1;
373  int count = l1 - h + 1;
374  int numEven = (count >> 1) + (count & 1 && !(h & 1));
375  if (h % 2 == 0)
376  {
377  vecSize += numSPH * numEven;
378  }
379  else
380  {
381  vecSize += numSPH * (l1 - h + 1 - numEven);
382  }
383  }
384 }

◆ preProcess()

void ProgParallelForwardArtZernike3D::preProcess ( )
virtual

Produce side info. An exception is thrown if any of the files is not found

Reimplemented from XmippMetadataProgram.

Definition at line 155 of file parallel_forward_art_zernike3d.cpp.

156 {
157 
158  // Check that metadata has all information neede
159  if (!getInputMd()->containsLabel(MDL_ANGLE_ROT) ||
160  !getInputMd()->containsLabel(MDL_ANGLE_TILT) ||
161  !getInputMd()->containsLabel(MDL_ANGLE_PSI))
162  {
163  REPORT_ERROR(ERR_MD_MISSINGLABEL, "Input metadata projection angles are missing. Exiting...");
164  }
165 
166  if (fnVolR != "")
167  {
168  V.read(fnVolR);
169  }
170  else
171  {
172  FileName fn_first_image;
173  Image<double> first_image;
174  getInputMd()->getRow(1)->getValue(MDL_IMAGE, fn_first_image);
175  first_image.read(fn_first_image);
176  size_t Xdim_first = XSIZE(first_image());
177  V().initZeros(Xdim_first, Xdim_first, Xdim_first);
178  }
179  V().setXmippOrigin();
180 
181  Xdim = XSIZE(V());
182 
183  p_busy_elem.resize(Xdim*Xdim);
184  for (auto& p : p_busy_elem) {
185  p = std::make_unique<std::atomic<double*>>(nullptr);
186  }
187 
188  w_busy_elem.resize(Xdim*Xdim);
189  for (auto& p : w_busy_elem) {
190  p = std::make_unique<std::atomic<double*>>(nullptr);
191  }
192 
193  Vout().initZeros(V());
194  Vout().setXmippOrigin();
195 
196  if (resume && fnVolO.exists())
197  {
199  }
200  else
201  {
202  Vrefined() = V();
203  }
204  // Vrefined().initZeros(V());
205  Vrefined().setXmippOrigin();
206 
207  if (RmaxDef < 0)
208  RmaxDef = Xdim / 2;
209 
210  // Transformation matrix
211  A.initIdentity(3);
212 
213  // CTF Filter
216  FilterCTF.ctf.enable_CTFnoise = false;
217  FilterCTF.ctf.enable_CTF = true;
218 
219  // Area where Zernike3D basis is computed (and volume is updated)
220  // Read Reference mask if avalaible (otherwise sphere of radius RmaxDef is used)
221  Mask mask;
222  mask.type = BINARY_CIRCULAR_MASK;
223  mask.mode = INNER_MASK;
224  if (fnMaskRF != "")
225  {
226  Image<double> aux;
227  aux.read(fnMaskRF);
228  typeCast(aux(), VRecMaskF);
230  double Rmax2 = RmaxDef * RmaxDef;
231  for (int k = STARTINGZ(VRecMaskF); k <= FINISHINGZ(VRecMaskF); k++)
232  {
233  for (int i = STARTINGY(VRecMaskF); i <= FINISHINGY(VRecMaskF); i++)
234  {
235  for (int j = STARTINGX(VRecMaskF); j <= FINISHINGX(VRecMaskF); j++)
236  {
237  double r2 = k * k + i * i + j * j;
238  if (r2 >= Rmax2)
239  A3D_ELEM(VRecMaskF, k, i, j) = 0;
240  }
241  }
242  }
243  }
244  else
245  {
246  mask.R1 = RmaxDef;
247  mask.generate_mask(V());
248  VRecMaskF = mask.get_binary_mask();
250  }
251 
252 
253  // Mask determining reconstruction area
254  if (fnMaskRB != "")
255  {
256  Image<double> aux;
257  aux.read(fnMaskRB);
258  typeCast(aux(), VRecMaskB);
260  double Rmax2 = RmaxDef * RmaxDef;
261  for (int k = STARTINGZ(VRecMaskB); k <= FINISHINGZ(VRecMaskB); k++)
262  {
263  for (int i = STARTINGY(VRecMaskB); i <= FINISHINGY(VRecMaskB); i++)
264  {
265  for (int j = STARTINGX(VRecMaskB); j <= FINISHINGX(VRecMaskB); j++)
266  {
267  double r2 = k * k + i * i + j * j;
268  if (r2 >= Rmax2)
269  A3D_ELEM(VRecMaskB, k, i, j) = 0;
270  }
271  }
272  }
273  }
274  else
275  {
276  mask.R1 = RmaxDef;
277  mask.generate_mask(V());
278  VRecMaskB = mask.get_binary_mask();
280  }
281 
282  // Init P and W vector of images
283  P.resize(sigma.size());
284  W.resize(sigma.size());
285 
286  // Area Zernike3D in 2D
287  mask.R1 = RmaxDef;
288  mask.generate_mask(XSIZE(V()), XSIZE(V()));
289  mask2D = mask.get_binary_mask();
291 
292  vecSize = 0;
294  fillVectorTerms(L1, L2, vL1, vN, vL2, vM);
295 
296  // createWorkFiles();
297  initX = STARTINGX(Vrefined());
298  endX = FINISHINGX(Vrefined());
299  initY = STARTINGY(Vrefined());
300  endY = FINISHINGY(Vrefined());
301  initZ = STARTINGZ(Vrefined());
302  endZ = FINISHINGZ(Vrefined());
303 
308 }
Rotation angle of an image (double,degrees)
std::vector< std::unique_ptr< std::atomic< double * > > > w_busy_elem
CTFDescription ctf
#define FINISHINGX(v)
#define CTFINV
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Definition: mask.h:360
Tilting angle of an image (double,degrees)
void fillVectorTerms(int l1, int l2, Matrix1D< int > &vL1, Matrix1D< int > &vN, Matrix1D< int > &vL2, Matrix1D< int > &vM)
Zernike and SPH coefficients allocation.
Special label to be used when gathering MDs in MpiMetadataPrograms.
#define FINISHINGZ(v)
void numCoefficients(int l1, int l2, int &vecSize)
Length of coefficients vector.
#define STARTINGX(v)
#define i
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
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
#define STARTINGY(v)
#define A3D_ELEM(V, k, i, j)
#define REALGAUSSIANZ
double R1
Definition: mask.h:413
#define XSIZE(v)
#define RAISED_COSINE
Missing expected label.
Definition: xmipp_error.h:158
int type
Definition: mask.h:402
virtual std::unique_ptr< MDRow > getRow(size_t id)=0
bool exists() const
#define j
#define FINISHINGY(v)
void generate_mask(bool apply_geo=false)
Definition: mask.cpp:1577
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
Definition: matrix1d.h:1227
#define BINARY_CIRCULAR_MASK
Definition: mask.h:365
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
float r2
std::vector< std::unique_ptr< std::atomic< double * > > > p_busy_elem
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
const MultidimArray< int > & get_binary_mask() const
Definition: mask.h:707
#define REALGAUSSIANZ2
#define STARTINGZ(v)
Name of an image (std::string)
#define LOWPASS
void initIdentity()
Definition: matrix2d.h:673
int mode
Definition: mask.h:407
constexpr int INNER_MASK
Definition: mask.h:47

◆ processImage()

void ProgParallelForwardArtZernike3D::processImage ( const FileName fnImg,
const FileName fnImgOut,
const MDRow rowIn,
MDRow rowOut 
)
virtual

Predict angles and shift. At the input the pose parameters must have an initial guess of the parameters. At the output they have the estimated pose.

Implements XmippMetadataProgram.

Definition at line 317 of file parallel_forward_art_zernike3d.cpp.

318 {
319  flagEnabled = 1;
320 
321  int img_enabled;
322  rowIn.getValue(MDL_ENABLED, img_enabled);
323  if (img_enabled == -1) return;
324 
325  rowIn.getValue(MDL_ANGLE_ROT, rot);
326  rowIn.getValue(MDL_ANGLE_TILT, tilt);
327  rowIn.getValue(MDL_ANGLE_PSI, psi);
328  rowIn.getValueOrDefault(MDL_SHIFT_X, shiftX, 0.0);
329  rowIn.getValueOrDefault(MDL_SHIFT_Y, shiftY, 0.0);
330  std::vector<double> vectortemp;
331  if (useZernike)
332  {
333  rowIn.getValue(MDL_SPH_COEFFICIENTS, vectortemp);
334  std::vector<double> vec(vectortemp.begin(), vectortemp.end());
335  clnm = vec;
336  }
337  rowIn.getValueOrDefault(MDL_FLIP, flip, false);
338 
340  {
341  hasCTF = true;
342  FilterCTF.ctf.readFromMdRow(rowIn, false);
343  FilterCTF.ctf.Tm = Ts;
345  }
346  else
347  hasCTF = false;
348  MAT_ELEM(A, 0, 2) = shiftX;
349  MAT_ELEM(A, 1, 2) = shiftY;
350  MAT_ELEM(A, 0, 0) = 1;
351  MAT_ELEM(A, 0, 1) = 0;
352  MAT_ELEM(A, 1, 0) = 0;
353  MAT_ELEM(A, 1, 1) = 1;
354 
355  if (verbose >= 2)
356  std::cout << "Processing " << fnImg << std::endl;
357 
358  I.read(fnImg);
359  I().setXmippOrigin();
360 
361  // Forward Model
362  artModel<Direction::Forward>();
363 
364  // ART update
365  artModel<Direction::Backward>();
366 }
Rotation angle of an image (double,degrees)
Defocus U (Angstroms)
CTFDescription ctf
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
Special label to be used when gathering MDs in MpiMetadataPrograms.
Name for the CTF Model (std::string)
Is this image enabled? (int [-1 or 1])
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
T & getValue(MDLabel label)
Flip the image? (bool)
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:1172
int verbose
Verbosity level.
const T & getValueOrDefault(MDLabel label, const T &def) const
virtual bool containsLabel(MDLabel label) const =0
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
Deformation coefficients.
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
Shift for the image in the Y axis (double)

◆ readParams()

void ProgParallelForwardArtZernike3D::readParams ( )
virtual

Read argument from command line.

Reimplemented from XmippMetadataProgram.

Definition at line 49 of file parallel_forward_art_zernike3d.cpp.

50 {
52  fnVolR = getParam("--ref");
53  fnMaskRF = getParam("--maskf");
54  fnMaskRB = getParam("--maskb");
55  fnOutDir = getParam("--odir");
56  RmaxDef = getIntParam("--RDef");
57  phaseFlipped = checkParam("--phaseFlipped");
58  useCTF = checkParam("--useCTF");
59  Ts = getDoubleParam("--sampling");
60  L1 = getIntParam("--l1");
61  L2 = getIntParam("--l2");
62  loop_step = getIntParam("--step");
63  useZernike = checkParam("--useZernike");
64  lambda = getDoubleParam("--regularization");
65  resume = checkParam("--resume");
66  niter = getIntParam("--niter");
67  save_iter = getIntParam("--save_iter");
68  sort_last_N = getIntParam("--sort_last");
69  FileName outPath = getParam("-o");
70  outPath = outPath.afterLastOf("/");
71  fnVolO = fnOutDir + "/" + outPath;
72 
73  std::string aux;
74  aux = getParam("--sigma");
75  // Transform string of values separated by white spaces into substrings stored in a vector
76  std::stringstream ss(aux);
77  std::istream_iterator<std::string> begin(ss);
78  std::istream_iterator<std::string> end;
79  std::vector<std::string> vstrings(begin, end);
80  sigma.resize(vstrings.size());
81  std::transform(vstrings.begin(), vstrings.end(), sigma.begin(), [](const std::string& val)
82  {
83  return std::stod(val);
84  });
85 
86  // Parallelization
87  int threads = getIntParam("--thr");
88  if (0 >= threads)
89  {
90  threads = CPU::findCores();
91  }
92  m_threadPool.resize(threads);
93 }
double getDoubleParam(const char *param, int arg=0)
static unsigned findCores()
Definition: cpu.h:41
void resize(int nThreads)
Definition: ctpl.h:70
FileName afterLastOf(const String &str) const
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ recoverVol()

void ProgParallelForwardArtZernike3D::recoverVol ( )

Definition at line 433 of file parallel_forward_art_zernike3d.cpp.

434 {
435  // Find the part of the volume that must be updated
436  auto &mVout = Vout();
437  const auto &mV = Vrefined();
438  mVout.initZeros(mV);
439  mVout = mV;
440 }

◆ show()

void ProgParallelForwardArtZernike3D::show ( )

Show.

Definition at line 96 of file parallel_forward_art_zernike3d.cpp.

97 {
98  if (!verbose)
99  return;
101  std::cout
102  << "Output directory: " << fnOutDir << std::endl
103  << "Reference volume: " << fnVolR << std::endl
104  << "Forward model mask: " << fnMaskRF << std::endl
105  << "Backward model mask: " << fnMaskRB << std::endl
106  << "Sampling: " << Ts << std::endl
107  << "Max. Radius Deform. " << RmaxDef << std::endl
108  << "Zernike Degree: " << L1 << std::endl
109  << "SH Degree: " << L2 << std::endl
110  << "Step: " << loop_step << std::endl
111  << "Correct CTF: " << useCTF << std::endl
112  << "Correct heretogeneity: " << useZernike << std::endl
113  << "Phase flipped: " << phaseFlipped << std::endl
114  << "Regularization: " << lambda << std::endl
115  << "Number of iterations: " << niter << std::endl
116  << "Save every # iterations: " << save_iter << std::endl;
117 }
int verbose
Verbosity level.
void show() const override

Member Data Documentation

◆ A

Matrix2D<double> ProgParallelForwardArtZernike3D::A

Definition at line 104 of file parallel_forward_art_zernike3d.h.

◆ clnm

std::vector<double> ProgParallelForwardArtZernike3D::clnm

Definition at line 122 of file parallel_forward_art_zernike3d.h.

◆ ctf

CTFDescription ProgParallelForwardArtZernike3D::ctf

Definition at line 116 of file parallel_forward_art_zernike3d.h.

◆ current_image

size_t ProgParallelForwardArtZernike3D::current_image

Definition at line 130 of file parallel_forward_art_zernike3d.h.

◆ current_iter

int ProgParallelForwardArtZernike3D::current_iter

Definition at line 132 of file parallel_forward_art_zernike3d.h.

◆ current_save_iter

int ProgParallelForwardArtZernike3D::current_save_iter

Definition at line 128 of file parallel_forward_art_zernike3d.h.

◆ defocusAngle

double ProgParallelForwardArtZernike3D::defocusAngle

Definition at line 114 of file parallel_forward_art_zernike3d.h.

◆ defocusU

double ProgParallelForwardArtZernike3D::defocusU

Definition at line 114 of file parallel_forward_art_zernike3d.h.

◆ defocusV

double ProgParallelForwardArtZernike3D::defocusV

Definition at line 114 of file parallel_forward_art_zernike3d.h.

◆ endX

int ProgParallelForwardArtZernike3D::endX

Definition at line 134 of file parallel_forward_art_zernike3d.h.

◆ endY

int ProgParallelForwardArtZernike3D::endY

Definition at line 134 of file parallel_forward_art_zernike3d.h.

◆ endZ

int ProgParallelForwardArtZernike3D::endZ

Definition at line 134 of file parallel_forward_art_zernike3d.h.

◆ filter

FourierFilter ProgParallelForwardArtZernike3D::filter

Definition at line 141 of file parallel_forward_art_zernike3d.h.

◆ filter2

FourierFilter ProgParallelForwardArtZernike3D::filter2

Definition at line 141 of file parallel_forward_art_zernike3d.h.

◆ FilterCTF

FourierFilter ProgParallelForwardArtZernike3D::FilterCTF

Definition at line 118 of file parallel_forward_art_zernike3d.h.

◆ flagEnabled

int ProgParallelForwardArtZernike3D::flagEnabled

Definition at line 74 of file parallel_forward_art_zernike3d.h.

◆ flip

bool ProgParallelForwardArtZernike3D::flip

Definition at line 110 of file parallel_forward_art_zernike3d.h.

◆ fnMaskRB

FileName ProgParallelForwardArtZernike3D::fnMaskRB

Definition at line 48 of file parallel_forward_art_zernike3d.h.

◆ fnMaskRF

FileName ProgParallelForwardArtZernike3D::fnMaskRF

Filename of the reference volume mask

Definition at line 48 of file parallel_forward_art_zernike3d.h.

◆ fnOutDir

FileName ProgParallelForwardArtZernike3D::fnOutDir

Output directory.

Definition at line 52 of file parallel_forward_art_zernike3d.h.

◆ fnVolO

FileName ProgParallelForwardArtZernike3D::fnVolO

Filename of the refined volume

Definition at line 50 of file parallel_forward_art_zernike3d.h.

◆ fnVolR

FileName ProgParallelForwardArtZernike3D::fnVolR

Filename of the reference volume

Definition at line 46 of file parallel_forward_art_zernike3d.h.

◆ hasCTF

bool ProgParallelForwardArtZernike3D::hasCTF

Definition at line 112 of file parallel_forward_art_zernike3d.h.

◆ I

Image<double> ProgParallelForwardArtZernike3D::I

Definition at line 90 of file parallel_forward_art_zernike3d.h.

◆ Idiff

Image<double> ProgParallelForwardArtZernike3D::Idiff

Definition at line 102 of file parallel_forward_art_zernike3d.h.

◆ Ifilteredp

Image<double> ProgParallelForwardArtZernike3D::Ifilteredp

Definition at line 88 of file parallel_forward_art_zernike3d.h.

◆ ignoreCTF

bool ProgParallelForwardArtZernike3D::ignoreCTF

Definition at line 64 of file parallel_forward_art_zernike3d.h.

◆ initX

int ProgParallelForwardArtZernike3D::initX

Definition at line 134 of file parallel_forward_art_zernike3d.h.

◆ initY

int ProgParallelForwardArtZernike3D::initY

Definition at line 134 of file parallel_forward_art_zernike3d.h.

◆ initZ

int ProgParallelForwardArtZernike3D::initZ

Definition at line 134 of file parallel_forward_art_zernike3d.h.

◆ L1

int ProgParallelForwardArtZernike3D::L1

Degrees of Zernike polynomials and spherical harmonics

Definition at line 54 of file parallel_forward_art_zernike3d.h.

◆ L2

int ProgParallelForwardArtZernike3D::L2

Definition at line 54 of file parallel_forward_art_zernike3d.h.

◆ lambda

double ProgParallelForwardArtZernike3D::lambda

Definition at line 66 of file parallel_forward_art_zernike3d.h.

◆ loop_step

int ProgParallelForwardArtZernike3D::loop_step

Definition at line 136 of file parallel_forward_art_zernike3d.h.

◆ m_threadPool

ctpl::thread_pool ProgParallelForwardArtZernike3D::m_threadPool

Definition at line 144 of file parallel_forward_art_zernike3d.h.

◆ mask2D

MultidimArray<int> ProgParallelForwardArtZernike3D::mask2D

Definition at line 84 of file parallel_forward_art_zernike3d.h.

◆ niter

int ProgParallelForwardArtZernike3D::niter

Definition at line 80 of file parallel_forward_art_zernike3d.h.

◆ num_images

size_t ProgParallelForwardArtZernike3D::num_images

Definition at line 130 of file parallel_forward_art_zernike3d.h.

◆ ordered_list

MultidimArray<size_t> ProgParallelForwardArtZernike3D::ordered_list

Definition at line 126 of file parallel_forward_art_zernike3d.h.

◆ P

std::vector<Image<double> > ProgParallelForwardArtZernike3D::P

Definition at line 94 of file parallel_forward_art_zernike3d.h.

◆ p_busy_elem

std::vector<std::unique_ptr<std::atomic<double*> > > ProgParallelForwardArtZernike3D::p_busy_elem

Definition at line 98 of file parallel_forward_art_zernike3d.h.

◆ phaseFlipped

bool ProgParallelForwardArtZernike3D::phaseFlipped

Definition at line 62 of file parallel_forward_art_zernike3d.h.

◆ psi

double ProgParallelForwardArtZernike3D::psi

Definition at line 106 of file parallel_forward_art_zernike3d.h.

◆ resume

bool ProgParallelForwardArtZernike3D::resume

Resume computations

Definition at line 78 of file parallel_forward_art_zernike3d.h.

◆ RmaxDef

int ProgParallelForwardArtZernike3D::RmaxDef

Maximum radius

Definition at line 60 of file parallel_forward_art_zernike3d.h.

◆ rot

double ProgParallelForwardArtZernike3D::rot

Definition at line 106 of file parallel_forward_art_zernike3d.h.

◆ save_iter

int ProgParallelForwardArtZernike3D::save_iter

Definition at line 68 of file parallel_forward_art_zernike3d.h.

◆ shiftX

double ProgParallelForwardArtZernike3D::shiftX

Definition at line 108 of file parallel_forward_art_zernike3d.h.

◆ shiftY

double ProgParallelForwardArtZernike3D::shiftY

Definition at line 108 of file parallel_forward_art_zernike3d.h.

◆ showOptimization

bool ProgParallelForwardArtZernike3D::showOptimization

Definition at line 124 of file parallel_forward_art_zernike3d.h.

◆ sigma

std::vector<double> ProgParallelForwardArtZernike3D::sigma

Definition at line 138 of file parallel_forward_art_zernike3d.h.

◆ sort_last_N

int ProgParallelForwardArtZernike3D::sort_last_N

Definition at line 82 of file parallel_forward_art_zernike3d.h.

◆ threads

int ProgParallelForwardArtZernike3D::threads

Definition at line 145 of file parallel_forward_art_zernike3d.h.

◆ tilt

double ProgParallelForwardArtZernike3D::tilt

Definition at line 106 of file parallel_forward_art_zernike3d.h.

◆ Ts

double ProgParallelForwardArtZernike3D::Ts

Sampling rate

Definition at line 58 of file parallel_forward_art_zernike3d.h.

◆ useCTF

bool ProgParallelForwardArtZernike3D::useCTF

Definition at line 70 of file parallel_forward_art_zernike3d.h.

◆ useZernike

bool ProgParallelForwardArtZernike3D::useZernike

Definition at line 72 of file parallel_forward_art_zernike3d.h.

◆ V

Image<double> ProgParallelForwardArtZernike3D::V

Definition at line 88 of file parallel_forward_art_zernike3d.h.

◆ vecSize

int ProgParallelForwardArtZernike3D::vecSize

Definition at line 120 of file parallel_forward_art_zernike3d.h.

◆ vL1

Matrix1D<int> ProgParallelForwardArtZernike3D::vL1

Zernike and SPH coefficients vectors

Definition at line 56 of file parallel_forward_art_zernike3d.h.

◆ vL2

Matrix1D<int> ProgParallelForwardArtZernike3D::vL2

Definition at line 56 of file parallel_forward_art_zernike3d.h.

◆ vM

Matrix1D<int> ProgParallelForwardArtZernike3D::vM

Definition at line 56 of file parallel_forward_art_zernike3d.h.

◆ vN

Matrix1D<int> ProgParallelForwardArtZernike3D::vN

Definition at line 56 of file parallel_forward_art_zernike3d.h.

◆ Vout

Image<double> ProgParallelForwardArtZernike3D::Vout

Definition at line 88 of file parallel_forward_art_zernike3d.h.

◆ VRecMaskB

MultidimArray<int> ProgParallelForwardArtZernike3D::VRecMaskB

Definition at line 92 of file parallel_forward_art_zernike3d.h.

◆ VRecMaskF

MultidimArray<int> ProgParallelForwardArtZernike3D::VRecMaskF

Definition at line 92 of file parallel_forward_art_zernike3d.h.

◆ Vrefined

Image<double> ProgParallelForwardArtZernike3D::Vrefined

Definition at line 88 of file parallel_forward_art_zernike3d.h.

◆ W

std::vector<Image<double> > ProgParallelForwardArtZernike3D::W

Definition at line 96 of file parallel_forward_art_zernike3d.h.

◆ w_busy_elem

std::vector<std::unique_ptr<std::atomic<double*> > > ProgParallelForwardArtZernike3D::w_busy_elem

Definition at line 99 of file parallel_forward_art_zernike3d.h.

◆ Xdim

size_t ProgParallelForwardArtZernike3D::Xdim

Definition at line 86 of file parallel_forward_art_zernike3d.h.


The documentation for this class was generated from the following files: