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

#include <projection.h>

Collaboration diagram for ParametersProjectionTomography:
Collaboration graph
[legend]

Public Member Functions

 ParametersProjectionTomography ()
 
void read (const FileName &fn_proj_param)
 
void defineParams (XmippProgram *program)
 
void readParams (XmippProgram *program)
 
void calculateProjectionAngles (Projection &P, double angle, double inplaneRot, const Matrix1D< double > &sinplane)
 

Public Attributes

FileName fnPhantom
 
FileName fnRoot
 Root filename (used for a stack) More...
 
FileName fnOut
 Output filename (used for a singleProjection) More...
 
bool singleProjection
 Only project a single image. More...
 
int starting
 First projection number. By default, 1. More...
 
std::string fn_projection_extension
 Extension for projection filenames. This is optional. More...
 
int proj_Xdim
 Projection Xdim. More...
 
int proj_Ydim
 Projection Ydim. More...
 
bool only_create_angles
 Only create angles, do not project. More...
 
bool show_angles
 
double axisRot
 Rotational angle of the tilt axis. More...
 
double axisTilt
 Tilt angle of the tilt axis. More...
 
Matrix1D< double > raxis
 Offset of the tilt axis. More...
 
double tilt0
 Minimum tilt around this axis. More...
 
double tiltF
 Maximum tilt around this axis. More...
 
double tiltStep
 Step in tilt. 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...
 
double Nangle_avg
 Bias to apply to the angles. More...
 
double Nangle_dev
 Standard deviation of the angles. More...
 

Detailed Description

Projecting parameters. This class reads a set of projection parameters in a file (see xmipp_project_tomography for more information about the file structure) and extract the useful information from it.

Definition at line 58 of file projection.h.

Constructor & Destructor Documentation

◆ ParametersProjectionTomography()

ParametersProjectionTomography::ParametersProjectionTomography ( )

Definition at line 50 of file projection.cpp.

51 {
52  proj_Xdim = 0;
53  proj_Ydim = 0;
54 
55  axisRot = 0;
56  axisTilt = 0;
57  raxis.initZeros(3);
58 
59  tilt0 = 0;
60  tiltF = 0;
61  tiltStep = 0;
62 
63  Nangle_dev = 0;
64  Nangle_avg = 0;
65 
66  Npixel_dev = 0;
67  Npixel_avg = 0;
68 
69  Ncenter_dev = 0;
70  Ncenter_avg = 0;
71 }
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: projection.h:101
double tilt0
Minimum tilt around this axis.
Definition: projection.h:92
double tiltF
Maximum tilt around this axis.
Definition: projection.h:94
Matrix1D< double > raxis
Offset of the tilt axis.
Definition: projection.h:90
double Npixel_avg
Bias to be applied to each pixel grey value */.
Definition: projection.h:99
int proj_Ydim
Projection Ydim.
Definition: projection.h:78
double Ncenter_avg
Bias to apply to the image center.
Definition: projection.h:104
double Ncenter_dev
Standard deviation of the image center.
Definition: projection.h:106
double Nangle_dev
Standard deviation of the angles.
Definition: projection.h:111
int proj_Xdim
Projection Xdim.
Definition: projection.h:76
void initZeros()
Definition: matrix1d.h:592
double axisRot
Rotational angle of the tilt axis.
Definition: projection.h:86
double axisTilt
Tilt angle of the tilt axis.
Definition: projection.h:88
double tiltStep
Step in tilt.
Definition: projection.h:96
double Nangle_avg
Bias to apply to the angles.
Definition: projection.h:109

Member Function Documentation

◆ calculateProjectionAngles()

void ParametersProjectionTomography::calculateProjectionAngles ( Projection P,
double  angle,
double  inplaneRot,
const Matrix1D< double > &  sinplane 
)

Calculate the Euler angles and X-Y shifts from the tilt axis direction and tilt angle.

As, usually, the tomographic rotation angle is the tilt angle, we are forcing to keep the sign of the resulting tilt angle coincides the sign of the incoming angle

Definition at line 277 of file projection.cpp.

279 {
280  // Find Euler rotation matrix
283  Matrix2D<double> Raxis;
284  Matrix2D<double> Rinplane;
285  rotation3DMatrix(angle,axis,Raxis,false);
286  rotation3DMatrix(inplaneRot,'Z',Rinplane,false);
287  double rot;
288  double tilt;
289  double psi;
290  Euler_matrix2angles(Rinplane*Raxis, rot, tilt, psi);
291 
292 
298  if (angle * tilt < 0)
299  Euler_another_set(rot, tilt, psi, rot, tilt, psi);
300 
301  rot = realWRAP(rot,-180,180);
302  if (XMIPP_EQUAL_ZERO(rot))
303  rot = 0.;
304  tilt = realWRAP(tilt,-180,180);
305  if (XMIPP_EQUAL_ZERO(tilt))
306  tilt = 0.;
307  psi = realWRAP(psi,-180,180);
308  if (XMIPP_EQUAL_ZERO(psi))
309  psi = 0.;
310 
311  P.setAngles(rot, tilt, psi);
312 
313  // Find displacement because of axis offset and inplane shift
314  Matrix1D<double> roffset = Rinplane*(raxis-Raxis*raxis) + sinplane;
315 
316  P.setShifts(XX(roffset), YY(roffset), ZZ(roffset));
317 
318 #ifdef DEBUG
319 
320  std::cout << "axisRot=" << axisRot << " axisTilt=" << axisTilt
321  << " axis=" << axis.transpose() << std::endl
322  << "angle=" << angle << std::endl
323  << "Raxis\n" << Raxis
324  << "Rinplane\n" << Rinplane
325  << "Raxis*Rinplane\n" << Raxis*Rinplane
326  << "rot=" << rot << " tilt=" << tilt << " psi=" << psi
327  << std::endl;
329  Euler_angles2matrix(rot,tilt,psi,E);
330  std::cout << "E\n" << E << std::endl;
331 #endif
332 }
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
void Euler_direction(double alpha, double beta, double gamma, Matrix1D< double > &v)
Definition: geometry.cpp:721
void Euler_another_set(double rot, double tilt, double psi, double &newrot, double &newtilt, double &newpsi)
Definition: geometry.cpp:1002
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
void rotation3DMatrix(double ang, char axis, Matrix2D< double > &result, bool homogeneous)
Matrix1D< double > raxis
Offset of the tilt axis.
Definition: projection.h:90
void setShifts(double xoff, double yoff, double zoff=0., const size_t n=0)
char axis
#define XX(v)
Definition: matrix1d.h:85
#define XMIPP_EQUAL_ZERO(x)
Definition: xmipp_macros.h:123
double axisRot
Rotational angle of the tilt axis.
Definition: projection.h:86
double axisTilt
Tilt angle of the tilt axis.
Definition: projection.h:88
#define YY(v)
Definition: matrix1d.h:93
double psi(const double x)
void Euler_matrix2angles(const Matrix2D< double > &A, double &alpha, double &beta, double &gamma, bool homogeneous)
Definition: geometry.cpp:839
#define realWRAP(x, x0, xF)
Definition: xmipp_macros.h:304
void setAngles(double _rot, double _tilt, double _psi)
#define ZZ(v)
Definition: matrix1d.h:101

◆ defineParams()

void ParametersProjectionTomography::defineParams ( XmippProgram program)

Definition at line 74 of file projection.cpp.

75 {
76  program->addParamsLine(" -i <volume_file> : Volume file to be projected.");
77  program->addParamsLine(" alias --input;");
78  program->addParamsLine(" --oroot <rootname> : Output rootname");
79  program->addParamsLine(" requires --params;");
80  program->addParamsLine("or -o <image_file> : Output image");
81  program->addParamsLine(" alias --output;");
82  program->addParamsLine(" requires --angles;");
83  program->addParamsLine("== Generating a set of projections == ");
84  program->addParamsLine(" [--params <parameters_file>] : File containing projection parameters");
85  program->addParamsLine(" : Check the manual for a description of the parameters");
86  program->addParamsLine(" requires --oroot;");
87  program->addParamsLine("== Generating a single projection == ");
88  program->addParamsLine(" [--angles <tilt> <axisRot=90> <axisTilt=90>] : Tilt angle for a single projection.");
89  program->addParamsLine(" : (axisRot, axisTilt) is the direction of the rotation axis." );
90  program->addParamsLine(" requires -o;");
91  program->addParamsLine("==+ Global projection options== ");
92  program->addParamsLine("[--show_angles] : Print angles value for each projection.");
93  program->addParamsLine("[--only_create_angles] : Projections are not calculated, only the angles values.");
94 }
void addParamsLine(const String &line)

◆ read()

void ParametersProjectionTomography::read ( const FileName fn_proj_param)

Read projection parameters from a file.

Definition at line 129 of file projection.cpp.

130 {
131  if (fn_proj_param.isMetaData())
132  {
133  MetaDataVec MD;
134  size_t objId;
135  MD.read(fn_proj_param);
136  objId = MD.firstRowId();
137  // MD.getValue(MDL_PRJ_VOL, fnPhantom, objId);
138  std::vector<double> vecD;
139  MD.getValue(MDL_PRJ_DIMENSIONS, vecD, objId);
140  proj_Xdim = (int)vecD[0];
141  proj_Ydim = (int)vecD[1];
142  MD.getValue(MDL_ANGLE_ROT, axisRot, objId);
143  MD.getValue(MDL_ANGLE_TILT, axisTilt, objId);
144 
145  raxis.resize(3);
146  if (!MD.getValue(MDL_SHIFT_X, XX(raxis), objId))
147  XX(raxis) = 0;
148  if (!MD.getValue(MDL_SHIFT_Y, YY(raxis), objId))
149  YY(raxis) = 0;
150  if (!MD.getValue(MDL_SHIFT_Z, ZZ(raxis), objId))
151  ZZ(raxis) = 0;
152 
153  MD.getValue(MDL_PRJ_TILT_RANGE, vecD, objId);
154  tilt0 = vecD[0];
155  tiltF = vecD[1];
156  tiltStep = vecD[2];
157 
158  if (MD.getValue(MDL_NOISE_ANGLES, vecD, objId))
159  {
160  Nangle_dev = vecD[0];
161  Nangle_avg = (vecD.size()>1)? vecD[1]: 0;
162  }
163  else
164  Nangle_dev = Nangle_avg = 0;
165 
166  if (MD.getValue(MDL_NOISE_PIXEL_LEVEL, vecD, objId))
167  {
168  Npixel_dev = vecD[0];
169  Npixel_avg = (vecD.size()>1)? vecD[1]: 0;
170  }
171  else
172  Npixel_dev = Npixel_avg = 0;
173 
174  if (MD.getValue(MDL_NOISE_PARTICLE_COORD, vecD, objId))
175  {
176  Ncenter_dev = vecD[0];
177  Ncenter_avg = (vecD.size()>1)? vecD[1]: 0;
178  }
179  else
180  Ncenter_dev = Ncenter_avg = 0;
181  }
182  else
183  {
184  FILE *fh_param;
185  char line[201];
186  int lineNo = 0;
187  char *auxstr;
188 
189  if ((fh_param = fopen(fn_proj_param.c_str(), "r")) == nullptr)
191  (std::string)"ParametersProjectionTomography::read: There is a problem "
192  "opening the file " + fn_proj_param);
193  while (fgets(line, 200, fh_param) != nullptr)
194  {
195  if (line[0] == 0)
196  continue;
197  if (line[0] == '#')
198  continue;
199  if (line[0] == '\n')
200  continue;
201  switch (lineNo)
202  {
203  case 0:
204  fnPhantom = firstWord(line);
205  lineNo = 1;
206  break;
207  case 1:
208  fnOut =
209  firstWord(line);
210  // Next two parameters are optional
211  auxstr = nextToken();
212  if (auxstr != nullptr)
213  starting =
214  textToInteger(auxstr);
216  lineNo = 2;
217  break;
218  case 2:
221  lineNo = 3;
222  break;
223  case 3:
224  axisRot = textToFloat(firstToken(line));
226  lineNo = 4;
227  break;
228  case 4:
229  raxis.resize(3);
230  XX(raxis) = textToFloat(firstToken(line));
233  lineNo = 5;
234  break;
235  case 5:
236  tilt0 = textToFloat(firstToken(line));
239  lineNo = 6;
240  break;
241  case 6:
243  auxstr = nextToken();
244  if (auxstr != nullptr)
245  Nangle_avg = textToFloat(auxstr);
246  else
247  Nangle_avg = 0;
248  lineNo = 7;
249  break;
250  case 7:
252  auxstr = nextToken();
253  if (auxstr != nullptr)
254  Npixel_avg = textToFloat(auxstr);
255  else
256  Npixel_avg = 0;
257  lineNo = 8;
258  break;
259  case 8:
261  auxstr = nextToken();
262  if (auxstr != nullptr)
263  Ncenter_avg = textToFloat(auxstr);
264  else
265  Ncenter_avg = 0;
266  lineNo = 9;
267  break;
268  } /* switch end */
269  } /* while end */
270  if (lineNo != 9)
271  REPORT_ERROR(ERR_ARG_MISSING, (std::string)"ParametersProjectionTomography::read: I "
272  "couldn't read all parameters from file " + fn_proj_param);
273  fclose(fh_param);
274  }
275 }
Argument missing.
Definition: xmipp_error.h:114
Rotation angle of an image (double,degrees)
char * firstWord(char *str)
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: projection.h:101
FileName fnOut
Output filename (used for a singleProjection)
Definition: projection.h:67
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
std::string fn_projection_extension
Extension for projection filenames. This is optional.
Definition: projection.h:73
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
< Type of randomness for Tilt (std::string)
double tilt0
Minimum tilt around this axis.
Definition: projection.h:92
Tilting angle of an image (double,degrees)
Shift for the image in the X axis (double)
Noise description for projected angles.
double tiltF
Maximum tilt around this axis.
Definition: projection.h:94
Matrix1D< double > raxis
Offset of the tilt axis.
Definition: projection.h:90
double Npixel_avg
Bias to be applied to each pixel grey value */.
Definition: projection.h:99
int proj_Ydim
Projection Ydim.
Definition: projection.h:78
#define XX(v)
Definition: matrix1d.h:85
double Ncenter_avg
Bias to apply to the image center.
Definition: projection.h:104
float textToFloat(const char *str)
double Ncenter_dev
Standard deviation of the image center.
Definition: projection.h:106
size_t firstRowId() const override
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
< Number of non-redundant projections directions (size_t)
Noise description for pixels&#39; gray level (when projecting)
double Nangle_dev
Standard deviation of the angles.
Definition: projection.h:111
int proj_Xdim
Projection Xdim.
Definition: projection.h:76
double axisRot
Rotational angle of the tilt axis.
Definition: projection.h:86
double axisTilt
Tilt angle of the tilt axis.
Definition: projection.h:88
#define YY(v)
Definition: matrix1d.h:93
bool getValue(MDObject &mdValueOut, size_t id) const override
File cannot be open.
Definition: xmipp_error.h:137
bool isMetaData(bool failIfNotExists=true) const
Shift for the image in the Z axis (double)
int textToInteger(const char *str)
char * firstToken(const char *str)
double tiltStep
Step in tilt.
Definition: projection.h:96
Shift for the image in the Y axis (double)
String nextToken(const String &str, size_t &i)
#define ZZ(v)
Definition: matrix1d.h:101
int starting
First projection number. By default, 1.
Definition: projection.h:71
double Nangle_avg
Bias to apply to the angles.
Definition: projection.h:109
Noise description for particle&#39;s center coordenates (when projecting)

◆ readParams()

void ParametersProjectionTomography::readParams ( XmippProgram program)

Definition at line 97 of file projection.cpp.

98 {
99  fnPhantom = program->getParam("-i");
100 
101  singleProjection = program->checkParam("-o");
102 
103  if (!singleProjection)
104  {
105  fnRoot = program->getParam("--oroot");
106  read(program->getParam("--params"));
107  }
108  else
109  {
110  fnOut = program->getParam("-o");
111 
112  tilt0 = tiltF = program->getDoubleParam("--angles",0);
113  tiltStep = 1;
114 
115  axisRot = program->getDoubleParam("--angles",1);
116  axisTilt = program->getDoubleParam("--angles",2);
117 
118  Image<char> volTemp;
119  volTemp.read(fnPhantom, HEADER);
120  proj_Xdim = XSIZE(VOLMATRIX(volTemp));
121  proj_Ydim = YSIZE(VOLMATRIX(volTemp));
122  }
123 
124  show_angles = program->checkParam("--show_angles");
125  only_create_angles = program->checkParam("--only_create_angles");
126 }
bool only_create_angles
Only create angles, do not project.
Definition: projection.h:81
#define YSIZE(v)
FileName fnOut
Output filename (used for a singleProjection)
Definition: projection.h:67
double getDoubleParam(const char *param, int arg=0)
#define VOLMATRIX(V)
double tilt0
Minimum tilt around this axis.
Definition: projection.h:92
double tiltF
Maximum tilt around this axis.
Definition: projection.h:94
int proj_Ydim
Projection Ydim.
Definition: projection.h:78
const char * getParam(const char *param, int arg=0)
#define XSIZE(v)
int proj_Xdim
Projection Xdim.
Definition: projection.h:76
double axisRot
Rotational angle of the tilt axis.
Definition: projection.h:86
FileName fnRoot
Root filename (used for a stack)
Definition: projection.h:65
double axisTilt
Tilt angle of the tilt axis.
Definition: projection.h:88
bool singleProjection
Only project a single image.
Definition: projection.h:69
bool checkParam(const char *param)
void read(const FileName &fn_proj_param)
Definition: projection.cpp:129
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
double tiltStep
Step in tilt.
Definition: projection.h:96

Member Data Documentation

◆ axisRot

double ParametersProjectionTomography::axisRot

Rotational angle of the tilt axis.

Definition at line 86 of file projection.h.

◆ axisTilt

double ParametersProjectionTomography::axisTilt

Tilt angle of the tilt axis.

Definition at line 88 of file projection.h.

◆ fn_projection_extension

std::string ParametersProjectionTomography::fn_projection_extension

Extension for projection filenames. This is optional.

Definition at line 73 of file projection.h.

◆ fnOut

FileName ParametersProjectionTomography::fnOut

Output filename (used for a singleProjection)

Definition at line 67 of file projection.h.

◆ fnPhantom

FileName ParametersProjectionTomography::fnPhantom

Phantom filename. It must be a Xmipp volume.

Definition at line 63 of file projection.h.

◆ fnRoot

FileName ParametersProjectionTomography::fnRoot

Root filename (used for a stack)

Definition at line 65 of file projection.h.

◆ Nangle_avg

double ParametersProjectionTomography::Nangle_avg

Bias to apply to the angles.

Definition at line 109 of file projection.h.

◆ Nangle_dev

double ParametersProjectionTomography::Nangle_dev

Standard deviation of the angles.

Definition at line 111 of file projection.h.

◆ Ncenter_avg

double ParametersProjectionTomography::Ncenter_avg

Bias to apply to the image center.

Definition at line 104 of file projection.h.

◆ Ncenter_dev

double ParametersProjectionTomography::Ncenter_dev

Standard deviation of the image center.

Definition at line 106 of file projection.h.

◆ Npixel_avg

double ParametersProjectionTomography::Npixel_avg

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

Definition at line 99 of file projection.h.

◆ Npixel_dev

double ParametersProjectionTomography::Npixel_dev

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

Definition at line 101 of file projection.h.

◆ only_create_angles

bool ParametersProjectionTomography::only_create_angles

Only create angles, do not project.

Definition at line 81 of file projection.h.

◆ proj_Xdim

int ParametersProjectionTomography::proj_Xdim

Projection Xdim.

Definition at line 76 of file projection.h.

◆ proj_Ydim

int ParametersProjectionTomography::proj_Ydim

Projection Ydim.

Definition at line 78 of file projection.h.

◆ raxis

Matrix1D<double> ParametersProjectionTomography::raxis

Offset of the tilt axis.

Definition at line 90 of file projection.h.

◆ show_angles

bool ParametersProjectionTomography::show_angles

Definition at line 83 of file projection.h.

◆ singleProjection

bool ParametersProjectionTomography::singleProjection

Only project a single image.

Definition at line 69 of file projection.h.

◆ starting

int ParametersProjectionTomography::starting

First projection number. By default, 1.

Definition at line 71 of file projection.h.

◆ tilt0

double ParametersProjectionTomography::tilt0

Minimum tilt around this axis.

Definition at line 92 of file projection.h.

◆ tiltF

double ParametersProjectionTomography::tiltF

Maximum tilt around this axis.

Definition at line 94 of file projection.h.

◆ tiltStep

double ParametersProjectionTomography::tiltStep

Step in tilt.

Definition at line 96 of file projection.h.


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