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

#include <forward_art_zernike3d_subtomos.h>

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

Public Types

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

Public Member Functions

 ProgForwardArtZernike3DSubtomos ()
 Empty constructor. More...
 
 ~ProgForwardArtZernike3DSubtomos ()
 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 ()
 
void applyMissingWedge (MultidimArray< double > &mV)
 
- 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 fnMaskR
 
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
 
double t1
 
double t2
 
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 > Vmask
 
Image< double > P
 
Image< double > W
 
Image< double > Idiff
 
Matrix2D< double > A
 
double rot
 
double tilt
 
double psi
 
double shiftX
 
double shiftY
 
double shiftZ
 
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
 
int num_images
 
int current_iter
 
int initX
 
int endX
 
int initY
 
int endY
 
int initZ
 
int endZ
 
int loop_step
 
struct blobtype blob
 
double blob_r
 
double sigma
 
double sigma4
 
MultidimArray< double > gaussian3d
 
MultidimArray< double > gaussian_mw
 
FourierTransformer transformer
 
- 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 40 of file forward_art_zernike3d_subtomos.h.

Member Enumeration Documentation

◆ Mode

Enumerator
Proj 
Vol 

Definition at line 143 of file forward_art_zernike3d_subtomos.h.

143 { Proj, Vol };

Constructor & Destructor Documentation

◆ ProgForwardArtZernike3DSubtomos()

ProgForwardArtZernike3DSubtomos::ProgForwardArtZernike3DSubtomos ( )

Empty constructor.

Definition at line 35 of file forward_art_zernike3d_subtomos.cpp.

36 {
37  resume = false;
38  produces_a_metadata = true;
40  showOptimization = false;
41 }
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.

◆ ~ProgForwardArtZernike3DSubtomos()

ProgForwardArtZernike3DSubtomos::~ProgForwardArtZernike3DSubtomos ( )
default

Destructor.

Member Function Documentation

◆ applyMissingWedge()

void ProgForwardArtZernike3DSubtomos::applyMissingWedge ( MultidimArray< double > &  mV)

Definition at line 913 of file forward_art_zernike3d_subtomos.cpp.

914 {
915  // gaussian_mw = gaussian3d;
916  // gaussian_mw.setXmippOrigin();
918  MultidimArray<int> maskWedge;
920  R.initIdentity(3);
921  // Euler_angles2matrix(static_cast<double>(rot), static_cast<double>(tilt), static_cast<double>(psi), R, false);
922  transformer.FourierTransform(mV, fg, false);
923  transformer.getFourierAlias(Fourier);
924  maskWedge.initZeros(Fourier);
925  maskWedge.setXmippOrigin();
926  BinaryWedgeMask(maskWedge, t1, t2, R, true);
928  DIRECT_MULTIDIM_ELEM(fg,n) *= DIRECT_MULTIDIM_ELEM(maskWedge,n);
930 }
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
void BinaryWedgeMask(MultidimArray< int > &mask, double theta0, double thetaF, const Matrix2D< double > &A, bool centerOrigin)
Definition: mask.cpp:524
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define DIRECT_MULTIDIM_ELEM(v, n)
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166
void getFourierAlias(T &V)
Definition: xmipp_fftw.h:207
void initZeros(const MultidimArray< T1 > &op)
int * n
void initIdentity()
Definition: matrix2d.h:673

◆ defineParams()

void ProgForwardArtZernike3DSubtomos::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippMetadataProgram.

Definition at line 98 of file forward_art_zernike3d_subtomos.cpp.

99 {
100  addUsageLine("Template-based canonical volume reconstruction through Zernike3D coefficients");
101  defaultComments["-i"].clear();
102  defaultComments["-i"].addComment("Metadata with initial alignment");
103  defaultComments["-o"].clear();
104  defaultComments["-o"].addComment("Refined volume");
106  addParamsLine(" [--ref <volume=\"\">] : Reference volume");
107  addParamsLine(" [--mask <m=\"\">] : Mask reference volume");
108  addParamsLine(" [--odir <outputDir=\".\">] : Output directory");
109  addParamsLine(" [--sampling <Ts=1>] : Sampling rate (A/pixel)");
110  addParamsLine(" [--RDef <r=-1>] : Maximum radius of the deformation (px). -1=Half of volume size");
111  addParamsLine(" [--l1 <l1=3>] : Degree Zernike Polynomials=1,2,3,...");
112  addParamsLine(" [--l2 <l2=2>] : Harmonical depth of the deformation=1,2,3,...");
113  addParamsLine(" [--blobr <b=4>] : Blob radius for forward mapping splatting");
114  addParamsLine(" [--step <step=1>] : Voxel index step");
115  addParamsLine(" [--sigma <step=0.25>] : Gaussian sigma");
116  addParamsLine(" [--useZernike] : Correct heterogeneity with Zernike3D coefficients");
117  addParamsLine(" [--useCTF] : Correct CTF during ART reconstruction");
118  addParamsLine(" [--phaseFlipped] : Input images have been phase flipped");
119  addParamsLine(" [--regularization <l=0.01>] : ART regularization weight");
120  addParamsLine(" [--niter <n=1>] : Number of ART iterations");
121  addParamsLine(" [--save_iter <s=0>] : Save intermidiate volume after #save_iter iterations");
122  addParamsLine(" [--sort_last <N=2>] : The algorithm sorts projections in the most orthogonally possible way. ");
123  addParamsLine(" : The most orthogonal way is defined as choosing the projection which maximizes the ");
124  addParamsLine(" : dot product with the N previous inserted projections. Use -1 to sort with all ");
125  addParamsLine(" : previous projections");
126  addParamsLine(" [--t1 <t1=-60>] : First tilt angle range");
127  addParamsLine(" [--t2 <t2=60>] : Second tilt angle range");
128  addParamsLine(" [--resume] : Resume processing");
129  addExampleLine("A typical use is:", false);
130  addExampleLine("xmipp_art_zernike3d -i anglesFromContinuousAssignment.xmd --ref reference.vol -o assigned_anglesAndDeformations.xmd --l1 3 --l2 2");
131 }
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 ProgForwardArtZernike3DSubtomos::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 ProgForwardArtZernike3DSubtomos::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 371 of file forward_art_zernike3d_subtomos.cpp.

373 {
374  int idx = 0;
375  vL1.initZeros(vecSize);
376  vN.initZeros(vecSize);
377  vL2.initZeros(vecSize);
378  vM.initZeros(vecSize);
379  for (int h = 0; h <= l2; h++)
380  {
381  int totalSPH = 2 * h + 1;
382  int aux = std::floor(totalSPH / 2);
383  for (int l = h; l <= l1; l += 2)
384  {
385  for (int m = 0; m < totalSPH; m++)
386  {
387  VEC_ELEM(vL1, idx) = l;
388  VEC_ELEM(vN, idx) = h;
389  VEC_ELEM(vL2, idx) = h;
390  VEC_ELEM(vM, idx) = m - aux;
391  idx++;
392  }
393  }
394  }
395 }
#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 ProgForwardArtZernike3DSubtomos::finishProcessing ( )
virtual

Reimplemented from XmippMetadataProgram.

Definition at line 275 of file forward_art_zernike3d_subtomos.cpp.

276 {
277  // XmippMetadataProgram::finishProcessing();
278  recoverVol();
279  Vout.write(fnVolO);
280 }
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 ProgForwardArtZernike3DSubtomos::numCoefficients ( int  l1,
int  l2,
int &  vecSize 
)

Length of coefficients vector.

Definition at line 353 of file forward_art_zernike3d_subtomos.cpp.

354 {
355  for (int h = 0; h <= l2; h++)
356  {
357  int numSPH = 2 * h + 1;
358  int count = l1 - h + 1;
359  int numEven = (count >> 1) + (count & 1 && !(h & 1));
360  if (h % 2 == 0)
361  {
362  vecSize += numSPH * numEven;
363  }
364  else
365  {
366  vecSize += numSPH * (l1 - h + 1 - numEven);
367  }
368  }
369 }

◆ preProcess()

void ProgForwardArtZernike3DSubtomos::preProcess ( )
virtual

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

Reimplemented from XmippMetadataProgram.

Definition at line 148 of file forward_art_zernike3d_subtomos.cpp.

149 {
150 
151  // Check that metadata has all information neede
152  if (!getInputMd()->containsLabel(MDL_ANGLE_ROT) ||
153  !getInputMd()->containsLabel(MDL_ANGLE_TILT) ||
154  !getInputMd()->containsLabel(MDL_ANGLE_PSI))
155  {
156  REPORT_ERROR(ERR_MD_MISSINGLABEL, "Input metadata projection angles are missing. Exiting...");
157  }
158 
159  if (fnVolR != "")
160  {
161  V.read(fnVolR);
162  }
163  else
164  {
165  FileName fn_first_image;
166  Image<double> first_image;
167  getInputMd()->getRow(1)->getValue(MDL_IMAGE, fn_first_image);
168  first_image.read(fn_first_image);
169  size_t Xdim_first = XSIZE(first_image());
170  V().initZeros(Xdim_first, Xdim_first, Xdim_first);
171  }
172  V().setXmippOrigin();
173 
174  Xdim = XSIZE(V());
175 
176  Vout().initZeros(V());
177  Vout().setXmippOrigin();
178 
179  if (resume && fnVolO.exists())
180  {
182  }
183  else
184  {
185  Vrefined() = V();
186  }
187  // Vrefined().initZeros(V());
188  Vrefined().setXmippOrigin();
189 
190  if (RmaxDef < 0)
191  RmaxDef = Xdim / 2;
192 
193  // Transformation matrix
194  A.initIdentity(4);
195 
196  // CTF Filter
199  FilterCTF.ctf.enable_CTFnoise = false;
200  FilterCTF.ctf.enable_CTF = true;
201  // FilterCTF.ctf.produceSideInfo();
202 
203  // Area where Zernike3D basis is computed (and volume is updated)
204  // Read Reference mask if avalaible (otherwise sphere of radius RmaxDef is used)
205  Mask mask;
206  mask.type = BINARY_CIRCULAR_MASK;
207  mask.mode = INNER_MASK;
208  if (fnMaskR != "")
209  {
210  Image<double> aux;
211  aux.read(fnMaskR);
212  typeCast(aux(), Vmask);
214  double Rmax2 = RmaxDef * RmaxDef;
215  for (int k = STARTINGZ(Vmask); k <= FINISHINGZ(Vmask); k++)
216  {
217  for (int i = STARTINGY(Vmask); i <= FINISHINGY(Vmask); i++)
218  {
219  for (int j = STARTINGX(Vmask); j <= FINISHINGX(Vmask); j++)
220  {
221  double r2 = k * k + i * i + j * j;
222  if (r2 >= Rmax2)
223  A3D_ELEM(Vmask, k, i, j) = 0;
224  }
225  }
226  }
227  }
228  else
229  {
230  mask.R1 = RmaxDef;
231  mask.generate_mask(V());
232  Vmask = mask.get_binary_mask();
234  }
235 
236  // Area Zernike3D in 2D
237  mask.R1 = RmaxDef;
238  mask.generate_mask(XSIZE(V()), XSIZE(V()));
239  mask2D = mask.get_binary_mask();
241 
242  vecSize = 0;
244  fillVectorTerms(L1, L2, vL1, vN, vL2, vM);
245 
246  // createWorkFiles();
247  initX = STARTINGX(Vrefined());
248  endX = FINISHINGX(Vrefined());
249  initY = STARTINGY(Vrefined());
250  endY = FINISHINGY(Vrefined());
251  initZ = STARTINGZ(Vrefined());
252  endZ = FINISHINGZ(Vrefined());
253 
254  sigma4 = 4 * sigma; // Test 3
255  double size_vg = CEIL(sigma4 * sqrt(2) * 50);
256  gaussian3d.initZeros(size_vg, size_vg, size_vg);
259  A3D_ELEM(gaussian3d, k, i, j) = gaussian1D(sqrt(k*k + i*i + j*j) / 50.0, sigma);
260  gaussian3d *= gaussian1D(0, sigma);
261 
262  // This could also be a valid option, but we need a large volume to enclose the gaussian +
263  // its missing wedge properly. Since the convolution is a linear operator, it is better to apply
264  // it once the volume has been formed by standard gaussians
265  // Needed gaussian dimensions CEIL(sigma4 * 2.5 * 50)
266  // applyMissingWedge(gaussian3d);
267 
269  W() = gaussian3d;
270  FileName fnMask=fnOutDir+"gaussian_mw.mrc";
271  W.write(fnMask);
272 
273 }
Rotation 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.
CTFDescription ctf
#define FINISHINGX(v)
#define CTFINV
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Definition: mask.h:360
void sqrt(Image< double > &op)
void numCoefficients(int l1, int l2, int &vecSize)
Length of coefficients vector.
Tilting angle of an image (double,degrees)
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)
Special label to be used when gathering MDs in MpiMetadataPrograms.
#define FINISHINGZ(v)
#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 FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
#define CEIL(x)
Definition: xmipp_macros.h:225
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
void initZeros(const MultidimArray< T1 > &op)
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
const MultidimArray< int > & get_binary_mask() const
Definition: mask.h:707
#define STARTINGZ(v)
Name of an image (std::string)
void initIdentity()
Definition: matrix2d.h:673
int mode
Definition: mask.h:407
constexpr int INNER_MASK
Definition: mask.h:47
double gaussian1D(double x, double sigma, double mu)

◆ processImage()

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

Create the processing working files. The working files are: nmaTodo.xmd for images to process (nmaTodo = mdIn - nmaDone) nmaDone.xmd image already processed (could exists from a previous run)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 284 of file forward_art_zernike3d_subtomos.cpp.

285 {
286  flagEnabled = 1;
287 
288  int img_enabled;
289  rowIn.getValue(MDL_ENABLED, img_enabled);
290  if (img_enabled == -1) return;
291 
292  // double auxRot, auxTilt, auxPsi, auxShiftX, auxShiftY;
293  rowIn.getValue(MDL_ANGLE_ROT, rot);
294  rowIn.getValue(MDL_ANGLE_TILT, tilt);
295  rowIn.getValue(MDL_ANGLE_PSI, psi);
296  rowIn.getValueOrDefault(MDL_SHIFT_X, shiftX, 0.0);
297  rowIn.getValueOrDefault(MDL_SHIFT_Y, shiftY, 0.0);
298  rowIn.getValueOrDefault(MDL_SHIFT_Z, shiftZ, 0.0);
299  std::vector<double> vectortemp;
300  if (useZernike)
301  {
302  rowIn.getValue(MDL_SPH_COEFFICIENTS, vectortemp);
303  std::vector<double> vec(vectortemp.begin(), vectortemp.end());
304  clnm = vec;
305  }
306  rowIn.getValueOrDefault(MDL_FLIP, flip, false);
307 
309  {
310  // std::cout << "Applying CTF" << std::endl;
311  hasCTF = true;
312  FilterCTF.ctf.readFromMdRow(rowIn, false);
313  FilterCTF.ctf.Tm = Ts;
315  }
316  else
317  hasCTF = false;
318  MAT_ELEM(A, 0, 3) = shiftX;
319  MAT_ELEM(A, 1, 3) = shiftY;
320  MAT_ELEM(A, 2, 3) = shiftZ;
321  MAT_ELEM(A, 0, 0) = 1;
322  MAT_ELEM(A, 0, 1) = 0;
323  MAT_ELEM(A, 0, 2) = 0;
324  MAT_ELEM(A, 1, 0) = 0;
325  MAT_ELEM(A, 1, 1) = 1;
326  MAT_ELEM(A, 1, 2) = 0;
327  MAT_ELEM(A, 2, 0) = 0;
328  MAT_ELEM(A, 2, 1) = 0;
329  MAT_ELEM(A, 2, 2) = 1;
330 
331 
332  if (verbose >= 2)
333  std::cout << "Processing " << fnImg << std::endl;
334 
335  I.read(fnImg);
336  I().setXmippOrigin();
337 
338  // Forward Model
339  artModel<Direction::Forward>();
340  // forwardModel();
341 
342  // ART update
343  artModel<Direction::Backward>();
344  // updateART();
345 }
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.
Shift for the image in the Z axis (double)
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 ProgForwardArtZernike3DSubtomos::readParams ( )
virtual

Read argument from command line.

Reimplemented from XmippMetadataProgram.

Definition at line 46 of file forward_art_zernike3d_subtomos.cpp.

47 {
49  fnVolR = getParam("--ref");
50  fnMaskR = getParam("--mask");
51  fnOutDir = getParam("--odir");
52  RmaxDef = getIntParam("--RDef");
53  phaseFlipped = checkParam("--phaseFlipped");
54  useCTF = checkParam("--useCTF");
55  Ts = getDoubleParam("--sampling");
56  L1 = getIntParam("--l1");
57  L2 = getIntParam("--l2");
58  t1 = getDoubleParam("--t1");
59  t2 = getDoubleParam("--t2");
60  blob_r = getDoubleParam("--blobr");
61  loop_step = getIntParam("--step");
62  sigma = getDoubleParam("--sigma");
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  // fnDone = fnOutDir + "/sphDone.xmd";
70  fnVolO = fnOutDir + "/Refined.vol";
71 }
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ recoverVol()

void ProgForwardArtZernike3DSubtomos::recoverVol ( )

Definition at line 473 of file forward_art_zernike3d_subtomos.cpp.

474 {
475  // Find the part of the volume that must be updated
476  auto &mVout = Vout();
477  const auto &mV = Vrefined();
478  mVout.initZeros(mV);
479 
480  const auto lastZ = FINISHINGZ(mV);
481  const auto lastY = FINISHINGY(mV);
482  const auto lastX = FINISHINGX(mV);
483  // const int step = DIRECTION == Direction::Forward ? loop_step : 1;
484  const int step = loop_step;
485  auto pos = std::array<double, 3>{};
486 
487  for (int k = STARTINGZ(mV); k <= lastZ; k++)
488  {
489  for (int i = STARTINGY(mV); i <= lastY; i++)
490  {
491  for (int j = STARTINGX(mV); j <= lastX; j++)
492  {
493  if (A3D_ELEM(Vmask, k, i, j) == 1)
494  {
495  pos[0] = j;
496  pos[1] = i;
497  pos[2] = k;
498  updateVoxel(pos, A3D_ELEM(mV, k, i, j), mVout);
499  }
500  }
501  }
502  }
503 }
#define FINISHINGX(v)
#define FINISHINGZ(v)
#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
#define STARTINGY(v)
#define A3D_ELEM(V, k, i, j)
#define j
#define FINISHINGY(v)
#define STARTINGZ(v)

◆ show()

void ProgForwardArtZernike3DSubtomos::show ( )

Show.

Definition at line 74 of file forward_art_zernike3d_subtomos.cpp.

75 {
76  if (!verbose)
77  return;
79  std::cout
80  << "Output directory: " << fnOutDir << std::endl
81  << "Reference volume: " << fnVolR << std::endl
82  << "Reference mask: " << fnMaskR << std::endl
83  << "Sampling: " << Ts << std::endl
84  << "Max. Radius Deform. " << RmaxDef << std::endl
85  << "Zernike Degree: " << L1 << std::endl
86  << "SH Degree: " << L2 << std::endl
87  << "Blob radius: " << blob_r << std::endl
88  << "Step: " << loop_step << std::endl
89  << "Correct CTF: " << useCTF << std::endl
90  << "Correct heretogeneity: " << useZernike << std::endl
91  << "Phase flipped: " << phaseFlipped << std::endl
92  << "Regularization: " << lambda << std::endl
93  << "Number of iterations: " << niter << std::endl
94  << "Save every # iterations: " << save_iter << std::endl;
95 }
int verbose
Verbosity level.
void show() const override

Member Data Documentation

◆ A

Matrix2D<double> ProgForwardArtZernike3DSubtomos::A

Definition at line 102 of file forward_art_zernike3d_subtomos.h.

◆ blob

struct blobtype ProgForwardArtZernike3DSubtomos::blob

Definition at line 135 of file forward_art_zernike3d_subtomos.h.

◆ blob_r

double ProgForwardArtZernike3DSubtomos::blob_r

Definition at line 136 of file forward_art_zernike3d_subtomos.h.

◆ clnm

std::vector<double> ProgForwardArtZernike3DSubtomos::clnm

Definition at line 120 of file forward_art_zernike3d_subtomos.h.

◆ ctf

CTFDescription ProgForwardArtZernike3DSubtomos::ctf

Definition at line 114 of file forward_art_zernike3d_subtomos.h.

◆ current_iter

int ProgForwardArtZernike3DSubtomos::current_iter

Definition at line 130 of file forward_art_zernike3d_subtomos.h.

◆ current_save_iter

int ProgForwardArtZernike3DSubtomos::current_save_iter

Definition at line 126 of file forward_art_zernike3d_subtomos.h.

◆ defocusAngle

double ProgForwardArtZernike3DSubtomos::defocusAngle

Definition at line 112 of file forward_art_zernike3d_subtomos.h.

◆ defocusU

double ProgForwardArtZernike3DSubtomos::defocusU

Definition at line 112 of file forward_art_zernike3d_subtomos.h.

◆ defocusV

double ProgForwardArtZernike3DSubtomos::defocusV

Definition at line 112 of file forward_art_zernike3d_subtomos.h.

◆ endX

int ProgForwardArtZernike3DSubtomos::endX

Definition at line 132 of file forward_art_zernike3d_subtomos.h.

◆ endY

int ProgForwardArtZernike3DSubtomos::endY

Definition at line 132 of file forward_art_zernike3d_subtomos.h.

◆ endZ

int ProgForwardArtZernike3DSubtomos::endZ

Definition at line 132 of file forward_art_zernike3d_subtomos.h.

◆ FilterCTF

FourierFilter ProgForwardArtZernike3DSubtomos::FilterCTF

Definition at line 116 of file forward_art_zernike3d_subtomos.h.

◆ flagEnabled

int ProgForwardArtZernike3DSubtomos::flagEnabled

Definition at line 74 of file forward_art_zernike3d_subtomos.h.

◆ flip

bool ProgForwardArtZernike3DSubtomos::flip

Definition at line 108 of file forward_art_zernike3d_subtomos.h.

◆ fnMaskR

FileName ProgForwardArtZernike3DSubtomos::fnMaskR

Filename of the reference volume mask

Definition at line 46 of file forward_art_zernike3d_subtomos.h.

◆ fnOutDir

FileName ProgForwardArtZernike3DSubtomos::fnOutDir

Output directory.

Definition at line 50 of file forward_art_zernike3d_subtomos.h.

◆ fnVolO

FileName ProgForwardArtZernike3DSubtomos::fnVolO

Filename of the refined volume

Definition at line 48 of file forward_art_zernike3d_subtomos.h.

◆ fnVolR

FileName ProgForwardArtZernike3DSubtomos::fnVolR

Filename of the reference volume

Definition at line 44 of file forward_art_zernike3d_subtomos.h.

◆ gaussian3d

MultidimArray<double> ProgForwardArtZernike3DSubtomos::gaussian3d

Definition at line 139 of file forward_art_zernike3d_subtomos.h.

◆ gaussian_mw

MultidimArray<double> ProgForwardArtZernike3DSubtomos::gaussian_mw

Definition at line 139 of file forward_art_zernike3d_subtomos.h.

◆ hasCTF

bool ProgForwardArtZernike3DSubtomos::hasCTF

Definition at line 110 of file forward_art_zernike3d_subtomos.h.

◆ I

Image<double> ProgForwardArtZernike3DSubtomos::I

Definition at line 92 of file forward_art_zernike3d_subtomos.h.

◆ Idiff

Image<double> ProgForwardArtZernike3DSubtomos::Idiff

Definition at line 100 of file forward_art_zernike3d_subtomos.h.

◆ Ifilteredp

Image<double> ProgForwardArtZernike3DSubtomos::Ifilteredp

Definition at line 90 of file forward_art_zernike3d_subtomos.h.

◆ ignoreCTF

bool ProgForwardArtZernike3DSubtomos::ignoreCTF

Definition at line 64 of file forward_art_zernike3d_subtomos.h.

◆ initX

int ProgForwardArtZernike3DSubtomos::initX

Definition at line 132 of file forward_art_zernike3d_subtomos.h.

◆ initY

int ProgForwardArtZernike3DSubtomos::initY

Definition at line 132 of file forward_art_zernike3d_subtomos.h.

◆ initZ

int ProgForwardArtZernike3DSubtomos::initZ

Definition at line 132 of file forward_art_zernike3d_subtomos.h.

◆ L1

int ProgForwardArtZernike3DSubtomos::L1

Degrees of Zernike polynomials and spherical harmonics

Definition at line 54 of file forward_art_zernike3d_subtomos.h.

◆ L2

int ProgForwardArtZernike3DSubtomos::L2

Definition at line 54 of file forward_art_zernike3d_subtomos.h.

◆ lambda

double ProgForwardArtZernike3DSubtomos::lambda

Definition at line 66 of file forward_art_zernike3d_subtomos.h.

◆ loop_step

int ProgForwardArtZernike3DSubtomos::loop_step

Definition at line 134 of file forward_art_zernike3d_subtomos.h.

◆ mask2D

MultidimArray<int> ProgForwardArtZernike3DSubtomos::mask2D

Definition at line 86 of file forward_art_zernike3d_subtomos.h.

◆ niter

int ProgForwardArtZernike3DSubtomos::niter

Definition at line 82 of file forward_art_zernike3d_subtomos.h.

◆ num_images

int ProgForwardArtZernike3DSubtomos::num_images

Definition at line 128 of file forward_art_zernike3d_subtomos.h.

◆ ordered_list

MultidimArray<size_t> ProgForwardArtZernike3DSubtomos::ordered_list

Definition at line 124 of file forward_art_zernike3d_subtomos.h.

◆ P

Image<double> ProgForwardArtZernike3DSubtomos::P

Definition at line 96 of file forward_art_zernike3d_subtomos.h.

◆ phaseFlipped

bool ProgForwardArtZernike3DSubtomos::phaseFlipped

Definition at line 62 of file forward_art_zernike3d_subtomos.h.

◆ psi

double ProgForwardArtZernike3DSubtomos::psi

Definition at line 104 of file forward_art_zernike3d_subtomos.h.

◆ resume

bool ProgForwardArtZernike3DSubtomos::resume

Resume computations

Definition at line 80 of file forward_art_zernike3d_subtomos.h.

◆ RmaxDef

int ProgForwardArtZernike3DSubtomos::RmaxDef

Maximum radius

Definition at line 60 of file forward_art_zernike3d_subtomos.h.

◆ rot

double ProgForwardArtZernike3DSubtomos::rot

Definition at line 104 of file forward_art_zernike3d_subtomos.h.

◆ save_iter

int ProgForwardArtZernike3DSubtomos::save_iter

Definition at line 68 of file forward_art_zernike3d_subtomos.h.

◆ shiftX

double ProgForwardArtZernike3DSubtomos::shiftX

Definition at line 106 of file forward_art_zernike3d_subtomos.h.

◆ shiftY

double ProgForwardArtZernike3DSubtomos::shiftY

Definition at line 106 of file forward_art_zernike3d_subtomos.h.

◆ shiftZ

double ProgForwardArtZernike3DSubtomos::shiftZ

Definition at line 106 of file forward_art_zernike3d_subtomos.h.

◆ showOptimization

bool ProgForwardArtZernike3DSubtomos::showOptimization

Definition at line 122 of file forward_art_zernike3d_subtomos.h.

◆ sigma

double ProgForwardArtZernike3DSubtomos::sigma

Definition at line 137 of file forward_art_zernike3d_subtomos.h.

◆ sigma4

double ProgForwardArtZernike3DSubtomos::sigma4

Definition at line 137 of file forward_art_zernike3d_subtomos.h.

◆ sort_last_N

int ProgForwardArtZernike3DSubtomos::sort_last_N

Definition at line 84 of file forward_art_zernike3d_subtomos.h.

◆ t1

double ProgForwardArtZernike3DSubtomos::t1

Definition at line 76 of file forward_art_zernike3d_subtomos.h.

◆ t2

double ProgForwardArtZernike3DSubtomos::t2

Definition at line 76 of file forward_art_zernike3d_subtomos.h.

◆ tilt

double ProgForwardArtZernike3DSubtomos::tilt

Definition at line 104 of file forward_art_zernike3d_subtomos.h.

◆ transformer

FourierTransformer ProgForwardArtZernike3DSubtomos::transformer

Definition at line 141 of file forward_art_zernike3d_subtomos.h.

◆ Ts

double ProgForwardArtZernike3DSubtomos::Ts

Sampling rate

Definition at line 58 of file forward_art_zernike3d_subtomos.h.

◆ useCTF

bool ProgForwardArtZernike3DSubtomos::useCTF

Definition at line 70 of file forward_art_zernike3d_subtomos.h.

◆ useZernike

bool ProgForwardArtZernike3DSubtomos::useZernike

Definition at line 72 of file forward_art_zernike3d_subtomos.h.

◆ V

Image<double> ProgForwardArtZernike3DSubtomos::V

Definition at line 90 of file forward_art_zernike3d_subtomos.h.

◆ vecSize

int ProgForwardArtZernike3DSubtomos::vecSize

Definition at line 118 of file forward_art_zernike3d_subtomos.h.

◆ vL1

Matrix1D<int> ProgForwardArtZernike3DSubtomos::vL1

Zernike and SPH coefficients vectors

Definition at line 56 of file forward_art_zernike3d_subtomos.h.

◆ vL2

Matrix1D<int> ProgForwardArtZernike3DSubtomos::vL2

Definition at line 56 of file forward_art_zernike3d_subtomos.h.

◆ vM

Matrix1D<int> ProgForwardArtZernike3DSubtomos::vM

Definition at line 56 of file forward_art_zernike3d_subtomos.h.

◆ Vmask

MultidimArray<int> ProgForwardArtZernike3DSubtomos::Vmask

Definition at line 94 of file forward_art_zernike3d_subtomos.h.

◆ vN

Matrix1D<int> ProgForwardArtZernike3DSubtomos::vN

Definition at line 56 of file forward_art_zernike3d_subtomos.h.

◆ Vout

Image<double> ProgForwardArtZernike3DSubtomos::Vout

Definition at line 90 of file forward_art_zernike3d_subtomos.h.

◆ Vrefined

Image<double> ProgForwardArtZernike3DSubtomos::Vrefined

Definition at line 90 of file forward_art_zernike3d_subtomos.h.

◆ W

Image<double> ProgForwardArtZernike3DSubtomos::W

Definition at line 98 of file forward_art_zernike3d_subtomos.h.

◆ Xdim

size_t ProgForwardArtZernike3DSubtomos::Xdim

Definition at line 88 of file forward_art_zernike3d_subtomos.h.


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