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

#include <angular_resolution_alignment.h>

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

Public Member Functions

void defineParams ()
 
void readParams ()
 
void run ()
 
- 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)
 
virtual void initComments ()
 
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 show () 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 ()
 

Additional Inherited Members

- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- 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

Definition at line 36 of file angular_resolution_alignment.h.

Member Function Documentation

◆ defineParams()

void ProgAngResAlign::defineParams ( )
virtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 34 of file angular_resolution_alignment.cpp.

35 {
36  addUsageLine("This algorithm estimates the existence of angular alignment errors by measuring a set of directional FSC.");
37  addUsageLine("To do that, the method only makes use of two half maps, but it does not use the set of particles.");
38  addUsageLine("The result is a plot resolution-radius. When this plot presents a slope the map has angular assignment error.");
39  addUsageLine("In contrast, if the curve is flat, the map is error free or there is shift errors in the particle alignment.");
40  addUsageLine("Reference: J.L. Vilas, et. al, XXXXX (2023)");
41  addUsageLine("+ The optimal con angle is 17 degree.", true);
42  addUsageLine(" This fact was proved in J.L Vilas & H.D. Tagare Nat. Meth 2023. Other values can be used,");
43  addUsageLine(" and this parameter does not seems to affect in a significative manner");
44  addUsageLine("+* On the helix", true);
45  addUsageLine(" If the map is a helix, the helix option should be activated. This option ensures a better estimation of the angular");
46  addUsageLine(" assignment errors. The helix is assumen that is oriented along the z-axis. This flag modifies the shape of the ");
47  addUsageLine("gaussian mask usign a cylinder.");
48  addUsageLine(" ");
49  addUsageLine(" ");
50  addSeeAlsoLine("resolution_fsc");
51 
52  addParamsLine(" --half1 <input_file> : Input Half map 1");
53  addParamsLine(" --half2 <input_file> : Input Half map 2");
54  addParamsLine(" [--directional_resolution] : (Optional) Uses direcitonal FSC instead of global FSC shell ");
55  addParamsLine(" [--limit_radius] : (Optional) Limits the maximum radius ");
56 
57  addParamsLine(" [-o <output_folder=\"\">] : Folder where the results will be stored.");
58 
59  addParamsLine(" [--sampling <Ts=1>] : (Optical) Pixel size (Angstrom). If it is not provided by default will be 1 A/px.");
60  addParamsLine(" [--mask <input_file=\"\">] : (Optional) Smooth mask to remove noise. If it is not provided, the computation will be carried out without mask.");
61 
62  addParamsLine(" [--anglecone <ang_con=17>] : (Optional) Angle Cone (angle between the axis and the generatrix) for estimating the directional FSC");
63  addParamsLine(" [--threshold <thrs=0.143>] : (Optional) Threshold for the FSC/directionalFSC estimation ");
64  addParamsLine(" [--helix] : (Optional) If the reconstruction is a helix put this flag. The axis of the helix must be along the z-axis");
65  addParamsLine(" [--threads <Nthreads=1>] : (Optional) Number of threads to be used");
66 
67  addExampleLine("Resolution of two half maps half1.mrc and half2.mrc with a sampling rate of 2 A/px", false);
68  addExampleLine("xmipp_angular_resolution_alignment --half1 half1.mrc --half2 half2.mrc --sampling 2 ");
69  addExampleLine("Resolution of two half maps half1.mrc and half2.mrc with a sampling rate of 2 A/px and a mask mask.mrc", false);
70  addExampleLine("xmipp_angular_resolution_alignment --half1 half1.mrc --half2 half2.mrc --mask mask.mrc --sampling 2 ");
71 }
void addSeeAlsoLine(const char *seeAlso)
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgAngResAlign::readParams ( )
virtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from XmippProgram.

Definition at line 73 of file angular_resolution_alignment.cpp.

74 {
75  fnhalf1 = getParam("--half1");
76  fnhalf2 = getParam("--half2");
77  fnOut = getParam("-o");
78 
79  sampling = getDoubleParam("--sampling");
80  fnmask = getParam("--mask");
81  directionalRes = checkParam("--directional_resolution");
82  limRad = checkParam("--limit_radius");
83  isHelix = checkParam("--helix");
84  ang_con = getDoubleParam("--anglecone");
85  thrs = getDoubleParam("--threshold");
86 
87  Nthreads = getIntParam("--threads");
88 }
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
FileName fnOut
#define sampling
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgAngResAlign::run ( )
virtual

This function will be start running the program. it also should be implemented by derived classes.

Reimplemented from XmippProgram.

Definition at line 1068 of file angular_resolution_alignment.cpp.

1069  {
1070  std::cout << "Starting ... " << std::endl << std::endl;
1071 
1072  //This read the data and applies a fftshift to in the next step compute the fft
1073  // The maps half1_aux, and half2_aux are used to recover the initial maps after masking in each iteration
1074  MultidimArray<double> half1, half2;
1075  MultidimArray<double> &phalf1 = half1, &phalf2 = half2;
1076  readData(phalf1, phalf2);
1077 
1078  // Defining frequencies freq_fourier_x,y,z and freqMap
1079  // The number of frequencies in each shell freqElem is determined
1080  defineFrequenciesSimple(phalf1);
1081 
1082  //Define shell Mask
1083  MultidimArray<double> shellMask;
1084  shellMask.resizeNoCopy(phalf1);
1085 
1086  // Generating the set of directions to be analyzed
1087  // And converting the cone angle to radians
1088  generateDirections(angles, false);
1089  ang_con = ang_con*PI/180.0;
1090 
1091  MultidimArray<double> half1_aux;
1092  MultidimArray<double> half2_aux;
1093 
1094  //Generate shell mask and computing radial resolution
1095 
1096  MetaDataVec mdOut;
1097 
1098  //std::cout << "max radius = " << maxRadius << std::endl;
1099 
1100  for (size_t shellRadius = 0; shellRadius<maxRadius; shellRadius++)
1101  {
1102  shellMask.initZeros();
1103  shellMask.setXmippOrigin();
1104  generateShellMask(shellMask, shellRadius, isHelix);
1105 
1106  // Image<double> img;
1107  // img() = shellMask;
1108  // FileName fn;
1109  // fn = formatString("mk_%i.mrc", shellRadius);
1110  // img.write(fn);
1111 
1112  applyShellMask(half1, half2, shellMask, half1_aux, half2_aux);
1113 
1114  //Computing the FFT
1115  FourierTransformer transformer2(FFTW_BACKWARD), transformer1(FFTW_BACKWARD);
1116  //transformer1.setThreadsNumber(Nthreads);
1117  //transformer2.setThreadsNumber(Nthreads);
1118 
1119  transformer1.FourierTransform(half1_aux, FT1, false);
1120  transformer2.FourierTransform(half2_aux, FT2, false);
1121 
1122  // Storing the shell of both maps as vectors global
1123  // The global FSC is also computed
1124 
1125  arrangeFSC_and_fscGlobal();
1126 
1127 
1128  double res;
1129  if (directionalRes)
1130  {
1131  std::vector<double> radialResolution(angles.mdimx);
1132 
1133  for (size_t k = 0; k<angles.mdimx; k++)
1134  {
1135  float rot = MAT_ELEM(angles, 0, k);
1136  float tilt = MAT_ELEM(angles, 1, k);
1137 
1138  double resInterp = -1;
1140 
1141  // Estimating the direction FSC along the direction given by rot and tilt
1142  fscDir_fast(fsc, rot, tilt, thrs, resInterp);
1143 
1144  radialResolution[k] = resInterp;
1145  }
1146 
1147  std::sort(radialResolution.begin(),radialResolution.end());
1148 
1149  res = radialResolution[round(0.5*angles.mdimx)];
1150  radialResolution.clear();
1151  }
1152  else
1153  {
1154  fscGlobal(thrs, res);
1155  }
1156 
1157  std::cout << "Radius "<< shellRadius << "/" << maxRadius << " " << res << "A" << std::endl;
1158 
1159  MDRowVec row;
1160  row.setValue(MDL_RESOLUTION_FRC, res);
1161  row.setValue(MDL_IDX, shellRadius);
1162  mdOut.addRow(row);
1163 
1164  }
1165 
1166  mdOut.write(fnOut);
1167 }
void resizeNoCopy(const MultidimArray< T1 > &v)
void setValue(const MDObject &object) override
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
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
size_t addRow(const MDRow &row) override
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
FileName fnOut
void sort(struct DCEL_T *dcel)
Definition: sorting.cpp:18
int round(double x)
Definition: ap.cpp:7245
Index within a list (size_t)
size_t mdimx
Definition: matrix2d.h:410
void initZeros(const MultidimArray< T1 > &op)
#define PI
Definition: tools.h:43
Fourier shell correlation (double)

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