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

#include <project_xray.h>

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

Public Member Functions

virtual 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_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 Member Functions

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

Additional Inherited Members

- 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 82 of file project_xray.h.

Member Function Documentation

◆ defineParams()

void ProgXrayProject::defineParams ( )
protectedvirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Reimplemented in ProgMPIXrayProject.

Definition at line 28 of file project_xray.cpp.

29 {
30  addUsageLine("Generate projections as in a X-ray microscope from a 3D Xmipp volume.");
31  addSeeAlsoLine("phantom_create");
32  //Params
33  projParam.defineParams(this); // Projection parameters
34  addParamsLine("== Xray options == ");
35  addParamsLine(" [--sampling_rate <Ts>] : Sampling rate of the volume to be projected (nm).");
36  addParamsLine(" : If empty, same value as X-Y plane sampling from PSF.");
37  addParamsLine("alias -s;");
38  addParamsLine("[--psf <psf_param_file=\"\">] : XRay-Microscope parameters file. If not set, then default parameters are chosen.");
39  addParamsLine("[--focal_shift+ <delta_z=0.0>] : Shift along optical axis between the center of the phantom and the center of the psf in microns");
40  addParamsLine("alias -f;");
41  addParamsLine("[--threshold+ <thr=0.0>] : Normalized threshold relative to maximum of PSF to reduce the volume into slabs");
42  addParamsLine("[--std_proj] : Save also standard projections, adding _std suffix to filenames");
43  addParamsLine("[--thr <threads=1>] : Number of concurrent threads");
44  //Examples
45  //Example projection file
46  addExampleLine("In the following link you can find an example of projection parameter file:",false);
47  addExampleLine(" ",false);
48  addExampleLine("http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/tomoProjection.param?format=raw",false);
49  addExampleLine(" ",false);
50  addExampleLine("In the following link you can find an example of X-ray microscope parameters file:",false);
51  addExampleLine(" ",false);
52  addExampleLine("http://sourceforge.net/p/testxmipp/code/ci/master/tree/input/xray_psf.xmd?format=raw",false);
53 
54 }
void defineParams(XmippProgram *program)
Definition: projection.cpp:74
ParametersProjectionTomography projParam
Definition: project_xray.h:93
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)

◆ postRun()

void ProgXrayProject::postRun ( )
protected

Definition at line 99 of file project_xray.cpp.

100 {
101  //Terminate threads and free memory
102  // if (td != NULL)
103  // delete td;
104  delete thMgr;
105  delete barrier;
106 }
ThreadManager * thMgr
Barrier * barrier

◆ preRun()

void ProgXrayProject::preRun ( )
protected

Definition at line 81 of file project_xray.cpp.

82 {
84 
87  //Correct the rotation axis displacement in projectionParams from pixels to meters
89 
90  // Threads stuff
91 
92  barrier = new Barrier(nThr);
93 
94  //Create threads to start working
95  thMgr = new ThreadManager(nThr);
96 
97 }
ParametersProjectionTomography projParam
Definition: project_xray.h:93
ThreadManager * thMgr
double dxo
object space XY-plane sampling rate
Definition: psf_xr.h:197
Matrix1D< double > raxis
Offset of the tilt axis.
Definition: projection.h:90
Barrier * barrier
double psfThr
threshold for psfSlabs
Definition: project_xray.h:97
void calculateParams(double _dxo, double _dzo=-1, double threshold=0.)
Produce Side information.
Definition: psf_xr.cpp:279
XrayProjPhantom phantom
Definition: project_xray.h:105
int nThr
Number of threads;.
Definition: project_xray.h:101
void read(const ParametersProjectionTomography &prm)
unsigned int randomize_random_generator()

◆ readParams()

void ProgXrayProject::readParams ( )
protectedvirtual

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 57 of file project_xray.cpp.

58 {
59  // fn_proj_param = getParam("-i");
60  // fn_sel_file = getParam("-o");
61  projParam.readParams(this);
62 
63  fn_psf_xr = getParam("--psf");
64  dxo = (checkParam("-s"))? getDoubleParam("-s")*1e-9 : -1 ;
65  psfThr = getDoubleParam("--threshold");
66  nThr = getIntParam("--thr");
67  save_std_projs = checkParam("--std_proj");
68 
70  psf.setFocalShift(getDoubleParam("--focal_shift")*1e-6);
72  psf.nThr = nThr;
73 }
ParametersProjectionTomography projParam
Definition: project_xray.h:93
double getDoubleParam(const char *param, int arg=0)
void readParams(XmippProgram *program)
Definition: projection.cpp:97
void setFocalShift(double zShift)
Add focal shift to previously read psf zshift.
Definition: psf_xr.cpp:273
int nThr
Definition: psf_xr.h:215
FileName fn_psf_xr
Filename with the Microscope Parameters.
Definition: project_xray.h:91
const char * getParam(const char *param, int arg=0)
void read(const FileName &fn, bool readVolume=true)
Definition: psf_xr.cpp:82
bool save_std_projs
Save standard projections.
Definition: project_xray.h:103
double psfThr
threshold for psfSlabs
Definition: project_xray.h:97
int verbose
Switch to control verbose mode.
Definition: psf_xr.h:212
int verbose
Verbosity level.
int nThr
Number of threads;.
Definition: project_xray.h:101
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgXrayProject::run ( )
virtual

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

Reimplemented from XmippProgram.

Reimplemented in ProgMPIXrayProject.

Definition at line 108 of file project_xray.cpp.

109 {
110  preRun();
111 
112  int expectedNumProjs = FLOOR((projParam.tiltF-projParam.tilt0)/projParam.tiltStep);
113  int numProjs=0;
114 
115  if (verbose > 0)
116  {
117  std::cerr << "Projecting ...\n";
118  if (!(projParam.show_angles))
119  init_progress_bar(expectedNumProjs);
120  }
121  projMD.setComment("True rot, tilt and psi; rot, tilt, psi, X and Y shifts applied");
122  double tRot,tTilt,tPsi,rot,tilt,psi;
123  FileName fn_proj; // Projection name
124  size_t idx = FIRST_IMAGE;
125 
126  // Project
127  for (double angle=projParam.tilt0; angle<=projParam.tiltF; angle+=projParam.tiltStep)
128  {
130  fn_proj = projParam.fnOut;
131  else
132  fn_proj.compose(idx, projParam.fnRoot + ".stk");
133 
134  // Choose Center displacement ........................................
137  Matrix1D<double> inPlaneShift(3);
138  VECTOR_R3(inPlaneShift,shiftX,shiftY,0);
139 
140  projParam.calculateProjectionAngles(proj,angle, 0,inPlaneShift);
141 
142  //Reset thread task distributor
143  // td->clear();
144 
145  // Really project ....................................................
148 
149  // Add noise in angles and voxels ....................................
150  proj.getEulerAngles(tRot, tTilt,tPsi);
151 
155 
156  proj.setEulerAngles(rot,tilt,psi);
157 
158  size_t objId = projMD.addObject();
160  {
161  // Here we subtract the differences to the background illumination (at this moment normalized to 1) //TODO
164 
165  if (save_std_projs)
167 
168  projMD.setValue(MDL_IMAGE,fn_proj,objId);
169  }
170 
171  projMD.setValue(MDL_ANGLE_ROT,rot,objId);
172  projMD.setValue(MDL_ANGLE_TILT,tilt,objId);
173  projMD.setValue(MDL_ANGLE_PSI,psi,objId);
174  projMD.setValue(MDL_ANGLE_ROT2,tRot,objId);
175  projMD.setValue(MDL_ANGLE_TILT2,tTilt,objId);
176  projMD.setValue(MDL_ANGLE_PSI2,tPsi,objId);
177  projMD.setValue(MDL_SHIFT_X,shiftX,objId);
178  projMD.setValue(MDL_SHIFT_Y,shiftY,objId);
179 
180  IMGMATRIX(proj).addNoise(projParam.Npixel_avg, projParam.Npixel_dev, "gaussian");
181 
182  // Save ..............................................................
184  {
185  std::cout << "N Rot Tilt Psi" <<std::endl;
186  std::cout << idx << "\t" << proj.rot() << "\t"
187  << proj.tilt() << "\t" << proj.psi() << std::endl;
188  }
189  else if ((expectedNumProjs % XMIPP_MAX(1, numProjs / 60)) == 0 && verbose > 0)
190  progress_bar(numProjs);
191 
192  numProjs++;
193  idx++;
194  }
195  if (!(projParam.show_angles))
196  progress_bar(expectedNumProjs);
197 
198  // Save metadata file with angles and shift info
200  {
201  projMD.setComment("Angles rot,tilt and psi contain noisy projection angles and rot2,tilt2 and psi2 contain actual projection angles");
202  projMD.write(projParam.fnRoot + ".xmd");
203  }
204 
205  postRun();
206 
207  return;
208 }
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)
double Npixel_dev
Standard deviation of the noise to be added to each pixel grey value.
Definition: projection.h:101
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
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)
FileName insertBeforeExtension(const String &str) const
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.
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
double rot(const size_t n=0) const
#define IMGMATRIX(I)
double tiltF
Maximum tilt around this axis.
Definition: projection.h:94
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)
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 FLOOR(x)
Definition: xmipp_macros.h:240
bool save_std_projs
Save standard projections.
Definition: project_xray.h:103
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
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
int verbose
Verbosity level.
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)
FileName fnRoot
Root filename (used for a stack)
Definition: projection.h:65
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
double psi(const double x)
double rnd_gaus()
#define VECTOR_R3(v, x, y, z)
Definition: matrix1d.h:124
#define ALL_IMAGES
#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

Member Data Documentation

◆ dxo

double ProgXrayProject::dxo

Definition at line 99 of file project_xray.h.

◆ fn_proj_param

FileName ProgXrayProject::fn_proj_param

Filename with the Projection_Parameters.

Definition at line 87 of file project_xray.h.

◆ fn_psf_xr

FileName ProgXrayProject::fn_psf_xr

Filename with the Microscope Parameters.

Definition at line 91 of file project_xray.h.

◆ fn_sel_file

FileName ProgXrayProject::fn_sel_file

Selection file with all projections.

Definition at line 89 of file project_xray.h.

◆ nThr

int ProgXrayProject::nThr

Number of threads;.

Definition at line 101 of file project_xray.h.

◆ phantom

XrayProjPhantom ProgXrayProject::phantom

Definition at line 105 of file project_xray.h.

◆ proj

Projection ProgXrayProject::proj

Definition at line 106 of file project_xray.h.

◆ projMD

MetaDataVec ProgXrayProject::projMD

Definition at line 107 of file project_xray.h.

◆ projParam

ParametersProjectionTomography ProgXrayProject::projParam

Definition at line 93 of file project_xray.h.

◆ psf

XRayPSF ProgXrayProject::psf

Definition at line 95 of file project_xray.h.

◆ psfThr

double ProgXrayProject::psfThr

threshold for psfSlabs

Definition at line 97 of file project_xray.h.

◆ save_std_projs

bool ProgXrayProject::save_std_projs

Save standard projections.

Definition at line 103 of file project_xray.h.

◆ stdProj

Projection ProgXrayProject::stdProj

Definition at line 106 of file project_xray.h.

◆ td

ParallelTaskDistributor* ProgXrayProject::td

Definition at line 108 of file project_xray.h.


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