Xmipp  v3.23.11-Nereus
Protected Member Functions | Protected Attributes | List of all members
ProgAngularRotate Class Reference
Inheritance diagram for ProgAngularRotate:
Inheritance graph
[legend]
Collaboration diagram for ProgAngularRotate:
Collaboration graph
[legend]

Protected Member Functions

void defineParams ()
 
void readParams ()
 
void run ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Protected Attributes

FileName fnIn
 
FileName fnOut
 
MetaDataVec mdIn
 
MetaDataVec mdOut
 
Matrix2D< double > R
 
Matrix2D< double > T
 
Matrix2D< double > B
 
bool writeMatrix
 
- 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
 

Additional Inherited Members

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

Detailed Description

Definition at line 33 of file angular_rotate.cpp.

Member Function Documentation

◆ defineParams()

void ProgAngularRotate::defineParams ( )
inlineprotectedvirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 41 of file angular_rotate.cpp.

42  {
43  addUsageLine("Calculate the Euler angles after applying a rotation to a geometry set from a metadata.");
44  addKeywords("angular, geometry, rotate");
45  addSeeAlsoLine("transform_geometry");
46 
47  addParamsLine(" -i <metadata> : Input metadata file");
48  addParamsLine(" [-o <metadata>] : Output metadata file, if not provided result will overwrite input file");
49  addParamsLine(" --ang <angle> : Rotate in plane");
50  addParamsLine(" or --euler <rot> <tilt> <psi> : Rotate with these Euler angles");
51  addParamsLine(" or --alignZ <x> <y> <z> : Align (x,y,z) with Z axis");
52  addParamsLine(" or --axis <ang> <x=0> <y=0> <z=1> : Rotate <ang> degrees around (x,y,z)");
53  addParamsLine("[--write_matrix] : Print transformation matrix to screen");
54 
55  addExampleLine("Modify the geometry of a selfile applying a rotation of 0.1 degrees around (x,y,z)=(1,1,1) direction:", false);
56  addExampleLine("xmipp_angular_rotate -i selfile.sel -o newselfile.sel --axis 0.1 1 1 1");
57 
58  }
void addSeeAlsoLine(const char *seeAlso)
void addKeywords(const char *keywords)
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgAngularRotate::readParams ( )
inlineprotectedvirtual

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 60 of file angular_rotate.cpp.

61  {
62  fnIn = getParam("-i");
63  fnOut = (checkParam("-o"))? getParam("-o") : fnIn;
64 
65  mdIn.read(fnIn);
66  int dim;
67 
69  dim = 3;
70  else
71  dim = 2;
72 
73  R.initIdentity(dim + 1);
74  B.initIdentity(dim + 1);
75  Matrix1D<double> xyz(3);
76 
77  if (checkParam("--ang"))
78  Euler_angles2matrix(0., 0.,getDoubleParam("--ang"), R, true);
79  else if (checkParam("--axis"))
80  {
81  double ang = getDoubleParam("--axis", 0);
82  XX(xyz) = getDoubleParam("--axis", 1); //axis x
83  YY(xyz) = getDoubleParam("--axis", 2); //y
84  ZZ(xyz) = getDoubleParam("--axis", 3);//z
85  rotation3DMatrix(ang, xyz, R, true);
86  }
87  else if (checkParam("--euler"))
88  {
89  XX(xyz) = getDoubleParam("--euler", 0); //rot
90  YY(xyz) = getDoubleParam("--euler", 1); //tilt
91  ZZ(xyz) = getDoubleParam("--euler", 2);//psi
92  Euler_angles2matrix(XX(xyz), YY(xyz), ZZ(xyz), R, true);
93  }
94  else if (checkParam("--alignZ"))
95  {
96  XX(xyz) = getDoubleParam("--alignZ", 0); //rot
97  YY(xyz) = getDoubleParam("--alignZ", 1); //tilt
98  ZZ(xyz) = getDoubleParam("--alignZ", 2);//psi
99  alignWithZ(xyz, R);
100  }
101 
102  writeMatrix = checkParam("--write_matrix");
103  }
double getDoubleParam(const char *param, int arg=0)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
Tilting angle of an image (double,degrees)
Special label to be used when gathering MDs in MpiMetadataPrograms.
void rotation3DMatrix(double ang, char axis, Matrix2D< double > &result, bool homogeneous)
const char * getParam(const char *param, int arg=0)
#define XX(v)
Definition: matrix1d.h:85
Matrix2D< double > R
Matrix2D< double > B
#define YY(v)
Definition: matrix1d.h:93
bool checkParam(const char *param)
bool containsLabel(const MDLabel label) const override
void alignWithZ(const Matrix1D< double > &axis, Matrix2D< double > &result, bool homogeneous)
#define ZZ(v)
Definition: matrix1d.h:101
void initIdentity()
Definition: matrix2d.h:673

◆ run()

void ProgAngularRotate::run ( )
inlineprotectedvirtual

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

Reimplemented from XmippProgram.

Definition at line 105 of file angular_rotate.cpp.

106  {
107  bool containsScale=mdIn.containsLabel(MDL_SCALE);
108  for (auto& input : mdIn)
109  {
110  geo2TransformationMatrix(input, B);
111 
112  T = R * B;
113 
114  transformationMatrix2Geo(T, input);
115  if (!containsScale)
116  input.setValue(MDL_SCALE,1.0);
117  mdOut.addRow(dynamic_cast<MDRowVec&>(input));
118 
119  if (writeMatrix)
120  std::cout << T << std::endl;
121  }
122 
123  mdOut.write(fnOut);
124  }
void geo2TransformationMatrix(const MDRow &imageGeo, Matrix2D< double > &A, bool only_apply_shifts)
void transformationMatrix2Geo(const Matrix2D< double > &A, MDRow &imageGeo)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
size_t addRow(const MDRow &row) override
Matrix2D< double > R
Matrix2D< double > B
scaling factor for an image or volume (double)
Matrix2D< double > T
bool containsLabel(const MDLabel label) const override

Member Data Documentation

◆ B

Matrix2D<double> ProgAngularRotate::B
protected

Definition at line 38 of file angular_rotate.cpp.

◆ fnIn

FileName ProgAngularRotate::fnIn
protected

Definition at line 36 of file angular_rotate.cpp.

◆ fnOut

FileName ProgAngularRotate::fnOut
protected

Definition at line 36 of file angular_rotate.cpp.

◆ mdIn

MetaDataVec ProgAngularRotate::mdIn
protected

Definition at line 37 of file angular_rotate.cpp.

◆ mdOut

MetaDataVec ProgAngularRotate::mdOut
protected

Definition at line 37 of file angular_rotate.cpp.

◆ R

Matrix2D<double> ProgAngularRotate::R
protected

Definition at line 38 of file angular_rotate.cpp.

◆ T

Matrix2D<double> ProgAngularRotate::T
protected

Definition at line 38 of file angular_rotate.cpp.

◆ writeMatrix

bool ProgAngularRotate::writeMatrix
protected

Definition at line 39 of file angular_rotate.cpp.


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