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

#include <forward_zernike_images_priors.h>

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

Public Types

enum  Direction { Direction::ROTATE, Direction::UNROTATE }
 

Public Member Functions

 ProgForwardZernikeImagesPriors ()
 Empty constructor. More...
 
 ~ProgForwardZernikeImagesPriors ()
 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 minimizepos (Matrix1D< double > &steps)
 Determine the positions to be minimize of a vector containing spherical harmonic coefficients. 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 > &mVD, const MultidimArray< double > &mV, double &def, double rot, double tilt, double psi)
 Deform a volumen using Zernike-Spherical harmonic basis. More...
 
void updateCTFImage (double defocusU, double defocusV, double angle)
 
double transformImageSph (double *pc_priors)
 
virtual void finishProcessing ()
 
virtual void writeImageParameters (MDRow &row)
 
virtual void checkPoint ()
 For very long programs, it may be needed to write checkpoints. More...
 
Matrix1D< double > weightsInterpolation3D (double x, double y, double z)
 
void splattingAtPos (std::array< double, 3 > r, double weight, MultidimArray< double > &mP, const MultidimArray< double > &mV)
 
std::vector< double > string2vector (std::string const &s) const
 
void linearCombinationClnm ()
 
void optimalPowellOrder ()
 
double bspline1 (double x)
 
- 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 run ()
 Run over all images. 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 fnPriors
 
FileName fnOutDir
 Output directory. More...
 
int L1
 
int L2
 
Matrix1D< int > vL1
 
Matrix1D< int > vN
 
Matrix1D< int > vL2
 
Matrix1D< int > vM
 
double maxShift
 
double maxAngularChange
 
double maxResol
 
double Ts
 
int Rmax
 
bool optimizeAlignment
 
bool optimizeDefocus
 
bool ignoreCTF
 
bool optimizeRadius
 
bool phaseFlipped
 
double lambda
 
int RmaxDef
 
int num_images
 
int algn_params
 
int ctf_params
 
Matrix1D< double > p
 
int flagEnabled
 
int image_mode
 
bool useCTF
 
bool resume
 
MultidimArray< int > mask2D
 
MultidimArray< int > V_mask
 
std::vector< std::vector< double > > priors
 
size_t Xdim
 
std::vector< FileNamefnImage
 
Image< double > V
 
Image< double > Vdeformed
 
std::vector< Image< double > > I
 
std::vector< Image< double > > Ifiltered
 
std::vector< Image< double > > Ifilteredp
 
std::vector< Image< double > > P
 
FourierFilter filter
 
Matrix2D< double > A1
 
Matrix2D< double > A2
 
Matrix2D< double > A3
 
std::vector< double > old_rot
 
std::vector< double > old_tilt
 
std::vector< double > old_psi
 
std::vector< double > deltaRot
 
std::vector< double > deltaTilt
 
std::vector< double > deltaPsi
 
std::vector< double > old_shiftX
 
std::vector< double > old_shiftY
 
std::vector< double > deltaX
 
std::vector< double > deltaY
 
bool old_flip
 
bool hasCTF
 
std::vector< double > old_defocusU
 
std::vector< double > old_defocusV
 
std::vector< double > old_defocusAngle
 
std::vector< double > deltaDefocusU
 
std::vector< double > deltaDefocusV
 
std::vector< double > deltaDefocusAngle
 
std::vector< double > currentDefocusU
 
std::vector< double > currentDefocusV
 
std::vector< double > currentAngle
 
FourierFilter FilterCTF1
 
FourierFilter FilterCTF2
 
FourierFilter FilterCTF3
 
int vecSize
 
Matrix1D< double > c_priors
 
Matrix1D< double > clnm
 
Matrix1D< double > steps_cp
 
double totalDeformation
 
double prior_deformation
 
std::vector< double > prior_deformations
 
bool showOptimization
 
double correlation
 
int loop_step
 
struct blobtype blob
 
double blob_r
 
bool do_not_init
 
- 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
 

Protected Member Functions

void createWorkFiles ()
 
- 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 Member Functions inherited from Rerunable
 Rerunable (const FileName &fn)
 
virtual void createWorkFiles (bool resume, MetaData *md)
 
const FileNamegetFileName () const
 
void setFileName (const FileName &fn)
 

Additional Inherited Members

- 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 43 of file forward_zernike_images_priors.h.

Member Enumeration Documentation

◆ Direction

Enumerator
ROTATE 
UNROTATE 

Definition at line 154 of file forward_zernike_images_priors.h.

154 { ROTATE, UNROTATE };

Constructor & Destructor Documentation

◆ ProgForwardZernikeImagesPriors()

ProgForwardZernikeImagesPriors::ProgForwardZernikeImagesPriors ( )

Empty constructor.

Definition at line 36 of file forward_zernike_images_priors.cpp.

36  : Rerunable("")
37 {
38  resume = false;
39  produces_a_metadata = true;
41  showOptimization = false;
42 }
bool each_image_produces_an_output
Indicate that an output is produced for each image in the input.
Rerunable(const FileName &fn)
bool produces_a_metadata
Indicate that the unique final output file is a Metadata.

◆ ~ProgForwardZernikeImagesPriors()

ProgForwardZernikeImagesPriors::~ProgForwardZernikeImagesPriors ( )
default

Destructor.

Member Function Documentation

◆ bspline1()

double ProgForwardZernikeImagesPriors::bspline1 ( double  x)

Definition at line 1279 of file forward_zernike_images_priors.cpp.

1280 {
1281  double m = 1 / blob_r;
1282  if (0. < x && x < blob_r)
1283  return m * (blob_r - x);
1284  else if (-blob_r < x && x <= 0.)
1285  return m * (blob_r + x);
1286  else
1287  return 0.;
1288 }
doublereal * x
int m

◆ checkPoint()

void ProgForwardZernikeImagesPriors::checkPoint ( )
virtual

For very long programs, it may be needed to write checkpoints.

Reimplemented from XmippMetadataProgram.

Reimplemented in MpiProgForwardZernikeImagesPriors.

Definition at line 905 of file forward_zernike_images_priors.cpp.

905  {
906  MDRowVec rowAppend;
908  getOutputMd().getRow(rowAppend, getOutputMd().lastRowId());
909  checkPoint.addRow(rowAppend);
910  checkPoint.append(Rerunable::getFileName());
911 }
virtual void checkPoint()
For very long programs, it may be needed to write checkpoints.
std::unique_ptr< MDRow > getRow(size_t id) override
size_t addRow(const MDRow &row) override
const FileName & getFileName() const
void append(const FileName &outFile) const

◆ createWorkFiles()

void ProgForwardZernikeImagesPriors::createWorkFiles ( )
inlineprotected

Definition at line 222 of file forward_zernike_images_priors.h.

virtual void createWorkFiles(bool resume, MetaData *md)

◆ defineParams()

void ProgForwardZernikeImagesPriors::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippMetadataProgram.

Definition at line 105 of file forward_zernike_images_priors.cpp.

106 {
107  addUsageLine("Make a continuous angular assignment with deformations");
108  defaultComments["-i"].clear();
109  defaultComments["-i"].addComment("Metadata with initial alignment");
110  defaultComments["-o"].clear();
111  defaultComments["-o"].addComment("Metadata with the angular alignment and deformation parameters");
113  addParamsLine(" --ref <volume> : Reference volume");
114  addParamsLine(" --priors <metadata_file> : List of priors (deformation coefficients)");
115  addParamsLine(" [--mask <m=\"\">] : Reference volume");
116  addParamsLine(" [--odir <outputDir=\".\">] : Output directory");
117  addParamsLine(" [--max_shift <s=-1>] : Maximum shift allowed in pixels");
118  addParamsLine(" [--max_angular_change <a=5>] : Maximum angular change allowed (in degrees)");
119  addParamsLine(" [--max_resolution <f=4>] : Maximum resolution (A)");
120  addParamsLine(" [--sampling <Ts=1>] : Sampling rate (A/pixel)");
121  addParamsLine(" [--Rmax <R=-1>] : Maximum radius (px). -1=Half of volume size");
122  addParamsLine(" [--RDef <r=-1>] : Maximum radius of the deformation (px). -1=Half of volume size");
123  addParamsLine(" [--l1 <l1=3>] : Degree Zernike Polynomials=1,2,3,...");
124  addParamsLine(" [--l2 <l2=2>] : Harmonical depth of the deformation=1,2,3,...");
125  addParamsLine(" [--regularization <l=0.005>] : Regularization weight");
126  addParamsLine(" [--step <step=1>] : Voxel index step");
127  addParamsLine(" [--useCTF] : Correct CTF");
128  addParamsLine(" [--optimizeAlignment] : Optimize alignment");
129  addParamsLine(" [--optimizeDefocus] : Optimize defocus");
130  addParamsLine(" [--phaseFlipped] : Input images have been phase flipped");
131  addParamsLine(" [--blobr <b=1.5>] : Blob radius for forward mapping splatting");
132  addParamsLine(" [--image_mode <im=-1>] : Image mode (single, pairs, triplets). By default, it will be automatically identified.");
133  addParamsLine(" [--resume] : Resume processing");
134  addExampleLine("A typical use is:",false);
135  addExampleLine("xmipp_angular_sph_alignment -i anglesFromContinuousAssignment.xmd --ref reference.vol -o assigned_anglesAndDeformations.xmd --optimizeAlignment --optimizeDeformation --depth 1");
136 }
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 ProgForwardZernikeImagesPriors::deformVol ( MultidimArray< double > &  mVD,
const MultidimArray< double > &  mV,
double &  def,
double  rot,
double  tilt,
double  psi 
)

Deform a volumen using Zernike-Spherical harmonic basis.

Definition at line 969 of file forward_zernike_images_priors.cpp.

971 {
972  size_t idxY0=vecSize;
973  double Ncount=0.0;
974  double modg=0.0;
975  double diff2=0.0;
976 
977  def=0.0;
978  size_t idxZ0=2*idxY0;
979  double RmaxF=RmaxDef;
980  double RmaxF2=RmaxF*RmaxF;
981  double iRmaxF=1.0/RmaxF;
982  // Rotation Matrix
984  R.initIdentity(3);
985  Euler_angles2matrix(rot, tilt, psi, R, false);
986 
987  // TODO: Poner primero i y j en el loop, acumular suma y guardar al final
988  const auto lastZ = FINISHINGZ(mV);
989  const auto lastY = FINISHINGY(mV);
990  const auto lastX = FINISHINGX(mV);
991  for (int k=STARTINGZ(mV); k<=lastZ; k+=loop_step)
992  {
993  for (int i=STARTINGY(mV); i<=lastY; i+=loop_step)
994  {
995  for (int j=STARTINGX(mV); j<=lastX; j+=loop_step)
996  {
997  if (A3D_ELEM(V_mask,k,i,j) == 1) {
998  double gx=0.0, gy=0.0, gz=0.0;
999  double k2=k*k;
1000  double kr=k*iRmaxF;
1001  double k2i2=k2+i*i;
1002  double ir=i*iRmaxF;
1003  double r2=k2i2+j*j;
1004  double jr=j*iRmaxF;
1005  double rr=sqrt(r2)*iRmaxF;
1006  for (size_t idx = 0; idx < idxY0; idx++)
1007  {
1008  auto l1 = VEC_ELEM(vL1,idx);
1009  auto n = VEC_ELEM(vN,idx);
1010  auto l2 = VEC_ELEM(vL2,idx);
1011  auto m = VEC_ELEM(vM,idx);
1012  auto zsph=ZernikeSphericalHarmonics(l1,n,l2,m,jr,ir,kr,rr);
1013  auto c = std::array<double, 3>{};
1014  c[0] = VEC_ELEM(clnm,idx);
1015  c[1] = VEC_ELEM(clnm,idx+idxY0);
1016  c[2] = VEC_ELEM(clnm,idx+idxZ0);
1017  if (rr>0 || l2==0) {
1018  gx += c[0] *(zsph);
1019  gy += c[1] *(zsph);
1020  gz += c[2] *(zsph);
1021  }
1022  }
1023 
1024  auto pos = std::array<double, 3>{};
1025  double r_x = j + gx;
1026  double r_y = i + gy;
1027  double r_z = k + gz;
1028  pos[0] = R.mdata[0] * r_x + R.mdata[1] * r_y + R.mdata[2] * r_z;
1029  pos[1] = R.mdata[3] * r_x + R.mdata[4] * r_y + R.mdata[5] * r_z;
1030  pos[2] = R.mdata[6] * r_x + R.mdata[7] * r_y + R.mdata[8] * r_z;
1031 
1032  double voxel_mV = A3D_ELEM(mV,k,i,j);
1033  splattingAtPos(pos, voxel_mV, mP, mV);
1034  modg += gx*gx+gy*gy+gz*gz;
1035  Ncount++;
1036  }
1037  }
1038  }
1039  }
1040 
1041  def = sqrt(modg/Ncount);
1042  totalDeformation = def;
1043 }
void splattingAtPos(std::array< double, 3 > r, double weight, MultidimArray< double > &mP, const MultidimArray< double > &mV)
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
#define FINISHINGX(v)
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
doublereal * c
void sqrt(Image< double > &op)
T * mdata
Definition: matrix2d.h:395
#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
int m
#define FINISHINGY(v)
double ZernikeSphericalHarmonics(int n, int m, double xr, double yr, double zr, double r)
double psi(const double x)
float r2
#define STARTINGZ(v)
int * n
int ir
void initIdentity()
Definition: matrix2d.h:673

◆ fillVectorTerms()

void ProgForwardZernikeImagesPriors::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 937 of file forward_zernike_images_priors.cpp.

939 {
940  int idx = 0;
941  vL1.initZeros(vecSize);
942  vN.initZeros(vecSize);
943  vL2.initZeros(vecSize);
944  vM.initZeros(vecSize);
945  for (int h=0; h<=l2; h++) {
946  int totalSPH = 2*h+1;
947  int aux = std::floor(totalSPH/2);
948  for (int l=h; l<=l1; l+=2) {
949  for (int m=0; m<totalSPH; m++) {
950  VEC_ELEM(vL1,idx) = l;
951  VEC_ELEM(vN,idx) = h;
952  VEC_ELEM(vL2,idx) = h;
953  VEC_ELEM(vM,idx) = m-aux;
954  idx++;
955  }
956  }
957  }
958 }
#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 ProgForwardZernikeImagesPriors::finishProcessing ( )
virtual

Write the final parameters.

Reimplemented from XmippMetadataProgram.

Reimplemented in MpiProgForwardZernikeImagesPriors.

Definition at line 285 of file forward_zernike_images_priors.cpp.

285  {
287  rename(Rerunable::getFileName().c_str(), (fnOutDir + fn_out).c_str());
288 }
const FileName & getFileName() const

◆ linearCombinationClnm()

void ProgForwardZernikeImagesPriors::linearCombinationClnm ( )

Definition at line 1106 of file forward_zernike_images_priors.cpp.

1107 {
1108  clnm.initZeros(3*vecSize);
1109  for (int idx=0; idx < 3*vecSize; idx++)
1110  {
1111  for (int idc = 0; idc < priors.size(); idc++)
1112  clnm[idx] += c_priors[idc] * priors[idc][idx];
1113  }
1114 }
std::vector< std::vector< double > > priors
void initZeros()
Definition: matrix1d.h:592

◆ minimizepos()

void ProgForwardZernikeImagesPriors::minimizepos ( Matrix1D< double > &  steps)

Determine the positions to be minimize of a vector containing spherical harmonic coefficients.

Definition at line 929 of file forward_zernike_images_priors.cpp.

930 {
931  int size = priors.size();
932  for (int idx=0; idx<size; idx++) {
933  VEC_ELEM(steps,idx) = 1.;
934  }
935 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
std::vector< std::vector< double > > priors

◆ numCoefficients()

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

Length of coefficients vector.

Definition at line 913 of file forward_zernike_images_priors.cpp.

914 {
915  for (int h=0; h<=l2; h++)
916  {
917  int numSPH = 2*h+1;
918  int count=l1-h+1;
919  int numEven=(count>>1)+(count&1 && !(h&1));
920  if (h%2 == 0) {
921  vecSize += numSPH*numEven;
922  }
923  else {
924  vecSize += numSPH*(l1-h+1-numEven);
925  }
926  }
927 }

◆ optimalPowellOrder()

void ProgForwardZernikeImagesPriors::optimalPowellOrder ( )

Definition at line 1116 of file forward_zernike_images_priors.cpp.

1117 {
1118  do_not_init = false;
1119  std::vector<double> z(priors[0].size(), 0.0);
1120  priors.push_back(z);
1121  Matrix1D<double> cost_vec;
1122  cost_vec.initZeros(priors.size());
1123  int totalSize = priors.size() + algn_params + ctf_params;
1124 
1125  // Initialize some values
1126  // TODO: Optimize parameters for each image (not sharing)
1127  // prm->deltaDefocusU[0]=x[idx+6]; prm->deltaDefocusU[1]=x[idx+6];
1128  // prm->deltaDefocusV[0]=x[idx+7]; prm->deltaDefocusV[1]=x[idx+7];
1129  // prm->deltaDefocusAngle[0]=x[idx+8]; prm->deltaDefocusAngle[1]=x[idx+8];
1130 
1131  switch (num_images)
1132  {
1133  case 2:
1134  deltaX[0] = 0;
1135  deltaY[0] = 0;
1136  deltaRot[0] = 0;
1137  deltaTilt[0] = 0;
1138  deltaPsi[0] = 0;
1139  // prm->deltaDefocusU[0]=x[idx + 11];
1140  // prm->deltaDefocusV[0]=x[idx + 13];
1141  // prm->deltaDefocusAngle[0]=x[idx + 15];
1142 
1143  deltaX[1] = 0;
1144  deltaY[1] = 0;
1145  deltaRot[1] = 0;
1146  deltaTilt[1] = 0;
1147  deltaPsi[1] = 0;
1148  // prm->deltaDefocusU[1]=x[idx + 12];
1149  // prm->deltaDefocusV[1]=x[idx + 14];
1150  // prm->deltaDefocusAngle[1]=x[idx + 16];
1151 
1152  MAT_ELEM(A1, 0, 2) = old_shiftX[0];
1153  MAT_ELEM(A1, 1, 2) = old_shiftY[0];
1154  MAT_ELEM(A1, 0, 0) = 1;
1155  MAT_ELEM(A1, 0, 1) = 0;
1156  MAT_ELEM(A1, 1, 0) = 0;
1157  MAT_ELEM(A1, 1, 1) = 1;
1158 
1159  MAT_ELEM(A2, 0, 2) = old_shiftX[1];
1160  MAT_ELEM(A2, 1, 2) = old_shiftY[1];
1161  MAT_ELEM(A2, 0, 0) = 1;
1162  MAT_ELEM(A2, 0, 1) = 0;
1163  MAT_ELEM(A2, 1, 0) = 0;
1164  MAT_ELEM(A2, 1, 1) = 1;
1165  break;
1166 
1167  case 3:
1168  deltaX[0] = 0;
1169  deltaY[0] = 0;
1170  deltaRot[0] = 0;
1171  deltaTilt[0] = 0;
1172  deltaPsi[0] = 0;
1173  // prm->deltaDefocusU[0]=x[idx + 16];
1174  // prm->deltaDefocusV[0]=x[idx + 19];
1175  // prm->deltaDefocusAngle[0]=x[idx + 22];
1176 
1177  deltaX[1] = 0;
1178  deltaY[1] = 0;
1179  deltaRot[1] = 0;
1180  deltaTilt[1] = 0;
1181  deltaPsi[1] = 0;
1182  // prm->deltaDefocusU[1]=x[idx + 17];
1183  // prm->deltaDefocusV[1]=x[idx + 20];
1184  // prm->deltaDefocusAngle[1]=x[idx + 23];
1185 
1186  deltaX[2] = 0;
1187  deltaY[2] = 0;
1188  deltaRot[2] = 0;
1189  deltaTilt[2] = 0;
1190  deltaPsi[2] = 0;
1191  // prm->deltaDefocusU[2]=x[idx + 18];
1192  // prm->deltaDefocusV[2]=x[idx + 21];
1193  // prm->deltaDefocusAngle[2]=x[idx + 24];
1194 
1195  MAT_ELEM(A1, 0, 2) = old_shiftX[0];
1196  MAT_ELEM(A1, 1, 2) = old_shiftY[0];
1197  MAT_ELEM(A1, 0, 0) = 1;
1198  MAT_ELEM(A1, 0, 1) = 0;
1199  MAT_ELEM(A1, 1, 0) = 0;
1200  MAT_ELEM(A1, 1, 1) = 1;
1201 
1202  MAT_ELEM(A2, 0, 2) = old_shiftX[1];
1203  MAT_ELEM(A2, 1, 2) = old_shiftY[1];
1204  MAT_ELEM(A2, 0, 0) = 1;
1205  MAT_ELEM(A2, 0, 1) = 0;
1206  MAT_ELEM(A2, 1, 0) = 0;
1207  MAT_ELEM(A2, 1, 1) = 1;
1208 
1209  MAT_ELEM(A3, 0, 2) = old_shiftX[2];
1210  MAT_ELEM(A3, 1, 2) = old_shiftY[2];
1211  MAT_ELEM(A3, 0, 0) = 1;
1212  MAT_ELEM(A3, 0, 1) = 0;
1213  MAT_ELEM(A3, 1, 0) = 0;
1214  MAT_ELEM(A3, 1, 1) = 1;
1215  break;
1216 
1217 
1218  default:
1219  deltaX[0] = 0;
1220  deltaY[0] = 0;
1221  deltaRot[0] = 0;
1222  deltaTilt[0] = 0;
1223  deltaPsi[0] = 0;
1224  deltaDefocusU[0] = 0;
1225  deltaDefocusV[0] = 0;
1226  deltaDefocusAngle[0] = 0;
1227 
1228  MAT_ELEM(A1, 0, 2) = old_shiftX[0];
1229  MAT_ELEM(A1, 1, 2) = old_shiftY[0];
1230  MAT_ELEM(A1, 0, 0) = 1;
1231  MAT_ELEM(A1, 0, 1) = 0;
1232  MAT_ELEM(A1, 1, 0) = 0;
1233  MAT_ELEM(A1, 1, 1) = 1;
1234  break;
1235  }
1236 
1237  auto lambda_aux = lambda;
1238  lambda = 0.0;
1239  for (int idx=0; idx < priors.size(); idx++)
1240  {
1241  clnm.initZeros(3*vecSize);
1242  p.initZeros(totalSize);
1243  p[idx] = 1.0;
1244  double *pptr = p.adaptForNumericalRecipes();
1245  cost_vec[idx] = transformImageSph(pptr);
1246  }
1247  lambda = lambda_aux;
1248 
1249  std::vector<std::size_t> index_vec;
1250  for (std::size_t i = 0; i != priors.size(); ++i)
1251  {
1252  index_vec.push_back(i);
1253  }
1254 
1255  std::sort(
1256  index_vec.begin(), index_vec.end(),
1257  [&](std::size_t a, std::size_t b)
1258  { return cost_vec[a] < cost_vec[b]; });
1259 
1260  auto priors_aux = priors;
1261  auto prior_deformations_aux = prior_deformations;
1262  priors.clear();
1263  prior_deformations.clear();
1264  for (std::size_t i = 0; i != index_vec.size(); ++i)
1265  {
1266  auto v = priors_aux[index_vec[i]];
1267  auto d = prior_deformations_aux[index_vec[i]];
1268  bool zeros = std::all_of(v.begin(), v.end(), [](double j) { return j==0.0; });
1269  if (!zeros)
1270  {
1271  priors.push_back(v);
1272  prior_deformations.push_back(d);
1273  }
1274  else if (zeros && i==0)
1275  do_not_init = true;
1276  }
1277 }
std::vector< std::vector< double > > priors
#define i
doublereal * d
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
doublereal * b
double z
void initZeros()
Definition: matrix1d.h:592
void sort(struct DCEL_T *dcel)
Definition: sorting.cpp:18
#define j
T * adaptForNumericalRecipes() const
Definition: matrix1d.h:844
doublereal * a

◆ preProcess()

void ProgForwardZernikeImagesPriors::preProcess ( )
virtual

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

Reimplemented from XmippMetadataProgram.

Definition at line 138 of file forward_zernike_images_priors.cpp.

139 {
140  V.read(fnVolR);
141  V().setXmippOrigin();
142  Xdim=XSIZE(V());
143  Vdeformed().initZeros(V());
144  Vdeformed().setXmippOrigin();
145 
146  std::string line;
147  std::ifstream priorsFile(fnPriors.getString());
148  bool first_line = true;
149  while (std::getline(priorsFile, line))
150  {
151  if (first_line)
152  {
153  std::vector<double> basisParams = string2vector(line);
154  L1 = (int)basisParams[0]; L2 = (int)basisParams[1]; RmaxDef = (int)basisParams[2];
155  first_line = false;
156  for (int idx=3; idx < basisParams.size(); idx++)
157  prior_deformations.push_back(basisParams[idx]);
158  }
159  else
160  {
161  priors.push_back(string2vector(line));
162  }
163  }
164 
165  // Check execution mode (single, pair, or triplet)
166  if (image_mode > 0)
167  {
169  }
170  else{
171  num_images = 1; // Single image
172  if (getInputMd()->containsLabel(MDL_IMAGE1) && !getInputMd()->containsLabel(MDL_IMAGE2))
173  {
174  num_images = 2; // Pair
175  }
176  else if (getInputMd()->containsLabel(MDL_IMAGE1) && getInputMd()->containsLabel(MDL_IMAGE2))
177  {
178  num_images = 3; // Triplet
179  }
180  }
181 
182  // Preallocate vectors (Size depends on image number)
183  fnImage.resize(num_images, "");
184  I.resize(num_images); Ifiltered.resize(num_images); Ifilteredp.resize(num_images);
185  P.resize(num_images);
186  old_rot.resize(num_images, 0.); old_tilt.resize(num_images, 0.); old_psi.resize(num_images, 0.);
187  deltaRot.resize(num_images, 0.); deltaTilt.resize(num_images, 0.); deltaPsi.resize(num_images, 0.);
188  old_shiftX.resize(num_images, 0.); old_shiftY.resize(num_images, 0.);
189  deltaX.resize(num_images, 0.); deltaY.resize(num_images, 0.);
190  old_defocusU.resize(num_images, 0.); old_defocusV.resize(num_images, 0.); old_defocusAngle.resize(num_images, 0.);
191  deltaDefocusU.resize(num_images, 0.); deltaDefocusV.resize(num_images, 0.); deltaDefocusAngle.resize(num_images, 0.);
192  currentDefocusU.resize(num_images, 0.); currentDefocusV.resize(num_images, 0.); currentAngle.resize(num_images, 0.);
193 
194  switch (num_images)
195  {
196  case 2:
197  Ifilteredp[0]().initZeros(Xdim,Xdim); Ifilteredp[1]().initZeros(Xdim,Xdim);
198  Ifilteredp[0]().setXmippOrigin(); Ifilteredp[1]().setXmippOrigin();
199  P[0]().initZeros(Xdim,Xdim); P[1]().initZeros(Xdim,Xdim);
200  break;
201  case 3:
202  Ifilteredp[0]().initZeros(Xdim,Xdim); Ifilteredp[1]().initZeros(Xdim,Xdim); Ifilteredp[2]().initZeros(Xdim,Xdim);
203  Ifilteredp[0]().setXmippOrigin(); Ifilteredp[1]().setXmippOrigin(); Ifilteredp[2]().setXmippOrigin();
204  P[0]().initZeros(Xdim,Xdim); P[1]().initZeros(Xdim,Xdim); P[2]().initZeros(Xdim,Xdim);
205  break;
206 
207  default:
208  Ifilteredp[0]().initZeros(Xdim,Xdim);
209  Ifilteredp[0]().setXmippOrigin();
210  P[0]().initZeros(Xdim,Xdim);
211  break;
212  }
213 
214  if (RmaxDef<0)
215  RmaxDef = Xdim/2;
216 
217  // Read Reference mask if avalaible (otherwise sphere of radius RmaxDef is used)
218  Mask mask;
219  mask.type = BINARY_CIRCULAR_MASK;
220  mask.mode = INNER_MASK;
221  if (fnMaskR != "") {
222  Image<double> aux;
223  aux.read(fnMaskR);
224  typeCast(aux(), V_mask);
226  double Rmax2 = RmaxDef*RmaxDef;
227  for (int k=STARTINGZ(V_mask); k<=FINISHINGZ(V_mask); k++) {
228  for (int i=STARTINGY(V_mask); i<=FINISHINGY(V_mask); i++) {
229  for (int j=STARTINGX(V_mask); j<=FINISHINGX(V_mask); j++) {
230  double r2 = k*k + i*i + j*j;
231  if (r2>=Rmax2)
232  A3D_ELEM(V_mask,k,i,j) = 0;
233  }
234  }
235  }
236  }
237  else {
238  mask.R1 = RmaxDef;
239  mask.generate_mask(V());
240  V_mask = mask.get_binary_mask();
242  }
243 
244  // Construct mask
245  if (Rmax<0)
246  Rmax=Xdim/2;
247  mask.R1 = Rmax;
248  mask.generate_mask(Xdim,Xdim);
249  mask2D=mask.get_binary_mask();
250 
251  // Low pass filter
254  filter.raised_w=0.02;
255 
256  // Transformation matrix
257  A1.initIdentity(3);
258  A2.initIdentity(3);
259  A3.initIdentity(3);
260 
261  // CTF Filter
271 
272  vecSize = 0;
275 
276  createWorkFiles();
277 
278  // Blob
279  blob.radius = blob_r; // Blob radius in voxels
280  blob.order = 2; // Order of the Bessel function
281  blob.alpha = 3.6; // Smoothness parameter
282 
283 }
std::vector< Image< double > > Ifiltered
double alpha
Smoothness parameter.
Definition: blobs.h:121
CTFDescription ctf
void numCoefficients(int l1, int l2, int &vecSize)
Length of coefficients vector.
#define FINISHINGX(v)
Definition: mask.h:360
std::vector< std::vector< double > > priors
#define FINISHINGZ(v)
std::vector< double > string2vector(std::string const &s) const
#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 CTF
double R1
Definition: mask.h:413
#define XSIZE(v)
Image associated to this object (std::string)
int type
Definition: mask.h:402
Image associated to this object (std::string)
#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
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
String getString() const
int order
Derivation order and Bessel function order.
Definition: blobs.h:118
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
float r2
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
const MultidimArray< int > & get_binary_mask() const
Definition: mask.h:707
std::vector< Image< double > > Ifilteredp
#define STARTINGZ(v)
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
void fillVectorTerms(int l1, int l2, Matrix1D< int > &vL1, Matrix1D< int > &vN, Matrix1D< int > &vL2, Matrix1D< int > &vM)
Zernike and SPH coefficients allocation.
#define LOWPASS
void initIdentity()
Definition: matrix2d.h:673
int mode
Definition: mask.h:407
constexpr int INNER_MASK
Definition: mask.h:47

◆ processImage()

void ProgForwardZernikeImagesPriors::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 642 of file forward_zernike_images_priors.cpp.

643 {
645  // totalSize = 3*num_Z_coeff + num_images * 2 shifts + num_images * 3 angles + num_images * 3 CTF
646  algn_params = num_images * 5;
647  ctf_params = num_images * 3;
648  int totalSize = priors.size() + algn_params + ctf_params;
649  p.initZeros(totalSize);
650  c_priors.initZeros(totalSize);
652 
653  flagEnabled=1;
654 
655  rowIn.getValueOrDefault(MDL_IMAGE, fnImage[0], "");
656  rowIn.getValueOrDefault(MDL_ANGLE_ROT, old_rot[0], 0.0);
657  rowIn.getValueOrDefault(MDL_ANGLE_TILT, old_tilt[0], 0.0);
658  rowIn.getValueOrDefault(MDL_ANGLE_PSI, old_psi[0], 0.0);
659  rowIn.getValueOrDefault(MDL_SHIFT_X, old_shiftX[0], 0.0);
660  rowIn.getValueOrDefault(MDL_SHIFT_Y, old_shiftY[0], 0.0);
661  I[0].read(fnImage[0]);
662  I[0]().setXmippOrigin();
663  Ifiltered[0]() = I[0]();
665 
666  switch (num_images)
667  {
668  case 2:
669  rowIn.getValueOrDefault(MDL_IMAGE1, fnImage[1], "");
670  rowIn.getValueOrDefault(MDL_ANGLE_ROT2, old_rot[1], 0.0);
672  rowIn.getValueOrDefault(MDL_ANGLE_PSI2, old_psi[1], 0.0);
673  rowIn.getValueOrDefault(MDL_SHIFT_X2, old_shiftX[1], 0.0);
674  rowIn.getValueOrDefault(MDL_SHIFT_Y2, old_shiftY[1], 0.0);
675  I[1].read(fnImage[1]);
676  I[1]().setXmippOrigin();
677  Ifiltered[1]() = I[1]();
679 
680  if (verbose >= 2)
681  std::cout << "Processing Pair (" << fnImage[0] << "," << fnImage[1] << ")" << std::endl;
682  break;
683 
684  case 3:
685  rowIn.getValueOrDefault(MDL_IMAGE1, fnImage[1], "");
686  rowIn.getValueOrDefault(MDL_ANGLE_ROT2, old_rot[1], 0.0);
688  rowIn.getValueOrDefault(MDL_ANGLE_PSI2, old_psi[1], 0.0);
689  rowIn.getValueOrDefault(MDL_SHIFT_X2, old_shiftX[1], 0.0);
690  rowIn.getValueOrDefault(MDL_SHIFT_Y2, old_shiftY[1], 0.0);
691  I[1].read(fnImage[1]);
692  I[1]().setXmippOrigin();
693  Ifiltered[1]() = I[1]();
695 
696  rowIn.getValueOrDefault(MDL_IMAGE2, fnImage[2], "");
697  rowIn.getValueOrDefault(MDL_ANGLE_ROT3, old_rot[2], 0.0);
699  rowIn.getValueOrDefault(MDL_ANGLE_PSI3, old_psi[2], 0.0);
700  rowIn.getValueOrDefault(MDL_SHIFT_X3, old_shiftX[2], 0.0);
701  rowIn.getValueOrDefault(MDL_SHIFT_Y3, old_shiftY[2], 0.0);
702  I[2].read(fnImage[2]);
703  I[2]().setXmippOrigin();
704  Ifiltered[2]() = I[2]();
706 
707  if (verbose >= 2)
708  std::cout << "Processing Triplet (" << fnImage[0] << "," << fnImage[1] << "," << fnImage[2] << ")" << std::endl;
709  break;
710 
711  default:
712  if (verbose >= 2)
713  std::cout << "Processing Image (" << fnImage[0] << ")" << std::endl;
714  break;
715  }
716 
717  if (rowIn.containsLabel(MDL_FLIP))
718  rowIn.getValue(MDL_FLIP,old_flip);
719  else
720  old_flip = false;
721 
722  // FIXME: Add defocus per image and make CTF correction available
724  {
725  hasCTF=true;
727  FilterCTF1.ctf.Tm = Ts;
732  }
733  else
734  hasCTF=false;
735 
736  prior_deformation = 0.0;
738  p.initZeros(totalSize);
739  c_priors.initZeros(totalSize);
741  if (!do_not_init)
742  {
743  p[0] = 1.0;
744  c_priors[0] = 1.0;
745  clnm = priors[0];
747  }
748 
749  if (verbose >= 2)
750  {
751  std::cout << std::endl;
752  std::cout << "------------------------------ Fiding priors linear combination ----------------------------" << std::endl;
753  }
754  steps.clear();
755  steps.initZeros(totalSize);
756 
757  // Optimize
758  double cost = -1;
759  try
760  {
761  cost = 1e38;
762  int iter;
763  if (optimizeAlignment)
764  {
765  int init = steps.size() - algn_params - ctf_params;
766  int end = steps.size() - ctf_params;
767  for (int i = init; i < end; i++)
768  steps(i) = 1.;
769  }
770  if (optimizeDefocus)
771  {
772  int init = steps.size() - ctf_params;
773  int end = steps.size();
774  for (int i = init; i < end; i++)
775  steps(i) = 1.;
776  }
777  minimizepos(steps);
778  steps_cp = steps;
779  powellOptimizer(p, 1, totalSize, &continuousZernikePriorsCost, this, 0.01, cost, iter, steps, verbose >= 2);
780 
781  if (verbose >= 3)
782  {
783  showOptimization = true;
785  showOptimization = false;
786  }
787 
788  if (cost > 0)
789  {
790  flagEnabled = -1;
791  p.initZeros();
792  }
793  cost = -cost;
794  correlation = cost;
795  if (verbose >= 2)
796  {
797  std::cout << std::endl;
798  for (int j = 1; j < 4; j++)
799  {
800  switch (j)
801  {
802  case 1:
803  std::cout << "X Coefficients=(";
804  break;
805  case 2:
806  std::cout << "Y Coefficients=(";
807  break;
808  case 3:
809  std::cout << "Z Coefficients=(";
810  break;
811  default:
812  // Default case will be never reached
813  break;
814  }
815  for (int i = (j - 1) * vecSize; i < j * vecSize; i++)
816  {
817  std::cout << clnm(i);
818  if (i < j * vecSize - 1)
819  std::cout << ",";
820  }
821  std::cout << ")" << std::endl;
822  }
823  std::cout << "Radius=" << RmaxDef << std::endl;
824  std::cout << " Dshift=(" << p(totalSize - 5) << "," << p(totalSize - 4) << ") "
825  << "Drot=" << p(totalSize - 3) << " Dtilt=" << p(totalSize - 2)
826  << " Dpsi=" << p(totalSize - 1) << std::endl;
827  std::cout << " Total deformation=" << totalDeformation << std::endl;
828  std::cout << std::endl;
829  }
830  }
831  catch (XmippError &XE)
832  {
833  std::cerr << XE.what() << std::endl;
834  std::cerr << "Warning: Cannot refine " << fnImg << std::endl;
835  flagEnabled = -1;
836  }
837 
838  //AJ NEW
839  writeImageParameters(rowOut);
840  //END AJ
841 
842 }
std::vector< Image< double > > Ifiltered
Rotation angle of an image (double,degrees)
Defocus U (Angstroms)
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
Shift for the image in the Y axis (double)
CTFDescription ctf
void clear()
Definition: matrix1d.cpp:67
size_t size() const
Definition: matrix1d.h:508
Tilting angle of an image (double,degrees)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
Shift for the image in the X axis (double)
std::vector< std::vector< double > > priors
Tilting angle of an image (double,degrees)
Special label to be used when gathering MDs in MpiMetadataPrograms.
Name for the CTF Model (std::string)
void powellOptimizer(Matrix1D< double > &p, int i0, int n, double(*f)(double *x, void *), void *prm, double ftol, double &fret, int &iter, const Matrix1D< double > &steps, bool show)
glob_prnt iter
#define i
Shift for the image in the Y axis (double)
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
Rotation angle of an image (double,degrees)
T & getValue(MDLabel label)
Flip the image? (bool)
Image associated to this object (std::string)
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
Image associated to this object (std::string)
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:1172
int verbose
Verbosity level.
void initZeros()
Definition: matrix1d.h:592
Psi angle of an image (double,degrees)
#define j
double steps
const T & getValueOrDefault(MDLabel label, const T &def) const
double continuousZernikePriorsCost(double *x, void *_prm)
Shift for the image in the X axis (double)
virtual bool containsLabel(MDLabel label) const =0
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
Rotation angle of an image (double,degrees)
Shift for the image in the Y axis (double)
void minimizepos(Matrix1D< double > &steps)
Determine the positions to be minimize of a vector containing spherical harmonic coefficients.
T * adaptForNumericalRecipes() const
Definition: matrix1d.h:844
Psi angle of an image (double,degrees)
Name of an image (std::string)
void applyMaskSpace(MultidimArray< double > &v)

◆ readParams()

void ProgForwardZernikeImagesPriors::readParams ( )
virtual

Read argument from command line.

Reimplemented from XmippMetadataProgram.

Definition at line 47 of file forward_zernike_images_priors.cpp.

48 {
50  fnVolR = getParam("--ref");
51  fnMaskR = getParam("--mask");
52  fnPriors = getParam("--priors");
53  fnOutDir = getParam("--odir");
54  maxShift = getDoubleParam("--max_shift");
55  maxAngularChange = getDoubleParam("--max_angular_change");
56  maxResol = getDoubleParam("--max_resolution");
57  Ts = getDoubleParam("--sampling");
58  Rmax = getIntParam("--Rmax");
59  RmaxDef = getIntParam("--RDef");
60  optimizeAlignment = checkParam("--optimizeAlignment");
61  optimizeDefocus = checkParam("--optimizeDefocus");
62  phaseFlipped = checkParam("--phaseFlipped");
63  useCTF = checkParam("--useCTF");
64  L1 = getIntParam("--l1");
65  L2 = getIntParam("--l2");
66  loop_step = getIntParam("--step");
67  image_mode = getIntParam("--image_mode");
68  resume = checkParam("--resume");
69  lambda = getDoubleParam("--regularization");
70  Rerunable::setFileName(fnOutDir + "/sphDone.xmd");
71  blob_r = getDoubleParam("--blobr");
72  keep_input_columns = true;
73 }
double getDoubleParam(const char *param, int arg=0)
void setFileName(const FileName &fn)
const char * getParam(const char *param, int arg=0)
bool keep_input_columns
Keep input metadata columns.
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ show()

void ProgForwardZernikeImagesPriors::show ( )

Show.

Definition at line 76 of file forward_zernike_images_priors.cpp.

77 {
78  if (!verbose)
79  return;
81  std::cout
82  << "Output directory: " << fnOutDir << std::endl
83  << "Reference volume: " << fnVolR << std::endl
84  << "Reference mask: " << fnMaskR << std::endl
85  << "Max. Shift: " << maxShift << std::endl
86  << "Max. Angular Change: " << maxAngularChange << std::endl
87  << "Max. Resolution: " << maxResol << std::endl
88  << "Sampling: " << Ts << std::endl
89  << "Max. Radius: " << Rmax << std::endl
90  << "Max. Radius Deform. " << RmaxDef << std::endl
91  << "Zernike Degree: " << L1 << std::endl
92  << "SH Degree: " << L2 << std::endl
93  << "Step: " << loop_step << std::endl
94  << "Correct CTF: " << useCTF << std::endl
95  << "Optimize alignment: " << optimizeAlignment << std::endl
96  << "Optimize defocus: " << optimizeDefocus << std::endl
97  << "Regularization: " << lambda << std::endl
98  << "Phase flipped: " << phaseFlipped << std::endl
99  << "Blob radius: " << blob_r << std::endl
100  << "Image mode: " << image_mode << std::endl
101  ;
102 }
int verbose
Verbosity level.
void show() const override

◆ splattingAtPos()

void ProgForwardZernikeImagesPriors::splattingAtPos ( std::array< double, 3 >  r,
double  weight,
MultidimArray< double > &  mP,
const MultidimArray< double > &  mV 
)

Definition at line 1076 of file forward_zernike_images_priors.cpp.

1076  {
1077  // Find the part of the volume that must be updated
1078  double x_pos = r[0];
1079  double y_pos = r[1];
1080  double z_pos = r[2];
1081  int i0 = XMIPP_MAX(FLOOR(y_pos - blob_r), STARTINGY(mV));
1082  int iF = XMIPP_MIN(CEIL(y_pos + blob_r), FINISHINGY(mV));
1083  int j0 = XMIPP_MAX(FLOOR(x_pos - blob_r), STARTINGX(mV));
1084  int jF = XMIPP_MIN(CEIL(x_pos + blob_r), FINISHINGX(mV));
1085  for (int i = i0; i <= iF; i++)
1086  {
1087  double y_val = bspline1(i - y_pos);
1088  for (int j = j0; j <= jF; j++)
1089  {
1090  double x_val = bspline1(j - x_pos);
1091  A2D_ELEM(mP, i, j) += weight * x_val * y_val;
1092  }
1093  }
1094 }
#define A2D_ELEM(v, i, j)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
#define FINISHINGX(v)
#define STARTINGX(v)
#define i
#define STARTINGY(v)
#define FLOOR(x)
Definition: xmipp_macros.h:240
#define CEIL(x)
Definition: xmipp_macros.h:225
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
#define FINISHINGY(v)

◆ string2vector()

std::vector< double > ProgForwardZernikeImagesPriors::string2vector ( std::string const &  s) const

Definition at line 1096 of file forward_zernike_images_priors.cpp.

1097 {
1098  std::stringstream iss(s);
1099  double number;
1100  std::vector<double> v;
1101  while (iss >> number)
1102  v.push_back(number);
1103  return v;
1104 }

◆ transformImageSph()

double ProgForwardZernikeImagesPriors::transformImageSph ( double *  pc_priors)

Definition at line 290 of file forward_zernike_images_priors.cpp.

291 {
292  const MultidimArray<double> &mV=V();
294  VEC_ELEM(c_priors,i)=pc_priors[i+1];
295 
297 
298  double deformation=0.0;
299  totalDeformation=0.0;
300 
301  P[0]().initZeros(Xdim,Xdim);
302  P[0]().setXmippOrigin();
303  double currentRot=old_rot[0] + deltaRot[0];
304  double currentTilt=old_tilt[0] + deltaTilt[0];
305  double currentPsi=old_psi[0] + deltaPsi[0];
306  deformVol(P[0](), mV, deformation, currentRot, currentTilt, currentPsi);
307 
308  double cost=0.0;
309  const MultidimArray<int> &mMask2D=mask2D;
310  double corr2 = 0.0;
311  double corr3 = 0.0;
312 
313  switch (num_images)
314  {
315  case 2:
316  {
317  P[1]().initZeros(Xdim,Xdim);
318  P[1]().setXmippOrigin();
319  currentRot = old_rot[1] + deltaRot[1];
320  currentTilt = old_tilt[1] + deltaTilt[1];
321  currentPsi = old_psi[1] + deltaPsi[1];
322  deformVol(P[1](), mV, deformation, currentRot, currentTilt, currentPsi);
323 
324  if (old_flip)
325  {
326  MAT_ELEM(A1, 0, 0) *= -1;
327  MAT_ELEM(A1, 0, 1) *= -1;
328  MAT_ELEM(A1, 0, 2) *= -1;
329  MAT_ELEM(A2, 0, 0) *= -1;
330  MAT_ELEM(A2, 0, 1) *= -1;
331  MAT_ELEM(A2, 0, 2) *= -1;
332  }
334  xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP, 0.);
336  xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP, 0.);
337  // filter.applyMaskSpace(P[1]());
338  const MultidimArray<double> mP2 = P[1]();
339  MultidimArray<double> &mI2filteredp = Ifilteredp[1]();
340  corr2 = correlationIndex(mI2filteredp, mP2, &mMask2D);
341  }
342  break;
343 
344  case 3:
345  {
346  P[1]().initZeros(Xdim,Xdim);
347  P[1]().setXmippOrigin();
348  currentRot = old_rot[1] + deltaRot[1];
349  currentTilt = old_tilt[1] + deltaTilt[1];
350  currentPsi = old_psi[1] + deltaPsi[1];
351  deformVol(P[1](), mV, deformation, currentRot, currentTilt, currentPsi);
352 
353  P[2]().initZeros(Xdim,Xdim);
354  P[2]().setXmippOrigin();
355  currentRot = old_rot[2] + deltaRot[2];
356  currentTilt = old_tilt[2] + deltaTilt[2];
357  currentPsi = old_psi[2] + deltaPsi[2];
358  deformVol(P[2](), mV, deformation, currentRot, currentTilt, currentPsi);
359 
360  if (old_flip)
361  {
362  MAT_ELEM(A1, 0, 0) *= -1;
363  MAT_ELEM(A1, 0, 1) *= -1;
364  MAT_ELEM(A1, 0, 2) *= -1;
365  MAT_ELEM(A2, 0, 0) *= -1;
366  MAT_ELEM(A2, 0, 1) *= -1;
367  MAT_ELEM(A2, 0, 2) *= -1;
368  MAT_ELEM(A3, 0, 0) *= -1;
369  MAT_ELEM(A3, 0, 1) *= -1;
370  MAT_ELEM(A3, 0, 2) *= -1;
371  }
373  xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP, 0.);
375  xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP, 0.);
377  xmipp_transformation::IS_NOT_INV, xmipp_transformation::DONT_WRAP, 0.);
378  // filter.applyMaskSpace(P[1]());
379  // filter.applyMaskSpace(P[2]());
380  const MultidimArray<double> mP2 = P[1]();
381  const MultidimArray<double> mP3 = P[2]();
382  MultidimArray<double> &mI2filteredp = Ifilteredp[1]();
383  MultidimArray<double> &mI3filteredp = Ifilteredp[2]();
384  corr2 = correlationIndex(mI2filteredp, mP2, &mMask2D);
385  corr3 = correlationIndex(mI3filteredp, mP3, &mMask2D);
386  }
387  break;
388 
389  default:
390  if (old_flip)
391  {
392  MAT_ELEM(A1, 0, 0) *= -1;
393  MAT_ELEM(A1, 0, 1) *= -1;
394  MAT_ELEM(A1, 0, 2) *= -1;
395  }
397  xmipp_transformation::IS_NOT_INV,xmipp_transformation::DONT_WRAP,0.);
398  break;
399  }
400 
401  if (hasCTF)
402  {
403  double defocusU=old_defocusU[0]+deltaDefocusU[0];
404  double defocusV=old_defocusV[0]+deltaDefocusV[0];
405  double angle=old_defocusAngle[0]+deltaDefocusAngle[0];
406  if (defocusU!=currentDefocusU[0] || defocusV!=currentDefocusV[0] || angle!=currentAngle[0]) {
407  updateCTFImage(defocusU,defocusV,angle);
408  }
409  FilterCTF1.generateMask(P[0]());
410  if (phaseFlipped)
413  }
414  filter.applyMaskSpace(P[0]());
415 
416 
417  const MultidimArray<double> mP1=P[0]();
418  MultidimArray<double> &mI1filteredp=Ifilteredp[0]();
419  double corr1=correlationIndex(mI1filteredp,mP1,&mMask2D);
420 
421  switch (num_images)
422  {
423  case 2:
424  cost=-(corr1+corr2+corr3) / 2.0;
425  break;
426  case 3:
427  cost=-(corr1+corr2+corr3) / 3.0;
428  break;
429  default:
430  cost=-(corr1+corr2+corr3);
431  break;
432  }
433 
434 #ifdef DEBUG
435  std::cout << "A=" << A << std::endl;
436  Image<double> save;
437  save()=P();
438  save.write("PPPtheo.xmp");
439  save()=Ifilteredp();
440  save.write("PPPfilteredp.xmp");
441  save()=Ifiltered();
442  save.write("PPPfiltered.xmp");
443  // Vdeformed.write("PPPVdeformed.vol");
444  std::cout << "Cost=" << cost << " deformation=" << deformation << std::endl;
445  std::cout << "Press any key" << std::endl;
446  char c; std::cin >> c;
447 #endif
448 
449  if (showOptimization)
450  {
451  std::cout << "A1=" << A1 << std::endl;
452  Image<double> save;
453  save()=P[0]();
454  save.write("PPPtheo1.xmp");
455  save()=Ifilteredp[0]();
456  save.write("PPPfilteredp1.xmp");
457  save()=Ifiltered[0]();
458  save.write("PPPfiltered1.xmp");
459 
460  switch (num_images)
461  {
462  case 2:
463  {
464  std::cout << "A2=" << A2 << std::endl;
465  save()=P[1]();
466  save.write("PPPtheo2.xmp");
467  save()=Ifilteredp[1]();
468  save.write("PPPfilteredp2.xmp");
469  save()=Ifiltered[1]();
470  save.write("PPPfiltered2.xmp");
471  }
472  break;
473 
474  case 3:
475  {
476  std::cout << "A2=" << A2 << std::endl;
477  save()=P[1]();
478  save.write("PPPtheo2.xmp");
479  save()=Ifilteredp[1]();
480  save.write("PPPfilteredp2.xmp");
481  save()=Ifiltered[1]();
482  save.write("PPPfiltered2.xmp");
483 
484  std::cout << "A3=" << A3 << std::endl;
485  save()=P[2]();
486  save.write("PPPtheo3.xmp");
487  save()=Ifilteredp[2]();
488  save.write("PPPfilteredp3.xmp");
489  save()=Ifiltered[2]();
490  save.write("PPPfiltered3.xmp");
491  }
492  break;
493 
494  default:
495  break;
496  }
497  Vdeformed.write("PPPVdeformed.vol");
498  std::cout << "Deformation=" << totalDeformation << std::endl;
499  std::cout << "Press any key" << std::endl;
500  char c; std::cin >> c;
501  }
502 
503  double bound = 1.0;
504  double sum = 0.0;
505  for (int i=0; i < priors.size(); i++) {
506  sum += c_priors[i];
507  if (c_priors[i] < 0.0)
508  {
509  bound = 0.0;
510  break;
511  }
512  }
513 
514  if (sum > 1.0 && bound == 1.0)
515  bound = 0.0;
516 
517  if (showOptimization)
518  std::cout << cost << " " << deformation << std::endl;
519  return bound * cost + lambda * abs(deformation - prior_deformation);
520 }
std::vector< Image< double > > Ifiltered
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
doublereal * c
void applyGeometry(int SplineDegree, MultidimArray< std::complex< double > > &V2, const MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside, MultidimArray< double > *BcoeffsPtr)
std::vector< std::vector< double > > priors
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)
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
void abs(Image< double > &op)
#define i
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72
std::vector< Image< double > > Ifilteredp
void generateMask(MultidimArray< double > &v)
void updateCTFImage(double defocusU, double defocusV, double angle)
void deformVol(MultidimArray< double > &mVD, const MultidimArray< double > &mV, double &def, double rot, double tilt, double psi)
Deform a volumen using Zernike-Spherical harmonic basis.
void applyMaskSpace(MultidimArray< double > &v)

◆ updateCTFImage()

void ProgForwardZernikeImagesPriors::updateCTFImage ( double  defocusU,
double  defocusV,
double  angle 
)

Definition at line 960 of file forward_zernike_images_priors.cpp.

961 {
962  FilterCTF1.ctf.K=1; // get pure CTF with no envelope
967 }
CTFDescription ctf
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
double K
Global gain. By default, 1.
Definition: ctf.h:238
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392

◆ weightsInterpolation3D()

Matrix1D< double > ProgForwardZernikeImagesPriors::weightsInterpolation3D ( double  x,
double  y,
double  z 
)

Definition at line 1045 of file forward_zernike_images_priors.cpp.

1045  {
1047  w.initZeros(8);
1048 
1049  int x0 = FLOOR(x);
1050  double fx0 = x - x0;
1051  int x1 = x0 + 1;
1052  double fx1 = x1 - x;
1053 
1054  int y0 = FLOOR(y);
1055  double fy0 = y - y0;
1056  int y1 = y0 + 1;
1057  double fy1 = y1 - y;
1058 
1059  int z0 = FLOOR(z);
1060  double fz0 = z - z0;
1061  int z1 = z0 + 1;
1062  double fz1 = z1 - z;
1063 
1064  VEC_ELEM(w,0) = fx1 * fy1 * fz1; // w000 (x0,y0,z0)
1065  VEC_ELEM(w,1) = fx1 * fy1 * fz0; // w001 (x0,y0,z1)
1066  VEC_ELEM(w,2) = fx1 * fy0 * fz1; // w010 (x0,y1,z0)
1067  VEC_ELEM(w,3) = fx1 * fy0 * fz0; // w011 (x0,y1,z1)
1068  VEC_ELEM(w,4) = fx0 * fy1 * fz1; // w100 (x1,y0,z0)
1069  VEC_ELEM(w,5) = fx0 * fy1 * fz0; // w101 (x1,y0,z1)
1070  VEC_ELEM(w,6) = fx0 * fy0 * fz1; // w110 (x1,y1,z0)
1071  VEC_ELEM(w,7) = fx0 * fy0 * fz0; // w111 (x1,y1,z1)
1072 
1073  return w;
1074 }
#define VEC_ELEM(v, i)
Definition: matrix1d.h:245
static double * y
doublereal * w
#define z0
doublereal * x
#define FLOOR(x)
Definition: xmipp_macros.h:240
#define y0
#define x0
double z
void initZeros()
Definition: matrix1d.h:592

◆ writeImageParameters()

void ProgForwardZernikeImagesPriors::writeImageParameters ( MDRow row)
virtual

Write the parameters found for one image

Definition at line 844 of file forward_zernike_images_priors.cpp.

844  {
845  int pos = priors.size();
846  if (flagEnabled==1) {
847  row.setValue(MDL_ENABLED, 1);
848  }
849  else {
850  row.setValue(MDL_ENABLED, -1);
851  }
852 
853  switch (num_images)
854  {
855  case 2:
856  row.setValue(MDL_ANGLE_ROT, old_rot[0]+p(pos+4));
857  row.setValue(MDL_ANGLE_ROT2, old_rot[1]+p(pos+5));
858  row.setValue(MDL_ANGLE_TILT, old_tilt[0]+p(pos+6));
859  row.setValue(MDL_ANGLE_TILT2, old_tilt[1]+p(pos+7));
860  row.setValue(MDL_ANGLE_PSI, old_psi[0]+p(pos+8));
861  row.setValue(MDL_ANGLE_PSI2, old_psi[1]+p(pos+9));
862  row.setValue(MDL_SHIFT_X, old_shiftX[0]+p(pos));
863  row.setValue(MDL_SHIFT_X2, old_shiftX[1]+p(pos+1));
864  row.setValue(MDL_SHIFT_Y, old_shiftY[0]+p(pos+2));
865  row.setValue(MDL_SHIFT_Y2, old_shiftY[1]+p(pos+3));
866  break;
867 
868  case 3:
869  row.setValue(MDL_ANGLE_ROT, old_rot[0]+p(pos+6));
870  row.setValue(MDL_ANGLE_ROT2, old_rot[1]+p(pos+7));
871  row.setValue(MDL_ANGLE_ROT3, old_rot[2]+p(pos+8));
872  row.setValue(MDL_ANGLE_TILT, old_tilt[0]+p(pos+9));
873  row.setValue(MDL_ANGLE_TILT2, old_tilt[1]+p(pos+10));
874  row.setValue(MDL_ANGLE_TILT3, old_tilt[2]+p(pos+11));
875  row.setValue(MDL_ANGLE_PSI, old_psi[0]+p(pos+12));
876  row.setValue(MDL_ANGLE_PSI2, old_psi[1]+p(pos+13));
877  row.setValue(MDL_ANGLE_PSI3, old_psi[2]+p(pos+14));
878  row.setValue(MDL_SHIFT_X, old_shiftX[0]+p(pos));
879  row.setValue(MDL_SHIFT_X2, old_shiftX[1]+p(pos+1));
880  row.setValue(MDL_SHIFT_X3, old_shiftX[2]+p(pos+2));
881  row.setValue(MDL_SHIFT_Y, old_shiftY[0]+p(pos+3));
882  row.setValue(MDL_SHIFT_Y2, old_shiftY[1]+p(pos+4));
883  row.setValue(MDL_SHIFT_Y3, old_shiftY[2]+p(pos+5));
884  break;
885 
886  default:
887  row.setValue(MDL_ANGLE_ROT, old_rot[0]+p(pos+2));
888  row.setValue(MDL_ANGLE_TILT, old_tilt[0]+p(pos+3));
889  row.setValue(MDL_ANGLE_PSI, old_psi[0]+p(pos+4));
890  row.setValue(MDL_SHIFT_X, old_shiftX[0]+p(pos));
891  row.setValue(MDL_SHIFT_Y, old_shiftY[0]+p(pos+1));
892  break;
893  }
894 
896  std::vector<double> vectortemp;
897  size_t end_clnm = VEC_XSIZE(clnm);
898  for (int j = 0; j < end_clnm; j++) {
899  vectortemp.push_back(clnm(j));
900  }
901  row.setValue(MDL_SPH_COEFFICIENTS, vectortemp);
903 }
Rotation angle of an image (double,degrees)
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
Shift for the image in the Y axis (double)
#define VEC_XSIZE(m)
Definition: matrix1d.h:77
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
std::vector< std::vector< double > > priors
Tilting angle of an image (double,degrees)
Special label to be used when gathering MDs in MpiMetadataPrograms.
Is this image enabled? (int [-1 or 1])
Shift for the image in the Y axis (double)
Rotation angle of an image (double,degrees)
Deformation in voxels.
Cost for the image (double)
Psi angle of an image (double,degrees)
#define j
void setValue(MDLabel label, const T &d, bool addLabel=true)
Shift for the image in the X axis (double)
Deformation coefficients.
Rotation angle of an image (double,degrees)
Shift for the image in the Y axis (double)
Psi angle of an image (double,degrees)

Member Data Documentation

◆ A1

Matrix2D<double> ProgForwardZernikeImagesPriors::A1

Definition at line 114 of file forward_zernike_images_priors.h.

◆ A2

Matrix2D<double> ProgForwardZernikeImagesPriors::A2

Definition at line 114 of file forward_zernike_images_priors.h.

◆ A3

Matrix2D<double> ProgForwardZernikeImagesPriors::A3

Definition at line 114 of file forward_zernike_images_priors.h.

◆ algn_params

int ProgForwardZernikeImagesPriors::algn_params

Definition at line 85 of file forward_zernike_images_priors.h.

◆ blob

struct blobtype ProgForwardZernikeImagesPriors::blob

Definition at line 149 of file forward_zernike_images_priors.h.

◆ blob_r

double ProgForwardZernikeImagesPriors::blob_r

Definition at line 150 of file forward_zernike_images_priors.h.

◆ c_priors

Matrix1D<double> ProgForwardZernikeImagesPriors::c_priors

Definition at line 134 of file forward_zernike_images_priors.h.

◆ clnm

Matrix1D<double> ProgForwardZernikeImagesPriors::clnm

Definition at line 136 of file forward_zernike_images_priors.h.

◆ correlation

double ProgForwardZernikeImagesPriors::correlation

Definition at line 145 of file forward_zernike_images_priors.h.

◆ ctf_params

int ProgForwardZernikeImagesPriors::ctf_params

Definition at line 87 of file forward_zernike_images_priors.h.

◆ currentAngle

std::vector<double> ProgForwardZernikeImagesPriors::currentAngle

Definition at line 126 of file forward_zernike_images_priors.h.

◆ currentDefocusU

std::vector<double> ProgForwardZernikeImagesPriors::currentDefocusU

Definition at line 126 of file forward_zernike_images_priors.h.

◆ currentDefocusV

std::vector<double> ProgForwardZernikeImagesPriors::currentDefocusV

Definition at line 126 of file forward_zernike_images_priors.h.

◆ deltaDefocusAngle

std::vector<double> ProgForwardZernikeImagesPriors::deltaDefocusAngle

Definition at line 124 of file forward_zernike_images_priors.h.

◆ deltaDefocusU

std::vector<double> ProgForwardZernikeImagesPriors::deltaDefocusU

Definition at line 124 of file forward_zernike_images_priors.h.

◆ deltaDefocusV

std::vector<double> ProgForwardZernikeImagesPriors::deltaDefocusV

Definition at line 124 of file forward_zernike_images_priors.h.

◆ deltaPsi

std::vector<double> ProgForwardZernikeImagesPriors::deltaPsi

Definition at line 116 of file forward_zernike_images_priors.h.

◆ deltaRot

std::vector<double> ProgForwardZernikeImagesPriors::deltaRot

Definition at line 116 of file forward_zernike_images_priors.h.

◆ deltaTilt

std::vector<double> ProgForwardZernikeImagesPriors::deltaTilt

Definition at line 116 of file forward_zernike_images_priors.h.

◆ deltaX

std::vector<double> ProgForwardZernikeImagesPriors::deltaX

Definition at line 118 of file forward_zernike_images_priors.h.

◆ deltaY

std::vector<double> ProgForwardZernikeImagesPriors::deltaY

Definition at line 118 of file forward_zernike_images_priors.h.

◆ do_not_init

bool ProgForwardZernikeImagesPriors::do_not_init

Definition at line 151 of file forward_zernike_images_priors.h.

◆ filter

FourierFilter ProgForwardZernikeImagesPriors::filter

Definition at line 112 of file forward_zernike_images_priors.h.

◆ FilterCTF1

FourierFilter ProgForwardZernikeImagesPriors::FilterCTF1

Definition at line 128 of file forward_zernike_images_priors.h.

◆ FilterCTF2

FourierFilter ProgForwardZernikeImagesPriors::FilterCTF2

Definition at line 129 of file forward_zernike_images_priors.h.

◆ FilterCTF3

FourierFilter ProgForwardZernikeImagesPriors::FilterCTF3

Definition at line 130 of file forward_zernike_images_priors.h.

◆ flagEnabled

int ProgForwardZernikeImagesPriors::flagEnabled

Definition at line 89 of file forward_zernike_images_priors.h.

◆ fnImage

std::vector<FileName> ProgForwardZernikeImagesPriors::fnImage

Definition at line 103 of file forward_zernike_images_priors.h.

◆ fnMaskR

FileName ProgForwardZernikeImagesPriors::fnMaskR

Filename of the reference volume mask

Definition at line 49 of file forward_zernike_images_priors.h.

◆ fnOutDir

FileName ProgForwardZernikeImagesPriors::fnOutDir

Output directory.

Definition at line 53 of file forward_zernike_images_priors.h.

◆ fnPriors

FileName ProgForwardZernikeImagesPriors::fnPriors

List of priors (deformation coefficients)

Definition at line 51 of file forward_zernike_images_priors.h.

◆ fnVolR

FileName ProgForwardZernikeImagesPriors::fnVolR

Filename of the reference volume

Definition at line 47 of file forward_zernike_images_priors.h.

◆ hasCTF

bool ProgForwardZernikeImagesPriors::hasCTF

Definition at line 122 of file forward_zernike_images_priors.h.

◆ I

std::vector<Image<double> > ProgForwardZernikeImagesPriors::I

Definition at line 106 of file forward_zernike_images_priors.h.

◆ Ifiltered

std::vector<Image<double> > ProgForwardZernikeImagesPriors::Ifiltered

Definition at line 107 of file forward_zernike_images_priors.h.

◆ Ifilteredp

std::vector<Image<double> > ProgForwardZernikeImagesPriors::Ifilteredp

Definition at line 108 of file forward_zernike_images_priors.h.

◆ ignoreCTF

bool ProgForwardZernikeImagesPriors::ignoreCTF

Definition at line 73 of file forward_zernike_images_priors.h.

◆ image_mode

int ProgForwardZernikeImagesPriors::image_mode

Definition at line 90 of file forward_zernike_images_priors.h.

◆ L1

int ProgForwardZernikeImagesPriors::L1

Degrees of Zernike polynomials and spherical harmonics

Definition at line 55 of file forward_zernike_images_priors.h.

◆ L2

int ProgForwardZernikeImagesPriors::L2

Definition at line 55 of file forward_zernike_images_priors.h.

◆ lambda

double ProgForwardZernikeImagesPriors::lambda

Definition at line 79 of file forward_zernike_images_priors.h.

◆ loop_step

int ProgForwardZernikeImagesPriors::loop_step

Definition at line 147 of file forward_zernike_images_priors.h.

◆ mask2D

MultidimArray<int> ProgForwardZernikeImagesPriors::mask2D

Definition at line 97 of file forward_zernike_images_priors.h.

◆ maxAngularChange

double ProgForwardZernikeImagesPriors::maxAngularChange

Maximum angular change allowed

Definition at line 61 of file forward_zernike_images_priors.h.

◆ maxResol

double ProgForwardZernikeImagesPriors::maxResol

Maximum frequency (A)

Definition at line 63 of file forward_zernike_images_priors.h.

◆ maxShift

double ProgForwardZernikeImagesPriors::maxShift

Maximum shift allowed

Definition at line 59 of file forward_zernike_images_priors.h.

◆ num_images

int ProgForwardZernikeImagesPriors::num_images

Definition at line 83 of file forward_zernike_images_priors.h.

◆ old_defocusAngle

std::vector<double> ProgForwardZernikeImagesPriors::old_defocusAngle

Definition at line 124 of file forward_zernike_images_priors.h.

◆ old_defocusU

std::vector<double> ProgForwardZernikeImagesPriors::old_defocusU

Definition at line 124 of file forward_zernike_images_priors.h.

◆ old_defocusV

std::vector<double> ProgForwardZernikeImagesPriors::old_defocusV

Definition at line 124 of file forward_zernike_images_priors.h.

◆ old_flip

bool ProgForwardZernikeImagesPriors::old_flip

Definition at line 120 of file forward_zernike_images_priors.h.

◆ old_psi

std::vector<double> ProgForwardZernikeImagesPriors::old_psi

Definition at line 116 of file forward_zernike_images_priors.h.

◆ old_rot

std::vector<double> ProgForwardZernikeImagesPriors::old_rot

Definition at line 116 of file forward_zernike_images_priors.h.

◆ old_shiftX

std::vector<double> ProgForwardZernikeImagesPriors::old_shiftX

Definition at line 118 of file forward_zernike_images_priors.h.

◆ old_shiftY

std::vector<double> ProgForwardZernikeImagesPriors::old_shiftY

Definition at line 118 of file forward_zernike_images_priors.h.

◆ old_tilt

std::vector<double> ProgForwardZernikeImagesPriors::old_tilt

Definition at line 116 of file forward_zernike_images_priors.h.

◆ optimizeAlignment

bool ProgForwardZernikeImagesPriors::optimizeAlignment

Definition at line 69 of file forward_zernike_images_priors.h.

◆ optimizeDefocus

bool ProgForwardZernikeImagesPriors::optimizeDefocus

Definition at line 71 of file forward_zernike_images_priors.h.

◆ optimizeRadius

bool ProgForwardZernikeImagesPriors::optimizeRadius

Definition at line 75 of file forward_zernike_images_priors.h.

◆ p

Matrix1D<double> ProgForwardZernikeImagesPriors::p

Definition at line 88 of file forward_zernike_images_priors.h.

◆ P

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

Definition at line 110 of file forward_zernike_images_priors.h.

◆ phaseFlipped

bool ProgForwardZernikeImagesPriors::phaseFlipped

Definition at line 77 of file forward_zernike_images_priors.h.

◆ prior_deformation

double ProgForwardZernikeImagesPriors::prior_deformation

Definition at line 140 of file forward_zernike_images_priors.h.

◆ prior_deformations

std::vector<double> ProgForwardZernikeImagesPriors::prior_deformations

Definition at line 141 of file forward_zernike_images_priors.h.

◆ priors

std::vector<std::vector<double> > ProgForwardZernikeImagesPriors::priors

Vector containing the priors

Definition at line 99 of file forward_zernike_images_priors.h.

◆ resume

bool ProgForwardZernikeImagesPriors::resume

Resume computations

Definition at line 95 of file forward_zernike_images_priors.h.

◆ Rmax

int ProgForwardZernikeImagesPriors::Rmax

Maximum radius

Definition at line 67 of file forward_zernike_images_priors.h.

◆ RmaxDef

int ProgForwardZernikeImagesPriors::RmaxDef

Definition at line 81 of file forward_zernike_images_priors.h.

◆ showOptimization

bool ProgForwardZernikeImagesPriors::showOptimization

Definition at line 143 of file forward_zernike_images_priors.h.

◆ steps_cp

Matrix1D<double> ProgForwardZernikeImagesPriors::steps_cp

Definition at line 138 of file forward_zernike_images_priors.h.

◆ totalDeformation

double ProgForwardZernikeImagesPriors::totalDeformation

Definition at line 140 of file forward_zernike_images_priors.h.

◆ Ts

double ProgForwardZernikeImagesPriors::Ts

Sampling rate

Definition at line 65 of file forward_zernike_images_priors.h.

◆ useCTF

bool ProgForwardZernikeImagesPriors::useCTF

Definition at line 91 of file forward_zernike_images_priors.h.

◆ V

Image<double> ProgForwardZernikeImagesPriors::V

Definition at line 105 of file forward_zernike_images_priors.h.

◆ V_mask

MultidimArray<int> ProgForwardZernikeImagesPriors::V_mask

Definition at line 97 of file forward_zernike_images_priors.h.

◆ Vdeformed

Image<double> ProgForwardZernikeImagesPriors::Vdeformed

Definition at line 105 of file forward_zernike_images_priors.h.

◆ vecSize

int ProgForwardZernikeImagesPriors::vecSize

Definition at line 132 of file forward_zernike_images_priors.h.

◆ vL1

Matrix1D<int> ProgForwardZernikeImagesPriors::vL1

Zernike and SPH coefficients vectors

Definition at line 57 of file forward_zernike_images_priors.h.

◆ vL2

Matrix1D<int> ProgForwardZernikeImagesPriors::vL2

Definition at line 57 of file forward_zernike_images_priors.h.

◆ vM

Matrix1D<int> ProgForwardZernikeImagesPriors::vM

Definition at line 57 of file forward_zernike_images_priors.h.

◆ vN

Matrix1D<int> ProgForwardZernikeImagesPriors::vN

Definition at line 57 of file forward_zernike_images_priors.h.

◆ Xdim

size_t ProgForwardZernikeImagesPriors::Xdim

Definition at line 101 of file forward_zernike_images_priors.h.


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