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

#include <project.h>

Collaboration diagram for ParametersProjection:
Collaboration graph
[legend]

Public Member Functions

 ParametersProjection ()
 
void from_prog_params (const ProgProject &prog_prm)
 
void read (const FileName &fn_proj_param)
 

Public Attributes

int proj_Xdim
 Projection Xdim. More...
 
int proj_Ydim
 Projection Ydim. More...
 
int tell
 Debugging level. More...
 
bool enable_angle_range
 Enable angle range mode (0 or 1) More...
 
Angle_range rot_range
 Rotational angle range. More...
 
Angle_range tilt_range
 Tilting angle range. More...
 
Angle_range psi_range
 Psi angle range. More...
 
bool doPhaseFlip
 
bool applyShift
 
bool doCTFCorrection
 
FileName fn_angle
 Document filename. More...
 
double Npixel_avg
 Bias to be applied to each pixel grey value */. More...
 
double Npixel_dev
 Standard deviation of the noise to be added to each pixel grey value. More...
 
double Ncenter_avg
 Bias to apply to the image center. More...
 
double Ncenter_dev
 Standard deviation of the image center. More...
 

Detailed Description

Projecting parameters. This class reads a set of projection parameters in a file (see the user help for xmipp_project for more information about the file structure) and extract the useful information from it. This class allows also to write in the same file format, for doing so you must first introduce the right values in the class fields, and the call to the procedure write

Definition at line 157 of file project.h.

Constructor & Destructor Documentation

◆ ParametersProjection()

ParametersProjection::ParametersProjection ( )

Definition at line 204 of file project.cpp.

205 {
206  Npixel_avg=0.;
207  Npixel_dev=0.;
208  Ncenter_avg=0.;
209  Ncenter_dev=0.;
210  rot_range.Navg = 0.;
211  rot_range.Ndev=0.;
212  tilt_range.Navg=0.;
213  tilt_range.Ndev=0.;
214  psi_range.Navg=0.;
215  psi_range.Ndev=0.;
216  doPhaseFlip=false;
217  applyShift=true;
218 }
double Ndev
Stddev of the noise that must be added to the definition of the angle.
Definition: project.h:145
Angle_range psi_range
Psi angle range.
Definition: project.h:175
Angle_range tilt_range
Tilting angle range.
Definition: project.h:173
double Npixel_avg
Bias to be applied to each pixel grey value */.
Definition: project.h:188
double Ncenter_avg
Bias to apply to the image center.
Definition: project.h:193
Angle_range rot_range
Rotational angle range.
Definition: project.h:171
double Ncenter_dev
Standard deviation of the image center.
Definition: project.h:195
double Navg
Mean of the noise that must be added to the definition of the angle.
Definition: project.h:143
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: project.h:190

Member Function Documentation

◆ from_prog_params()

void ParametersProjection::from_prog_params ( const ProgProject prog_prm)

From Program Parameters. This function loads the Projection Parameters from the parameters given to the program (PROJECT).

Definition at line 183 of file project.cpp.

184 {
185  read(prog_prm.fn_proj_param);
186 }
FileName fn_proj_param
Filename with the Projection_Parameters.
Definition: project.h:49
void read(const FileName &fn_proj_param)
Definition: project.cpp:220

◆ read()

void ParametersProjection::read ( const FileName fn_proj_param)

Read projection parameters from a file. An exception is thrown if the file is not found or any of the parameters is not found in the right place.

Definition at line 220 of file project.cpp.

221 {
222 
223  if (fn_proj_param.isMetaData())
224  {
225  MetaDataVec MD;
226  MD.read(fn_proj_param);
227  //if X and Y those not exists add them
228  if (!MD.containsLabel(MDL_SHIFT_X))
229  MD.addLabel(MDL_SHIFT_X);
230  if (!MD.containsLabel(MDL_SHIFT_Y))
231  MD.addLabel(MDL_SHIFT_Y);
232  if (MD.isEmpty())
234  (String)"Prog_Project_Parameters::read: There is a problem "
235  "opening the file " + fn_proj_param);
236 
237  std::vector <double> ParamVec;
238  std::string RandStr;
239  char * RandChar;
240  size_t objId;
241 
242  // Read data from the MetaData
243  objId = MD.firstRowId();
244  MD.getValue(MDL_DIMENSIONS_2D, ParamVec, objId);
245  proj_Xdim = (int)ParamVec[0];
246  proj_Ydim = (int)ParamVec[1];
247  if (!MD.getValue(MDL_PRJ_ANGFILE, fn_angle, objId))
248  fn_angle = "NULL";
249  else if (fn_angle != "NULL")
250  if (!fn_angle.exists())
251  REPORT_ERROR(ERR_IO_NOTEXIST, (String)"Prog_Project_Parameters::read: "
252  "file " + fn_angle + " doesn't exist");
253  else
254  {
259  MD.getValue(MDL_APPLY_SHIFT, applyShift, objId);
260  }
261 
262  if (MD.getValue(MDL_PRJ_ROT_RANGE,ParamVec, objId))
263  {
264  enable_angle_range = true;
265  rot_range.ang0 = ParamVec[0];
266  if (ParamVec.size() == 1)
267  {
269  rot_range.samples = 1;
270  }
271  else
272  {
273  rot_range.angF = ParamVec[1];
274  rot_range.samples = (int)ParamVec[2];
275  if (rot_range.ang0 == rot_range.angF)
276  rot_range.samples = 1;
277  }
278  if (!MD.getValue(MDL_PRJ_ROT_RANDSTR,RandStr,objId))
280  else
281  {
282  RandChar = new char[RandStr.length() + 1];
283  strcpy(RandChar, RandStr.c_str());
285  }
286  MD.getValue(MDL_PRJ_TILT_RANGE,ParamVec, objId);
287  tilt_range.ang0 = ParamVec[0];
288  if (ParamVec.size() == 1)
289  {
291  tilt_range.samples = 1;
292  }
293  else
294  {
295  tilt_range.angF = ParamVec[1];
296  tilt_range.samples = (int)ParamVec[2];
298  tilt_range.samples = 1;
299  }
300  if (!MD.getValue(MDL_PRJ_TILT_RANDSTR,RandStr,objId))
302  else
303  {
304  RandChar = new char[RandStr.length() + 1];
305  strcpy(RandChar, RandStr.c_str());
307  }
308  MD.getValue(MDL_PRJ_PSI_RANGE,ParamVec, objId);
309  psi_range.ang0 = ParamVec[0];
310  if (ParamVec.size() == 1)
311  {
313  psi_range.samples = 1;
314  }
315  else
316  {
317  psi_range.angF = ParamVec[1];
318  psi_range.samples = (int)ParamVec[2];
319  if (psi_range.ang0 == psi_range.angF)
320  psi_range.samples = 1;
321  }
322  if (!MD.getValue(MDL_PRJ_PSI_RANDSTR,RandStr,objId))
324  else
325  {
326  RandChar = new char[RandStr.length() + 1];
327  strcpy(RandChar, RandStr.c_str());
329  }
330  }
331  else
332  enable_angle_range = false;
333 
334  if(MD.getValue(MDL_PRJ_ROT_NOISE,ParamVec, objId))
335  {
336  rot_range.Ndev = ParamVec[0];
337  if (ParamVec.size()<2)
338  rot_range.Navg = 0;
339  else
340  rot_range.Navg = ParamVec[1];
341  }
342  else
344 
345  if(MD.getValue(MDL_PRJ_TILT_NOISE,ParamVec, objId))
346  {
347  tilt_range.Ndev = ParamVec[0];
348  if (ParamVec.size()<2)
349  tilt_range.Navg = 0;
350  else
351  tilt_range.Navg = ParamVec[1];
352  }
353  else
355 
356  if(MD.getValue(MDL_PRJ_PSI_NOISE,ParamVec, objId))
357  {
358  psi_range.Ndev = ParamVec[0];
359  if (ParamVec.size()<2)
360  psi_range.Navg = 0;
361  else
362  psi_range.Navg = ParamVec[1];
363  }
364  else
366 
367  if(MD.getValue(MDL_NOISE_PIXEL_LEVEL,ParamVec, objId))
368  {
369  Npixel_dev = ParamVec[0];
370  if (ParamVec.size() < 2)
371  Npixel_avg = 0;
372  else
373  Npixel_avg = ParamVec[1];
374  }
375  else
376  Npixel_dev = Npixel_avg =0.;
377 
378  if(MD.getValue(MDL_NOISE_COORD,ParamVec, objId))
379  {
380  Ncenter_dev = ParamVec[0];
381  if (ParamVec.size() < 2)
382  Ncenter_avg = 0;
383  else
384  Ncenter_avg = ParamVec[1];
385  }
386  else
387  Ncenter_dev = Ncenter_avg =0.;
388 
389  }
390  else
391  {
392  FILE *fh_param;
393  char line[201];
394  int lineNo = 0;
395  char *auxstr;
396 
397  if ((fh_param = fopen(fn_proj_param.c_str(), "r")) == NULL)
399  (String)"Prog_Project_Parameters::read: There is a problem "
400  "opening the file " + fn_proj_param);
401  while (fgets(line, 200, fh_param) != NULL)
402  {
403  if (line[0] == 0)
404  continue;
405  if (line[0] == '#')
406  continue;
407  if (line[0] == '\n')
408  continue;
409  switch (lineNo)
410  {
411  case 0:
414  lineNo = 1;
415  break;
416  case 1:
417  // Angle file
418  fn_angle = firstWord(line);
419  if (fn_angle == "NULL")
420  ;
421  else if (!fn_angle.exists())
422  REPORT_ERROR(ERR_IO_NOTEXIST, (String)"Prog_Project_Parameters::read: "
423  "file " + fn_angle + " doesn't exist");
424  lineNo = 2;
425  break;
426  case 2:
427  // theta init
428  auxstr = firstWord(line);
429  if (strcmp(auxstr, "NULL") != 0)
430  {
431  enable_angle_range = true;
432  rot_range.ang0 = textToFloat(auxstr);
433  auxstr = nextToken();
434  if (auxstr == nullptr)
435  {
436  // Fixed mode
439  rot_range.samples = 1;
440  }
441  else
442  {
443  rot_range.angF = textToFloat(auxstr);
445  if (rot_range.ang0 == rot_range.angF)
446  rot_range.samples = 1;
448  }
449  lineNo = 3;
450  }
451  else
452  {
453  enable_angle_range = false;
454  lineNo = 5;
455  }
456  break;
457  case 3:
459  auxstr = nextToken();
460  if (auxstr == nullptr)
461  {
462  // Fixed mode
465  tilt_range.samples = 1;
466  }
467  else
468  {
469  tilt_range.angF = textToFloat(auxstr);
472  tilt_range.samples = 1;
474  }
475  lineNo = 4;
476  break;
477  case 4:
479  auxstr = nextToken();
480  if (auxstr == nullptr)
481  {
482  // Fixed mode
485  psi_range.samples = 1;
486  }
487  else
488  {
489  psi_range.angF = textToFloat(auxstr);
491  if (psi_range.ang0 == psi_range.angF)
492  psi_range.samples = 1;
494  }
495  lineNo = 5;
496  break;
497  case 5:
499  auxstr = nextToken();
500  if (auxstr != nullptr)
501  rot_range.Navg = textToFloat(auxstr);
502  else
503  rot_range.Navg = 0;
504  lineNo = 6;
505  break;
506  case 6:
508  auxstr = nextToken();
509  if (auxstr != nullptr)
510  tilt_range.Navg = textToFloat(auxstr);
511  else
512  tilt_range.Navg = 0;
513  lineNo = 7;
514  break;
515  case 7:
517  auxstr = nextToken();
518  if (auxstr != nullptr)
519  psi_range.Navg = textToFloat(auxstr);
520  else
521  psi_range.Navg = 0;
522  lineNo = 8;
523  break;
524  case 8:
526  auxstr = nextToken();
527  if (auxstr != nullptr)
528  Npixel_avg = textToFloat(auxstr);
529  else
530  Npixel_avg = 0;
531  lineNo = 9;
532  break;
533  case 9:
535  auxstr = nextToken();
536  if (auxstr != nullptr)
537  Ncenter_avg = textToFloat(auxstr);
538  else
539  Ncenter_avg = 0;
540  lineNo = 10;
541  break;
542  } /* switch end */
543  } /* while end */
544  if (lineNo != 10)
545  REPORT_ERROR(ERR_PARAM_MISSING, formatString("Prog_Project_Parameters::read: I "
546  "couldn't read all parameters from file %s, only read %d lines", fn_proj_param.c_str(), lineNo));
547  fclose(fh_param);
548  }
549 }
bool enable_angle_range
Enable angle range mode (0 or 1)
Definition: project.h:169
char * firstWord(char *str)
int proj_Ydim
Projection Ydim.
Definition: project.h:163
double Ndev
Stddev of the noise that must be added to the definition of the angle.
Definition: project.h:145
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Angle_range psi_range
Psi angle range.
Definition: project.h:175
< Type of randomness for Tilt (std::string)
Angle_range tilt_range
Tilting angle range.
Definition: project.h:173
< Rotational angle dev and mean noise (vector double)
int samples
No. of samples.
Definition: project.h:131
Shift for the image in the X axis (double)
File for generated angles.
int proj_Xdim
Projection Xdim.
Definition: project.h:161
double Npixel_avg
Bias to be applied to each pixel grey value */.
Definition: project.h:188
int translate_randomness(char *str)
Definition: project.cpp:189
double Ncenter_avg
Bias to apply to the image center.
Definition: project.h:193
bool isEmpty() const override
FileName fn_angle
Document filename.
Definition: project.h:185
float textToFloat(const char *str)
size_t firstRowId() const override
Angle_range rot_range
Rotational angle range.
Definition: project.h:171
double angF
final angular value
Definition: project.h:129
double Ncenter_dev
Standard deviation of the image center.
Definition: project.h:195
Noise description for pixels&#39; gray level (when projecting)
File or directory does not exist.
Definition: xmipp_error.h:136
bool exists() const
< Psi angle dev and mean noise (vector double)
double ang0
initial angular value
Definition: project.h:127
bool getValue(MDObject &mdValueOut, size_t id) const override
bool addLabel(const MDLabel label, int pos=-1) override
#define ANGLE_RANGE_DETERMINISTIC
Definition: project.h:133
File cannot be open.
Definition: xmipp_error.h:137
bool isMetaData(bool failIfNotExists=true) const
int randomness
Definition: project.h:141
double Navg
Mean of the noise that must be added to the definition of the angle.
Definition: project.h:143
std::string String
Definition: xmipp_strings.h:34
String formatString(const char *format,...)
int textToInteger(const char *str)
char * firstToken(const char *str)
< Type of randomness for Rotational (std::string)
Apply shift when project the volume ,.
Shift for the image in the Y axis (double)
bool containsLabel(const MDLabel label) const override
< Psi angle range (vector double)
< Tilt angle dev and mean noise (vector double)
String nextToken(const String &str, size_t &i)
< Type of randomness for Psi (std::string)
Parameter missing.
Definition: xmipp_error.h:182
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: project.h:190

Member Data Documentation

◆ applyShift

bool ParametersProjection::applyShift

Definition at line 180 of file project.h.

◆ doCTFCorrection

bool ParametersProjection::doCTFCorrection

Definition at line 182 of file project.h.

◆ doPhaseFlip

bool ParametersProjection::doPhaseFlip

Definition at line 178 of file project.h.

◆ enable_angle_range

bool ParametersProjection::enable_angle_range

Enable angle range mode (0 or 1)

Definition at line 169 of file project.h.

◆ fn_angle

FileName ParametersProjection::fn_angle

Document filename.

Definition at line 185 of file project.h.

◆ Ncenter_avg

double ParametersProjection::Ncenter_avg

Bias to apply to the image center.

Definition at line 193 of file project.h.

◆ Ncenter_dev

double ParametersProjection::Ncenter_dev

Standard deviation of the image center.

Definition at line 195 of file project.h.

◆ Npixel_avg

double ParametersProjection::Npixel_avg

Bias to be applied to each pixel grey value */.

Definition at line 188 of file project.h.

◆ Npixel_dev

double ParametersProjection::Npixel_dev

Standard deviation of the noise to be added to each pixel grey value.

Definition at line 190 of file project.h.

◆ proj_Xdim

int ParametersProjection::proj_Xdim

Projection Xdim.

Definition at line 161 of file project.h.

◆ proj_Ydim

int ParametersProjection::proj_Ydim

Projection Ydim.

Definition at line 163 of file project.h.

◆ psi_range

Angle_range ParametersProjection::psi_range

Psi angle range.

Definition at line 175 of file project.h.

◆ rot_range

Angle_range ParametersProjection::rot_range

Rotational angle range.

Definition at line 171 of file project.h.

◆ tell

int ParametersProjection::tell

Debugging level.

Definition at line 166 of file project.h.

◆ tilt_range

Angle_range ParametersProjection::tilt_range

Tilting angle range.

Definition at line 173 of file project.h.


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