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

#include <mpi_project_XR.h>

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

Public Member Functions

void read (int argc, char **argv)
 
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 ()
 

Protected Member Functions

void defineParams ()
 
- Protected Member Functions inherited from ProgXrayProject
virtual void readParams ()
 
void preRun ()
 
void postRun ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Additional Inherited Members

- Public Attributes inherited from ProgXrayProject
FileName fn_proj_param
 Filename with the Projection_Parameters. More...
 
FileName fn_sel_file
 Selection file with all projections. More...
 
FileName fn_psf_xr
 Filename with the Microscope Parameters. More...
 
ParametersProjectionTomography projParam
 
XRayPSF psf
 
double psfThr
 threshold for psfSlabs More...
 
double dxo
 
int nThr
 Number of threads;. More...
 
bool save_std_projs
 Save standard projections. More...
 
XrayProjPhantom phantom
 
Projection proj
 
Projection stdProj
 
MetaDataVec projMD
 
ParallelTaskDistributortd
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 
- 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

Program class for the project program

Definition at line 37 of file mpi_project_XR.h.

Member Function Documentation

◆ defineParams()

void ProgMPIXrayProject::defineParams ( )
protectedvirtual

Function in which the param of each Program are defined.

Reimplemented from ProgXrayProject.

Definition at line 42 of file mpi_project_XR.cpp.

43 {
45  clearUsage();
46  addUsageLine("MPI Generate projections as in a X-ray microscope from a 3D Xmipp volume.");
47 
48 }
virtual void defineParams()
void addUsageLine(const char *line, bool verbatim=false)

◆ read()

void ProgMPIXrayProject::read ( int  argc,
char **  argv 
)

Definition at line 49 of file mpi_project_XR.cpp.

50 {
51  node = std::make_shared<MpiNode>(argc, argv);
52  if (!node->isMaster())
53  verbose = 0;
54  ProgXrayProject::read(argc, (const char **)argv);
55 }
virtual void read(int argc, const char **argv, bool reportErrors=true)
int argc
Original command line arguments.
Definition: xmipp_program.h:86
MpiNode * node
const char ** argv
Definition: xmipp_program.h:87
int verbose
Verbosity level.
bool isMaster() const
Definition: xmipp_mpi.cpp:166

◆ run()

void ProgMPIXrayProject::run ( )
virtual

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

Reimplemented from ProgXrayProject.

Definition at line 57 of file mpi_project_XR.cpp.

58 {
59  preRun();
60 
61  // Project
62  projMD.setComment("True rot, tilt and psi; rot, tilt, psi, X and Y shifts applied");
63 
64  // // Assign mpi node information
65  // MpiNode & node = *node;
66 
67  // Calculation of data to be distributed in nodes -----------------------------------------
68  std::vector<mpiProjData> mpiData;
69  mpiProjData data;
70 
71  size_t idx = FIRST_IMAGE;
72  size_t id;
73 
74  double angle=projParam.tilt0;
75  while (angle <= projParam.tiltF)
76  {
78  data.fn_proj = projParam.fnOut;
79  else
80  data.fn_proj.compose(idx, projParam.fnRoot + ".stk");
81 
82  // Choose Center displacement ........................................
85  Matrix1D<double> inPlaneShift(3);
86  VECTOR_R3(inPlaneShift,shiftX,shiftY,0);
87 
88  projParam.calculateProjectionAngles(proj,angle, 0,inPlaneShift);
89  proj.getEulerAngles(data.tRot, data.tTilt,data.tPsi);
90  proj.getShifts(data.xShift, data.yShift, data.zShift);
91 
92  // Add noise in angles and voxels ....................................
93 
97 
98  //MPI proj.setEulerAngles(rot,tilt,psi);
99 
100  if (node->isMaster())
101  {
102  id = projMD.addObject();
103  projMD.setValue(MDL_IMAGE,data.fn_proj, id);
104 
105  projMD.setValue(MDL_ANGLE_ROT,data.tRot, id);
107  projMD.setValue(MDL_ANGLE_PSI,data.tPsi, id);
108  projMD.setValue(MDL_ANGLE_ROT2,data.rot, id);
110  projMD.setValue(MDL_ANGLE_PSI2,data.psi, id);
111  projMD.setValue(MDL_SHIFT_X,shiftX, id);
112  projMD.setValue(MDL_SHIFT_Y,shiftY, id);
113  }
114 
115  mpiData.push_back(data);
116  idx++;
117  angle += projParam.tiltStep;
118  }
119 
120  // Creation of MPI Job Handler file
121 
122  long long int nodeBlockSize = 1;
123  std::unique_ptr<MpiTaskDistributor>jobHandler = std::make_unique<MpiTaskDistributor>(mpiData.size(), nodeBlockSize, node);
124 
125  size_t first = 0, last = 0;
126 
127  if (node->isMaster())
128  {
129  // Save metadata file with angles and shift info
131  projMD.write(projParam.fnRoot + ".sel");
132 
133  if (!(projParam.show_angles))
134  init_progress_bar(mpiData.size());
135 
136  // Creation of output file to reserve space
137  createEmptyFile(mpiData[mpiData.size()-1].fn_proj,
140 
141  std::cout << "Projecting ...\n";
142  }
143 
144  node->barrierWait();
145 
146  MPI_Barrier(MPI_COMM_WORLD);
147 
148  // Parallel node jobs
149  while (jobHandler->getTasks(first, last))
150  {
151  for (size_t k = first; k <= last; k++)
152  {
153  std::cout << "Node: " << node->rank << " - Task: " << k <<std::endl;
154  proj.setEulerAngles(mpiData[k].tRot, mpiData[k].tTilt,mpiData[k].tPsi);
155  proj.setShifts(mpiData[k].xShift, mpiData[k].yShift, mpiData[k].zShift);
156 
157  //Reset thread task distributor
158  td->clear();
159 
160  // Really project ....................................................
162  {
164  proj.write(mpiData[k].fn_proj);
165  }
166 
167  // Add noise in angles and voxels ....................................
168  // proj.setEulerAngles(mpiData[k].rot,mpiData[k].tilt,mpiData[k].psi); // Geo info is not stored in header file
169  IMGMATRIX(proj).addNoise(projParam.Npixel_avg, projParam.Npixel_dev, "gaussian");
170 
172  std::cout << "Node: " << node->rank << "\t" << proj.rot() << "\t"
173  << proj.tilt() << "\t" << proj.psi() << std::endl;
174 
175  if (node->isMaster() && !(projParam.show_angles))
176  progress_bar(k+1);
177  }
178  }
179  jobHandler->wait();
180 
181  postRun();
182 
183  return;
184 }
bool only_create_angles
Only create angles, do not project.
Definition: projection.h:81
void init_progress_bar(long total)
Rotation angle of an image (double,degrees)
#define YSIZE(v)
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: projection.h:101
Tilting angle of an image (double,degrees)
FileName fnOut
Output filename (used for a singleProjection)
Definition: projection.h:67
ParametersProjectionTomography projParam
Definition: project_xray.h:93
Projection stdProj
Definition: project_xray.h:106
double psi(const size_t n=0) const
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)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define MULTIDIM_ARRAY(v)
void compose(const String &str, const size_t no, const String &ext="")
void XrayRotateAndProjectVolumeOffCentered(XrayProjPhantom &phantom, XRayPSF &psf, Projection &P, Projection &standardP, int Ydim, int Xdim)
Special label to be used when gathering MDs in MpiMetadataPrograms.
Image< double > iniVol
Phantom Xmipp volume.
Definition: project_xray.h:65
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
double rot(const size_t n=0) const
#define IMGMATRIX(I)
void barrierWait()
Definition: xmipp_mpi.cpp:171
double tiltF
Maximum tilt around this axis.
Definition: projection.h:94
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
virtual void setComment(const String &newComment="No comment")
double tilt(const size_t n=0) const
MetaDataVec projMD
Definition: project_xray.h:107
Rotation angle of an image (double,degrees)
glob_log first
void setShifts(double xoff, double yoff, double zoff=0., const size_t n=0)
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
MpiNode * node
ParallelTaskDistributor * td
Definition: project_xray.h:108
double Ncenter_avg
Bias to apply to the image center.
Definition: projection.h:104
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
double Ncenter_dev
Standard deviation of the image center.
Definition: projection.h:106
#define XSIZE(v)
void progress_bar(long rlen)
void getEulerAngles(double &rot, double &tilt, double &psi, const size_t n=0) const
double Nangle_dev
Standard deviation of the angles.
Definition: projection.h:111
void createEmptyFile(const FileName &filename, int xdim, int ydim, int Zdim, size_t select_img, bool isStack, int mode, int _swapWrite, const MDRowVec *md)
int proj_Xdim
Projection Xdim.
Definition: projection.h:76
Projection proj
Definition: project_xray.h:106
void calculateProjectionAngles(Projection &P, double angle, double inplaneRot, const Matrix1D< double > &sinplane)
Definition: projection.cpp:277
Psi angle of an image (double,degrees)
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
FileName fnRoot
Root filename (used for a stack)
Definition: projection.h:65
size_t rank
Definition: xmipp_mpi.h:52
XrayProjPhantom phantom
Definition: project_xray.h:105
void setEulerAngles(double rot, double tilt, double psi, const size_t n=0)
bool singleProjection
Only project a single image.
Definition: projection.h:69
FileName fn_proj
double rnd_gaus()
#define VECTOR_R3(v, x, y, z)
Definition: matrix1d.h:124
bool isMaster() const
Definition: xmipp_mpi.cpp:166
#define FIRST_IMAGE
double tiltStep
Step in tilt.
Definition: projection.h:96
Shift for the image in the Y axis (double)
Name of an image (std::string)
double Nangle_avg
Bias to apply to the angles.
Definition: projection.h:109
void getShifts(double &xoff, double &yoff, double &zoff, const size_t n=0) const

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