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

#include <reconstruct_art.h>

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

Public Member Functions

 ProgReconsART ()
 
 ~ProgReconsART ()
 
void setIO (const FileName &fn_in, const FileName &fn_out)
 Functions of common reconstruction interface. More...
 
void defineParams ()
 
void readParams ()
 
void show ()
 
void run ()
 
- Public Member Functions inherited from ProgReconsBase
virtual ~ProgReconsBase ()
 
- 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 Attributes

ARTReconsBaseartRecons
 
bool isMpi
 
- 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 Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Detailed Description

Definition at line 38 of file reconstruct_art.h.

Constructor & Destructor Documentation

◆ ProgReconsART()

ProgReconsART::ProgReconsART ( )

Definition at line 32 of file reconstruct_art.cpp.

33 {
34  isMpi = false;
35  artRecons = nullptr;
36 }
ARTReconsBase * artRecons

◆ ~ProgReconsART()

ProgReconsART::~ProgReconsART ( )

Definition at line 37 of file reconstruct_art.cpp.

38 {
39  delete artRecons;
40 }
ARTReconsBase * artRecons

Member Function Documentation

◆ defineParams()

void ProgReconsART::defineParams ( )
virtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 45 of file reconstruct_art.cpp.

46 {
47  addUsageLine("Generate 3D reconstructions from projections using the ART algorithm (even with SIRT).");
48  addUsageLine("+A history file with the information of the reconstruction process is created. You can ");
49  addUsageLine("+also give symmetry elements to specify different points of view reusing the projections ");
50  addUsageLine("+you have. The reconstruction is performed using some basis (blobs or voxels) in ");
51  addUsageLine("+different grids (BCC (by default), FCC or CC).");
52 
54 
55  addParamsLine(" == Special Parameters for crystals == ");
57 
58  addExampleLine("+++* Basis volume definition: The basis volume is defined internally such that it should cover ",false);
59  addExampleLine("+++the space cube corresponding to =(-Xdim/2,-Xdim/2,-Xdim/2)= to =(X dim /2,Xdim/2,Xdim/2)= where Xdim ",false);
60  addExampleLine("+++is the X dimension of the projections.", false);
61  addExampleLine("+++* Voxel volume definition: The final reconstructed volume is defined in such a way that it ", false);
62  addExampleLine("+++covers the whole basis volume. For these two definitions and the fact that the basis has got ", false);
63  addExampleLine("+++some radius (normally 2) the final reconstructions are a little wider than the original ",false);
64  addExampleLine("+++projections (usually =2*radius+1=)",false);
65  addExampleLine("+++* Crystal reconstructions: Crystal projections must be the deformed projections of the ",false);
66  addExampleLine("+++deformed volume. I mean, the lattice vectors of the volume to reconstruct need not to lie ",false);
67  addExampleLine("+++on a grid point inside the BCC, FCC or CC grid. If we ant to force that they lie on a grid ",false);
68  addExampleLine("+++point we have to deform the volume. When he have this deformed volume and we project it, the ",false);
69  addExampleLine("+++two 3D lattice vectors project to two different 2D lattice vectors, that in principle there ",false);
70  addExampleLine("+++is no relationship between them. We must force this two 2D lattice vectors to align with ",false);
71  addExampleLine("+++=a=(Xdim,0)= and =b=(0,Ydim)= by deforming the projection. This is the second deformation. ",false);
72  addExampleLine("+++This complex projections are either generated from phantoms using the program Project or ",false);
73  addExampleLine("+++from lists of Fourier spots coming out from MRC as APH files by applying the program ",false);
74  addExampleLine("+++Spots2RealSpace2D.",false);
75  addExampleLine("+++* Surface constraints: These constraints force the volume to be 0 at known places. ",false);
76  addExampleLine("+++This has got the beneficial consequence that mass tends to be compacted where it should be.",false);
77  addExampleLine("+++* Grids: This program defines three grids for working with data. The typical simple cubic grid, ",false);
78  addExampleLine("+++the face-centered grid (fcc) and the body-centered cubic grid (bcc). We define these grids as follows: ",false);
79  addExampleLine("+++| Simple Cubic Grid | %ATTACHURL%/image004.gif |",false);
80  addExampleLine("+++| Face-centered cubic grid | %ATTACHURL%/image008.gif |",false);
81  addExampleLine("+++| Body-centered cubic grid | %ATTACHURL%/image006.gif |",false);
82  addExampleLine("+++where %ATTACHURL%/image010.gif is the set of integers and %ATTACHURL%/image002.gif is a positive ",false);
83  addExampleLine("+++real number called sampling distance. See =Gabor H., Geometry of Digital Spaces, Birkhauser, 1998, Massachussets=",false);
84  addExampleLine("+++Spots2RealSpace2D. %BR%",false);
85  addExampleLine("+++In the case of the simple cubic grid the voxels are cubes of volume %ATTACHURL%/image013.gif ³",false);
86  addExampleLine("+++. The voxels associated to the bcc grid are truncated octahedra, polyhedra of 8 hexagonal ",false);
87  addExampleLine("+++faces and 6 square faces, of volume 4 %ATTACHURL%/image013.gif ³ .Finally, the voxels associated ",false);
88  addExampleLine("+++to the fcc grid are rhombic dodacehedra, polyhedra of 12 identical rhombic faces, of volume 2 ",false);
89  addExampleLine("+++%ATTACHURL%/image013.gif ³. However, in practice the above definitions are implemented using a ",false);
90  addExampleLine("+++combination of simple cubic grids. Clearly, a simple cubic grid defines the complex simple cubic ",false);
91  addExampleLine("+++grid and thus the relative size used in the implementation is exactly the %ATTACHURL%/image013.gif ³. ",false);
92  addExampleLine("+++For defining the bcc grid two simple cubic grids are used, it can be seen from the definition for ",false);
93  addExampleLine("+++the bcc above that the valid positions for even values of =z=, =x= and =y= have to be also even, ",false);
94  addExampleLine("+++in the case of odd values of =z= , =x= and =y= have to be odd. Consequently, the relative size used ",false);
95  addExampleLine("+++in the BCC grid is equivalent to 2 %ATTACHURL%/image013.gif above. For defining the fcc grid four ",false);
96  addExampleLine("+++simple cubic grids are used, it can be seen from the definition for the fcc above that the valid ",false);
97  addExampleLine("+++positions for even values of =z=, the sum of =x= and =y= has to be even; in the case of odd values ",false);
98  addExampleLine("+++of =z= the sum of =x= and =y= has to be odd. Consequently, the relative size used in the FCC grid ",false);
99  addExampleLine("+++is equivalent to 2 %ATTACHURL%/image013.gif above. %BR%",false);
100  addExampleLine(" ",false); // For style twiki reasons
101  addExampleLine("Basic reconstructing commands:",false);
102  addExampleLine("reconstruct_art -i projections.sel -o artrec");
103  addExampleLine("Create the equivalent noisy reconstruction:",false);
104  addExampleLine("reconstruct_art -i projections.sel -o artrec --noisy_reconstruction");
105  // addExampleLine("Reconstruct using SIRT parallelization algorithm for five iterations:",false);
106  // addExampleLine("reconstruct_art -i projections.sel -o artrec -n 5 --parallel_mode SIRT");
107  addExampleLine("Save the basis information at each iteration:",false);
108  addExampleLine("reconstruct_art -i projections.sel -o artrec -n 3 --save_basis");
109 }
static void defineParams(XmippProgram *program, bool mpiMode=false)
void addExampleLine(const char *example, bool verbatim=true)
static void defineParams(XmippProgram *program, const char *prefix=nullptr, const char *comment=nullptr)
Definition: art_crystal.cpp:36
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgReconsART::readParams ( )
virtual

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 111 of file reconstruct_art.cpp.

112 {
113 
114 
115  if (checkParam("--crystal"))
117  else
119 
120  artRecons->readParams(this);
121 
122  if (artRecons->artPrm.threads > 1 && isMpi)
123  REPORT_ERROR(ERR_ARG_BADCMDLINE, "Threads not compatible in mpi version.");
125  REPORT_ERROR(ERR_ARG_BADCMDLINE, "If --parallel_mode is passed, then mpi version must be used.");
126 
127 }
Errors on command line parameters.
Definition: xmipp_error.h:112
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
virtual void readParams(XmippProgram *program)
ARTReconsBase * artRecons
ARTParallelMode parallel_mode
Definition: basic_art.h:109
bool checkParam(const char *param)
BasicARTParameters artPrm
int threads
Number of threads to use. Can not be different than 1 when using MPI.
Definition: basic_art.h:267

◆ run()

void ProgReconsART::run ( )
virtual

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

Reimplemented from XmippProgram.

Definition at line 146 of file reconstruct_art.cpp.

147 {
149 
150  Image<double> vol_voxels;
151  GridVolume vol_basis;
152  // Configure time clock
153  time_config();
154 
155  struct timeval start_time, end_time;
156  long int init_usecs, process_usecs, finish_usecs;
157 
158  gettimeofday(&start_time, nullptr);
159 
160  show();
161  // Produce side information and initial volume
162  artRecons->preProcess(vol_basis);
163  if (verbose > 0)
164  {
165  std::cout << " ---------------------------------------------------------------------" << std::endl;
166  std::cout << " Projections : " << artRecons->artPrm.numIMG << std::endl;
167  std::cout << " ---------------------------------------------------------------------" << std::endl;
168  }
169  // Show parameters and initiate history
170  artRecons->initHistory(vol_basis);
171 
172  gettimeofday(&end_time, nullptr);
173 
174  init_usecs = (end_time.tv_sec-start_time.tv_sec)*1000000+(end_time.tv_usec-start_time.tv_usec);
175 
176  gettimeofday(&start_time,nullptr);
177 
178  // Iterations
179  artRecons->iterations(vol_basis);
180 
181 
182  gettimeofday(&end_time,nullptr);
183 
184  process_usecs = (end_time.tv_sec-start_time.tv_sec)*1000000+(end_time.tv_usec-start_time.tv_usec);
185 
186  gettimeofday(&start_time,nullptr);
187 
188  // Finish iterations
189  artRecons->postProcess(vol_basis);
190 
191  // Write final volume
192  int Xoutput_volume_size=(artPrm.Xoutput_volume_size==0) ?
193  artPrm.projXdim:artPrm.Xoutput_volume_size;
194  int Youtput_volume_size=(artPrm.Youtput_volume_size==0) ?
195  artPrm.projYdim:artPrm.Youtput_volume_size;
196  int Zoutput_volume_size=(artPrm.Zoutput_volume_size==0) ?
197  artPrm.projXdim:artPrm.Zoutput_volume_size;
198 
199  // int min_distance = ceil( ( 2 * artPrm.grid_relative_size ) / artPrm.basis.blob.radius) + 1;
200 
201  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
202  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size,artPrm.threads);
203 
204  vol_voxels.write(artPrm.fn_out);
205 
206  if (artPrm.tell&TELL_SAVE_BASIS)
207  vol_basis.write(artPrm.fn_root+".basis");
208  artPrm.fh_hist->close();
209 
210  gettimeofday(&end_time,nullptr);
211 
212  finish_usecs = (end_time.tv_sec-start_time.tv_sec)*1000000+(end_time.tv_usec-start_time.tv_usec);
213 
214  std::cout << "INIT_TIME: " << (double)init_usecs/(double)1000000 << std::endl;
215  std::cout << "PROCESS_TIME: " << (double)process_usecs/(double)1000000 << std::endl;
216  std::cout << "FINISH_TIME: " << (double)finish_usecs/(double)1000000 << std::endl;
217 
218 }
int numIMG
Total number of images to process (taking symmetries into account)
Definition: basic_art.h:348
size_t projXdim
Projection X dimension.
Definition: basic_art.h:333
Basis basis
Basis function. By default, blobs.
Definition: basic_art.h:97
void initHistory(const GridVolume &vol_basis0)
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 TELL_SAVE_BASIS
Definition: basic_art.h:276
std::ofstream * fh_hist
File handler for the history file.
Definition: basic_art.h:339
size_t projYdim
Projection Y dimension.
Definition: basic_art.h:336
void changeToVoxels(GridVolume &vol_basis, MultidimArray< double > *vol_voxels, int Zdim, int Ydim, int Xdim, int threads=1) const
Definition: basis.cpp:261
void time_config()
virtual void postProcess(GridVolume &vol_basis)
ARTReconsBase * artRecons
virtual void preProcess(GridVolume &vol_basis0, int level=FULL, int rank=-1)
Produce Plain side information from the Class parameters.
int verbose
Verbosity level.
FileName fn_root
Definition: basic_art.h:217
void write(const FileName &fn) const
Definition: grids.h:1196
void iterations(GridVolume &vol_basis, int rank=-1)
BasicARTParameters artPrm
int threads
Number of threads to use. Can not be different than 1 when using MPI.
Definition: basic_art.h:267
FileName fn_out
Name of the output volume, also used to set the root of rest output files.
Definition: basic_art.h:217

◆ setIO()

void ProgReconsART::setIO ( const FileName fn_in,
const FileName fn_out 
)
virtual

Functions of common reconstruction interface.

Implements ProgReconsBase.

Definition at line 42 of file reconstruct_art.cpp.

43 {}

◆ show()

void ProgReconsART::show ( )

Definition at line 129 of file reconstruct_art.cpp.

130 {
131  if (verbose > 0)
132  {
133  std::cout << " =====================================================================" << std::endl;
134  std::cout << " ART reconstruction method " << std::endl;
135  std::cout << " =====================================================================" << std::endl;
136  std::cout << " Projections file : " << artRecons->artPrm.fn_sel << std::endl;
137  std::cout << " Output rootname : " << artRecons->artPrm.fn_root << std::endl;
138  std::cout << " Iterations : " << artRecons->artPrm.no_it << std::endl;
139  std::cout << " Lambda : " << artRecons->artPrm.lambda_list(0) << std::endl;
140  std::cout << std::endl;
141  std::cout << " More info in the history file: " << artRecons->artPrm.fn_root + ".hist" << std::endl;
142  std::cout << " ---------------------------------------------------------------------\n" << std::endl;
143  }
144 }
FileName fn_sel
Selection file with all images to process.
Definition: basic_art.h:208
ARTReconsBase * artRecons
int verbose
Verbosity level.
FileName fn_root
Definition: basic_art.h:217
int no_it
Number of iterations.
Definition: basic_art.h:100
BasicARTParameters artPrm
Matrix1D< double > lambda_list
Relaxation parameter.
Definition: basic_art.h:103

Member Data Documentation

◆ artRecons

ARTReconsBase* ProgReconsART::artRecons
protected

Definition at line 41 of file reconstruct_art.h.

◆ isMpi

bool ProgReconsART::isMpi
protected

Definition at line 42 of file reconstruct_art.h.


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