CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
vAlgorithm.hh
Go to the documentation of this file.
1 /*
2 This file is part of CASToR.
3 
4  CASToR is free software: you can redistribute it and/or modify it under the
5  terms of the GNU General Public License as published by the Free Software
6  Foundation, either version 3 of the License, or (at your option) any later
7  version.
8 
9  CASToR is distributed in the hope that it will be useful, but WITHOUT ANY
10  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  details.
13 
14  You should have received a copy of the GNU General Public License along with
15  CASToR (in file GNU_GPL.TXT). If not, see <http://www.gnu.org/licenses/>.
16 
17 Copyright 2017-2019 all CASToR contributors listed below:
18 
19  --> Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Thibaut MERLIN, Mael MILLARDET, Simon STUTE, Valentin VIELZEUF
20 
21 This is CASToR version 3.0.
22 */
23 
30 #ifndef VALGORITHM_HH
31 #define VALGORITHM_HH 1
32 
33 #include "gVariables.hh"
35 #include "oProjectorManager.hh"
38 #include "oOptimizerManager.hh"
39 #include "oDeformationManager.hh"
40 #include "oDynamicModelManager.hh"
41 #include "oImageSpace.hh"
42 #include "vDataFile.hh"
43 #include "sChronoManager.hh"
44 
45 
52 {
53  // Constructor & Destructor
54  public:
60  vAlgorithm();
65  virtual ~vAlgorithm();
66 
67 
68 
69  // -------------------------------------------------------------------
70  // Public member functions
71  public:
77  int Run();
97  int RunCPU();
98  #ifdef CASTOR_GPU
99 
106  int RunGPU();
107  #endif
108 
113  inline void SetSaveSensitivityHistoFlag(bool a_saveSensitivityHistoFlag)
114  {m_saveSensitivityHistoFlag = a_saveSensitivityHistoFlag;}
120  inline void SetSaveSubsetImageFlag(bool a_saveImageAfterSubsets)
121  {m_saveImageAfterSubsets = a_saveImageAfterSubsets;}
127  inline void SetSaveDynamicBasisCoefficientImages(bool a_saveDynamicBasisCoefficients)
128  {m_saveDynamicBasisCoefficients = a_saveDynamicBasisCoefficients;}
134  inline void SetOptimizerManager(oOptimizerManager* ap_OptimizerManager)
135  {mp_OptimizerManager = ap_OptimizerManager;}
141  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
142  {mp_ID = ap_ImageDimensionsAndQuantification;}
148  inline void SetImageSpace(oImageSpace* ap_ImageSpace)
149  {mp_ImageSpace = ap_ImageSpace;}
155  inline void SetProjectorManager(oProjectorManager* ap_ProjectorManager)
156  {mp_ProjectorManager = ap_ProjectorManager;}
162  inline void SetImageConvolverManager(oImageConvolverManager* ap_ImageConvolverManager)
163  {mp_ImageConvolverManager = ap_ImageConvolverManager;}
169  inline void SetImageProcessingManager(oImageProcessingManager* ap_ImageProcessingManager)
170  {mp_ImageProcessingManager = ap_ImageProcessingManager;}
176  inline void SetDynamicModelManager(oDynamicModelManager* ap_DynamicModelManager)
177  {mp_DynamicModelManager = ap_DynamicModelManager;}
183  inline void SetDeformationManager(oDeformationManager* ap_DeformationManager)
184  {mp_DeformationManager = ap_DeformationManager;}
190  inline void SetDataFile(vDataFile** a2p_DataFile)
191  {m2p_DataFile = a2p_DataFile;}
197  inline void SetGPUflag(bool a_flagGPU)
198  {m_flagGPU = a_flagGPU;}
204  inline void SetVerbose(int a_verboseLevel)
205  {m_verbose = a_verboseLevel;}
211  inline void SetNbBeds(int a_nbBeds)
212  {m_nbBeds = a_nbBeds;}
218  inline void SetPathInitImage(string a_pathToInitialImage)
219  {m_pathToInitialImg = a_pathToInitialImage;}
225  inline void SetPathToAttenuationImage(string a_pathToAttenuationImage)
226  {m_pathToAtnImg = a_pathToAttenuationImage;}
232  inline void SetPathToSensitivityImage(string a_pathToSensitivityImage)
233  {m_pathToSensitivityImg = a_pathToSensitivityImage;}
239  inline void SetPathToMultiModalImage(vector<string> a_pathToMultiModalImage)
240  {m_pathToMultiModalImg = a_pathToMultiModalImage;}
246  inline void SetPathToMaskImage(string a_pathToMaskImage)
247  {m_pathToMaskImg = a_pathToMaskImage;}
256  int SetNbIterationsAndSubsets(const string& a_nbIterationsSubsets);
268  int SetOutputIterations(const string& a_outputIterations);
274  virtual int InitSpecificOptions(string a_specificOptions);
279  virtual void ShowHelpSpecific(){}
280 
281 
282  // -------------------------------------------------------------------
283  // Protected member functions
284  protected:
290  virtual int StepBeforeIterationLoop();
296  virtual int StepAfterIterationLoop();
303  virtual int StepBeforeSubsetLoop(int a_iteration);
310  virtual int StepAfterSubsetLoop(int a_iteration);
318  virtual int StepPreProcessInsideSubsetLoop(int a_iteration, int a_subset);
326  virtual int StepPostProcessInsideSubsetLoop(int a_iteration, int a_subset);
336  virtual int StepInnerLoopInsideSubsetLoop(int a_iteration, int a_subset, int a_bed) = 0;
341  virtual int StepImageOutput(int a_iteration, int a_subset = -1) = 0;
342 
343 
344  // -------------------------------------------------------------------
345  // Data members
346  protected:
350  int m_verbose;
351  bool m_flagGPU;
361  int m_nbBeds;
363  string m_pathToAtnImg;
365  vector<string> m_pathToMultiModalImg;
372 };
373 
374 #endif
375 
376 
377 
378 
379 
380 
381 
382 
383 
384 
385 
386 
387 
void SetImageConvolverManager(oImageConvolverManager *ap_ImageConvolverManager)
Set the Image Convolver Manager Object.
Definition: vAlgorithm.hh:162
oImageConvolverManager * mp_ImageConvolverManager
Definition: vAlgorithm.hh:359
This class is designed to be a mother virtual class for DataFile.
Definition: vDataFile.hh:102
This header file is mainly used to declare some macro definitions and all includes needed from the st...
Declaration of class oDynamicModelManager.
oOptimizerManager * mp_OptimizerManager
Definition: vAlgorithm.hh:355
Declaration of class oImageDimensionsAndQuantification.
virtual void ShowHelpSpecific()
Show help for the child algorithm.
Definition: vAlgorithm.hh:279
virtual int InitSpecificOptions(string a_specificOptions)
Definition: vAlgorithm.cc:516
oImageProcessingManager * mp_ImageProcessingManager
Definition: vAlgorithm.hh:360
void SetPathToAttenuationImage(string a_pathToAttenuationImage)
This function is used to set the path to the attenuation image.
Definition: vAlgorithm.hh:225
int SetNbIterationsAndSubsets(const string &a_nbIterationsSubsets)
Set the number of iterations and subsets.
Definition: vAlgorithm.cc:85
void SetImageSpace(oImageSpace *ap_ImageSpace)
Set the Image Space Object.
Definition: vAlgorithm.hh:148
void SetSaveSensitivityHistoFlag(bool a_saveSensitivityHistoFlag)
Set the flag that specifies if the sensitivity image in histogram mode has to be saved for each subse...
Definition: vAlgorithm.hh:113
void SetOptimizerManager(oOptimizerManager *ap_OptimizerManager)
Set the Optimizer Manager Object.
Definition: vAlgorithm.hh:134
void SetSaveDynamicBasisCoefficientImages(bool a_saveDynamicBasisCoefficients)
Set the flag that specifies if the dynamic basis functions coefficients images have to be saved...
Definition: vAlgorithm.hh:127
string m_pathToAtnImg
Definition: vAlgorithm.hh:363
Declaration of class oDeformationManager.
int RunCPU()
Perform the iterative loop of the algorithm. Function designed to be executed on the CPU only...
Definition: vAlgorithm.cc:252
oProjectorManager * mp_ProjectorManager
Definition: vAlgorithm.hh:354
This class is designed to manage the optimization part of an iterative reconstruction.
virtual int StepBeforeSubsetLoop(int a_iteration)
This function is called before starting the data subset loop.
Definition: vAlgorithm.cc:439
int Run()
Just call either the RunCPU or the RunGPU function as asked for.
Definition: vAlgorithm.cc:233
bool m_saveSensitivityHistoFlag
Definition: vAlgorithm.hh:367
int m_nbIterations
Definition: vAlgorithm.hh:347
virtual int StepInnerLoopInsideSubsetLoop(int a_iteration, int a_subset, int a_bed)=0
This function is called inside the subset loop. It contains the core operations of the algorithm an...
void SetPathToMaskImage(string a_pathToMaskImage)
Set path to a mask image.
Definition: vAlgorithm.hh:246
int * mp_nbSubsets
Definition: vAlgorithm.hh:348
virtual int StepImageOutput(int a_iteration, int a_subset=-1)=0
This function deals with everything about saving output images from the reconstruction.
Definition: vAlgorithm.cc:505
oImageSpace * mp_ImageSpace
Definition: vAlgorithm.hh:358
void SetDynamicModelManager(oDynamicModelManager *ap_DynamicModelManager)
Set the Dynamic Model Manager Object.
Definition: vAlgorithm.hh:176
virtual int StepPostProcessInsideSubsetLoop(int a_iteration, int a_subset)
Definition: vAlgorithm.cc:461
Declaration of class oImageConvolverManager.
vAlgorithm()
vAlgorithm constructor. Initialize the member variables to their default values.
Definition: vAlgorithm.cc:39
vDataFile ** m2p_DataFile
Definition: vAlgorithm.hh:353
void SetPathToMultiModalImage(vector< string > a_pathToMultiModalImage)
Set path to multimodal images.
Definition: vAlgorithm.hh:239
void SetPathInitImage(string a_pathToInitialImage)
Set path to an initial image.
Definition: vAlgorithm.hh:218
bool m_saveDynamicBasisCoefficients
Definition: vAlgorithm.hh:369
string m_pathToSensitivityImg
Definition: vAlgorithm.hh:364
void SetGPUflag(bool a_flagGPU)
Set the GPU flag.
Definition: vAlgorithm.hh:197
string m_pathToInitialImg
Definition: vAlgorithm.hh:362
This class is designed to manage the use of dynamic model in the reconstruction.
Declaration of class vDataFile.
void SetNbBeds(int a_nbBeds)
Set number of beds (bed positions)
Definition: vAlgorithm.hh:211
oDynamicModelManager * mp_DynamicModelManager
Definition: vAlgorithm.hh:357
virtual int StepPreProcessInsideSubsetLoop(int a_iteration, int a_subset)
This function is called right after starting the data subset loop.
Definition: vAlgorithm.cc:450
virtual int StepBeforeIterationLoop()
This function is called at the beginning of the RunCPU function.
Definition: vAlgorithm.cc:388
bool m_saveImageAfterSubsets
Definition: vAlgorithm.hh:368
virtual ~vAlgorithm()
vAlgorithm destructor.
Definition: vAlgorithm.cc:73
This class is designed to manage the different image convolvers and to apply them.
void SetSaveSubsetImageFlag(bool a_saveImageAfterSubsets)
Set the flag that specifies if the image has to be saved for each subset.
Definition: vAlgorithm.hh:120
void SetDataFile(vDataFile **a2p_DataFile)
Set the list of DataFile.
Definition: vAlgorithm.hh:190
void SetImageProcessingManager(oImageProcessingManager *ap_ImageProcessingManager)
Set the Image Processing Manager Object.
Definition: vAlgorithm.hh:169
string m_pathToMaskImg
Definition: vAlgorithm.hh:366
bool m_flagGPU
Definition: vAlgorithm.hh:351
oDeformationManager * mp_DeformationManager
Definition: vAlgorithm.hh:356
void SetPathToSensitivityImage(string a_pathToSensitivityImage)
Set path to the sensitivity image.
Definition: vAlgorithm.hh:232
virtual int StepAfterSubsetLoop(int a_iteration)
This function is called after finishing the data subset loop.
Definition: vAlgorithm.cc:472
This class is designed to manage the image-based deformation part of the reconstruction.
oImageDimensionsAndQuantification * mp_ID
Definition: vAlgorithm.hh:352
Declaration of class oImageSpace.
This class is designed to manage the different image processing modules and to apply them...
vector< string > m_pathToMultiModalImg
Definition: vAlgorithm.hh:365
This class is designed to manage the projection part of the reconstruction.
virtual int StepAfterIterationLoop()
This function is called at the end of the RunCPU function.
Definition: vAlgorithm.cc:483
Declaration of class oImageProcessingManager.
void SetProjectorManager(oProjectorManager *ap_ProjectorManager)
Set the Projector Manager Object.
Definition: vAlgorithm.hh:155
This is the base class for reconstructions, containing a framework with iteration and data subset loo...
Definition: vAlgorithm.hh:51
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:60
void SetVerbose(int a_verboseLevel)
Set Verbosity.
Definition: vAlgorithm.hh:204
int SetOutputIterations(const string &a_outputIterations)
Set the selected output iterations.
Definition: vAlgorithm.cc:144
This class is designed to manage all dimensions and quantification related stuff. ...
Declaration of class sChronoManager.
Declaration of class oOptimizerManager.
bool * mp_outputIterations
Definition: vAlgorithm.hh:349
void SetDeformationManager(oDeformationManager *ap_DeformationManager)
Set the Deformation Manager Object.
Definition: vAlgorithm.hh:183
Declaration of class oProjectorManager.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the Image Dimensions and Quantification Object.
Definition: vAlgorithm.hh:141