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

Public Member Functions

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

Public Attributes

FileName fn_in
 
FileName fn_out
 
bool Euler_mode
 
bool PDBmode
 
bool centerPDB
 
double rot
 
double tilt
 
double psi
 
bool Align_mode
 
bool Axis_mode
 
Matrix1D< double > axis
 
double ang
 
Matrix1D< double > shift
 
Matrix1D< double > scale
 
Matrix2D< double > A3D
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- 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 32 of file phantom_transform.cpp.

Member Function Documentation

◆ defineParams()

void Phantom_transform_parameters::defineParams ( )
inlinevirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 47 of file phantom_transform.cpp.

48  {
49  addUsageLine("Apply a geometrical transformation to a phantom description or PDB.");
50  addSeeAlsoLine("phantom_create, volume_from_pdb");
51  addParamsLine(" -i <file> : Phantom description file (.descr) or PDB (.pdb)");
52  addParamsLine("[-o <file=\"\">] : Phantom description file (.descr) or PDB (.pdb)");
53  addParamsLine(" : For PDB files, you must explicitly give an output file, different from input");
54  addParamsLine(" --operation <op>: Operation to perform");
55  addParamsLine(" where <op>");
56  addParamsLine(" shift <x> <y> <z> : Shift vector");
57  addParamsLine(" scale <x> <y> <z> : Scale vector");
58  addParamsLine(" rotate_euler <rot> <tilt> <psi> :Rotate with these Euler angles ");
59  addParamsLine(" rotate_align_with_z <x> <y> <z> : Align (x,y,z) with Z");
60  addParamsLine(" rotate_axis <x> <y> <z> <ang>: Rotate <ang> degrees around (x,y,z)");
61  addParamsLine(" [--center_pdb] : Subtract the center of mass from coordinates.");
62  addParamsLine(" :+Only valid for PDB files");
63  addExampleLine("xmipp_phantom_transform -i model.pdb -o shifted.pdb --operation shift 1 2 3");
64  }
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 Phantom_transform_parameters::readParams ( )
inlinevirtual

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 66 of file phantom_transform.cpp.

67  {
68  fn_in = getParam("-i");
69  fn_out = getParam("-o");
70  if (fn_out=="")
71  fn_out=fn_in;
72  PDBmode=fn_in.contains(".pdb");
73  String operation;
74  shift.initZeros(3);
75  scale.resize(3);
77  A3D.initIdentity(4);
78  Euler_mode = Align_mode = Axis_mode = false;
79  centerPDB = checkParam("--center_pdb");
80  operation=getParam("--operation");
81  if (operation=="shift")
82  {
83  double x=getDoubleParam("--operation",1);
84  double y=getDoubleParam("--operation",2);
85  double z=getDoubleParam("--operation",3);
86  shift=vectorR3(x,y,z);
87  }
88  else if (operation=="scale")
89  {
90  double x=getDoubleParam("--operation",1);
91  double y=getDoubleParam("--operation",2);
92  double z=getDoubleParam("--operation",3);
93  scale=vectorR3(x,y,z);
94  }
95  else if (operation=="rotate_euler")
96  {
97  Euler_mode = true;
98  rot = getDoubleParam("--operation",1);
99  tilt = getDoubleParam("--operation",2);
100  psi = getDoubleParam("--operation",3);
101  Euler_angles2matrix(rot, tilt, psi, A3D, true);
102  }
103  else if (operation=="rotate_align_with_z")
104  {
105  Align_mode = true;
106  double x=getDoubleParam("--operation",1);
107  double y=getDoubleParam("--operation",2);
108  double z=getDoubleParam("--operation",3);
109  axis=vectorR3(x,y,z);
110  alignWithZ(axis, A3D);
111  }
112  else if (operation=="rotate_axis")
113  {
114  Axis_mode = true;
115  double x=getDoubleParam("--operation",1);
116  double y=getDoubleParam("--operation",2);
117  double z=getDoubleParam("--operation",3);
118  ang=getDoubleParam("--operation",4);
119  axis=vectorR3(x,y,z);
121  }
122 
123  // Apply shift
124  A3D(0, 3) = XX(shift);
125  A3D(1, 3) = YY(shift);
126  A3D(2, 3) = ZZ(shift);
127 
128  // Apply scale
129  A3D(0, 0) *= XX(scale);
130  A3D(0, 1) *= YY(scale);
131  A3D(0, 2) *= ZZ(scale);
132  A3D(1, 0) *= XX(scale);
133  A3D(1, 1) *= YY(scale);
134  A3D(1, 2) *= ZZ(scale);
135  A3D(2, 0) *= XX(scale);
136  A3D(2, 1) *= YY(scale);
137  A3D(2, 2) *= ZZ(scale);
138  }
double getDoubleParam(const char *param, int arg=0)
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
static double * y
Matrix1D< double > vectorR3(double x, double y, double z)
Definition: matrix1d.cpp:892
doublereal * x
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
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
double z
bool contains(const String &str) const
void initZeros()
Definition: matrix1d.h:592
#define YY(v)
Definition: matrix1d.h:93
std::string String
Definition: xmipp_strings.h:34
bool checkParam(const char *param)
void alignWithZ(const Matrix1D< double > &axis, Matrix2D< double > &result, bool homogeneous)
void initConstant(T val)
Definition: matrix1d.cpp:83
#define ZZ(v)
Definition: matrix1d.h:101
void initIdentity()
Definition: matrix2d.h:673

◆ run()

void Phantom_transform_parameters::run ( )
inlinevirtual

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

Reimplemented from XmippProgram.

Definition at line 161 of file phantom_transform.cpp.

162  {
163  show();
164  if (PDBmode)
166  else
167  {
168  Phantom P;
169  P.read(fn_in, false); // Read phantom without applying scale
170  P.selfApplyGeometry(A3D, xmipp_transformation::IS_NOT_INV);
171  P.write(fn_out);
172  }
173  }
void applyGeometryToPDBFile(const std::string &fn_in, const std::string &fn_out, const Matrix2D< double > &A, bool centerPDB, const std::string &intensityColumn)
Definition: pdb.cpp:294
void write(const FileName &fn_phantom="")
Definition: phantom.cpp:2355
void read(const FileName &fn_phantom, bool apply_scale=true)
Definition: phantom.cpp:2088
void selfApplyGeometry(const Matrix2D< double > &A, int inv)
Definition: phantom.cpp:2493

◆ show()

void Phantom_transform_parameters::show ( )
inline

Definition at line 140 of file phantom_transform.cpp.

141  {
142  if (verbose==0)
143  return;
144  std::cout << "Input file : " << fn_in << std::endl
145  << "Output file: " << fn_out << std::endl;
146  if (PDBmode)
147  std::cout << "Input file is PDB\n";
148  if (centerPDB)
149  std::cout << "Centering PDB\n";
150  if (Euler_mode)
151  std::cout << "Euler angles (rot, tilt, psi): " << rot << " " << tilt
152  << " " << psi << std::endl;
153  else if (Align_mode)
154  std::cout << "Aligning " << axis.transpose() << " with Z\n";
155  else if (Axis_mode)
156  std::cout << "Rotating " << ang << " degrees around "
157  << axis.transpose() << std::endl;
158  std::cout << "Transformation matrix\n" << A3D << std::endl;
159  }
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
int verbose
Verbosity level.

Member Data Documentation

◆ A3D

Matrix2D<double> Phantom_transform_parameters::A3D

Definition at line 45 of file phantom_transform.cpp.

◆ Align_mode

bool Phantom_transform_parameters::Align_mode

Definition at line 38 of file phantom_transform.cpp.

◆ ang

double Phantom_transform_parameters::ang

Definition at line 41 of file phantom_transform.cpp.

◆ axis

Matrix1D<double> Phantom_transform_parameters::axis

Definition at line 40 of file phantom_transform.cpp.

◆ Axis_mode

bool Phantom_transform_parameters::Axis_mode

Definition at line 39 of file phantom_transform.cpp.

◆ centerPDB

bool Phantom_transform_parameters::centerPDB

Definition at line 36 of file phantom_transform.cpp.

◆ Euler_mode

bool Phantom_transform_parameters::Euler_mode

Definition at line 36 of file phantom_transform.cpp.

◆ fn_in

FileName Phantom_transform_parameters::fn_in

Definition at line 35 of file phantom_transform.cpp.

◆ fn_out

FileName Phantom_transform_parameters::fn_out

Definition at line 35 of file phantom_transform.cpp.

◆ PDBmode

bool Phantom_transform_parameters::PDBmode

Definition at line 36 of file phantom_transform.cpp.

◆ psi

double Phantom_transform_parameters::psi

Definition at line 37 of file phantom_transform.cpp.

◆ rot

double Phantom_transform_parameters::rot

Definition at line 37 of file phantom_transform.cpp.

◆ scale

Matrix1D<double> Phantom_transform_parameters::scale

Definition at line 43 of file phantom_transform.cpp.

◆ shift

Matrix1D<double> Phantom_transform_parameters::shift

Definition at line 42 of file phantom_transform.cpp.

◆ tilt

double Phantom_transform_parameters::tilt

Definition at line 37 of file phantom_transform.cpp.


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