CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
oIterativeAlgorithm.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-2018 all CASToR contributors listed below:
18 
19  --> current contributors: Thibaut MERLIN, Simon STUTE, Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Mael MILLARDET
20  --> past contributors: Valentin VIELZEUF
21 
22 This is CASToR version 2.0.
23 */
24 
31 #ifndef OITERATIVEALGORITHM_HH
32 #define OITERATIVEALGORITHM_HH 1
33 
34 #include "gVariables.hh"
36 #include "oProjectorManager.hh"
39 #include "oOptimizerManager.hh"
40 #include "oDeformationManager.hh"
41 #include "oDynamicModelManager.hh"
42 #include "oImageSpace.hh"
43 #include "vDataFile.hh"
44 #include "sChronoManager.hh"
45 
46 
47 
54 {
55  // Constructor & Destructor
56  public:
67  virtual ~oIterativeAlgorithm();
68 
69 
70 
71  // -------------------------------------------------------------------
72  // Public member functions
73  public:
79  int Iterate();
101  int IterateCPU();
102  #ifdef CASTOR_GPU
103 
111  int IterateGPU();
112  #endif
113 
118  inline void SetSaveSensitivityHistoFlag(bool a_saveSensitivityHistoFlag) {m_saveSensitivityHistoFlag = a_saveSensitivityHistoFlag;}
124  inline void SetSaveSubsetImageFlag(bool a_saveImageAfterSubsets) {m_saveImageAfterSubsets = a_saveImageAfterSubsets;}
130  inline void SetOptimizerManager(oOptimizerManager* ap_OptimizerManager) {mp_OptimizerManager = ap_OptimizerManager;}
136  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification) {mp_ID = ap_ImageDimensionsAndQuantification;};
142  inline void SetImageSpace(oImageSpace* ap_ImageSpace) {mp_ImageSpace = ap_ImageSpace;};
148  inline void SetProjectorManager(oProjectorManager* ap_ProjectorManager) {mp_ProjectorManager = ap_ProjectorManager;};
154  inline void SetImageConvolverManager(oImageConvolverManager* ap_ImageConvolverManager) {mp_ImageConvolverManager = ap_ImageConvolverManager;}
160  inline void SetImageProcessingManager(oImageProcessingManager* ap_ImageProcessingManager) {mp_ImageProcessingManager = ap_ImageProcessingManager;}
166  inline void SetDynamicModelManager(oDynamicModelManager* ap_DynamicModelManager) {mp_DynamicModelManager = ap_DynamicModelManager;}
172  inline void SetDeformationManager(oDeformationManager* ap_DeformationManager) {mp_DeformationManager = ap_DeformationManager;}
178  inline void SetDataFile(vDataFile** a2p_DataFile) {m2p_DataFile = a2p_DataFile;};
184  inline void SetGPUflag(bool a_flagGPU) {m_flagGPU = a_flagGPU;};
190  inline void SetVerbose(int a_verboseLevel) {m_verbose = a_verboseLevel;};
196  inline void SetNbBeds(int a_nbBeds) {m_nbBeds = a_nbBeds;};
202  inline void SetPathInitImage(string a_pathToInitialImage) {m_pathToInitialImg = a_pathToInitialImage;};
208  inline void SetPathToAttenuationImage(string a_pathToAttenuationImage) {m_pathToAtnImg = a_pathToAttenuationImage;};
214  inline void SetPathToSensitivityImage(string a_pathToSensitivityImage) {m_pathToSensitivityImg = a_pathToSensitivityImage;};
220  inline void SetPathToMultiModalImage(vector<string> a_pathToMultiModalImage) {m_pathToMultiModalImg = a_pathToMultiModalImage;};
226  inline void SetPathToMaskImage(string a_pathToMaskImage) {m_pathToMaskImg = a_pathToMaskImage;};
235  int SetNbIterationsAndSubsets(const string& a_nbIterationsSubsets);
247  int SetOutputIterations(const string& a_outputIterations);
255  virtual int InitSpecificOptions(string a_specificOptions);
256 
257 
258 
259  // -------------------------------------------------------------------
260  // Protected member functions
261  protected:
269  virtual int StepBeforeIterationLoop();
277  virtual int StepAfterIterationLoop();
284  virtual int StepBeforeSubsetLoop(int a_iteration);
295  virtual int StepAfterSubsetLoop(int a_iteration);
309  virtual int StepPreProcessInsideSubsetLoop(int a_iteration, int a_subset);
323  virtual int StepPostProcessInsideSubsetLoop(int a_iteration, int a_subset);
339  virtual int StepInnerLoopInsideSubsetLoop(int a_iteration, int a_subset, int a_bed);
340 
341 
342 
343  // -------------------------------------------------------------------
344  // ----- Functions related to OpenMP barrier -----
349  void ThreadBarrierIncrement();
355  bool ThreadBarrierFlag();
361  bool ThreadBarrierCheck();
367  void ThreadBarrierSetOff();
373  void ThreadBarrierSetOn();
374 
375 
376 
377  // -------------------------------------------------------------------
378  // Data members
379  protected:
383  int m_verbose;
384  bool m_flagGPU;
394  int m_nbBeds;
396  string m_pathToAtnImg;
398  vector<string> m_pathToMultiModalImg;
403 };
404 
405 #endif
406 
407 
408 
409 
410 
411 
412 
413 
414 
415 
416 
417 
418 
This class is designed to be a mother virtual class for DataFile.
Definition: vDataFile.hh:103
This header file is mainly used to declare some macro definitions and all includes needed from the st...
Declaration of class oDynamicModelManager.
vector< string > m_pathToMultiModalImg
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the Image Dimensions and Quantification Object.
Declaration of class oImageDimensionsAndQuantification.
int Iterate()
Just call either the IterateCPU or the IterateGPU function as asked for.
int SetNbIterationsAndSubsets(const string &a_nbIterationsSubsets)
Set the number of iterations and subsets.
void SetGPUflag(bool a_flagGPU)
Set the GPU flag.
virtual int StepInnerLoopInsideSubsetLoop(int a_iteration, int a_subset, int a_bed)
This function is called inside the subset loop and manages the main loop over the events The loop o...
void SetPathToMultiModalImage(vector< string > a_pathToMultiModalImage)
Set path to multimodal images.
void SetProjectorManager(oProjectorManager *ap_ProjectorManager)
Set the Projector Manager Object.
void SetSaveSensitivityHistoFlag(bool a_saveSensitivityHistoFlag)
Set the flag that specifies if the sensitivity image in histogram mode has to be saved for each subse...
void SetDeformationManager(oDeformationManager *ap_DeformationManager)
Set the Deformation Manager Object.
Declaration of class oDeformationManager.
virtual int StepAfterIterationLoop()
This function is called at the end of the IterateCPU function.
void SetPathToSensitivityImage(string a_pathToSensitivityImage)
Set path to the sensitivity image.
This class is designed to manage the optimization part of an iterative reconstruction.
void ThreadBarrierSetOff()
Disable the thread locking variable (thread safe), and reset the number of waiting threads to 0...
void ThreadBarrierSetOn()
Enable the thread locking variable (thread safe), and reset the number of waiting threads to 0...
oIterativeAlgorithm()
oIterativeAlgorithm constructor. Initialize the member variables to their default values...
int SetOutputIterations(const string &a_outputIterations)
Set the selected output iterations.
void SetVerbose(int a_verboseLevel)
Set Verbosity.
This is the main class for iterative reconstructions, that manages the iteration loops. This class manages an iterative reconstruction of any kind, using a vDataFile, and through the use of an oProjector, an oOptimizer, a oConvolver, a oImageSpace.
bool ThreadBarrierCheck()
Check if all the threads are currently in waiting condition.
virtual int StepAfterSubsetLoop(int a_iteration)
This function is called after finishing the subset loop.
oImageProcessingManager * mp_ImageProcessingManager
bool ThreadBarrierFlag()
Check if the m_releaseThreads boolean is enabled or not.
oImageConvolverManager * mp_ImageConvolverManager
void SetSaveSubsetImageFlag(bool a_saveImageAfterSubsets)
Set the flag that specifies if the image has to be saved for each subset.
Declaration of class oImageConvolverManager.
oDynamicModelManager * mp_DynamicModelManager
This class is designed to manage the use of dynamic model in the reconstruction.
Declaration of class vDataFile.
virtual int StepPostProcessInsideSubsetLoop(int a_iteration, int a_subset)
void SetNbBeds(int a_nbBeds)
Set number of beds (bed positions)
oDeformationManager * mp_DeformationManager
void SetImageProcessingManager(oImageProcessingManager *ap_ImageProcessingManager)
Set the Image Processing Manager Object.
void SetPathInitImage(string a_pathToInitialImage)
Set path to an initial image.
This class is designed to manage the different image convolvers and to apply them.
void SetPathToAttenuationImage(string a_pathToAttenuationImage)
This function is used to set the path to the attenuation image.
void SetPathToMaskImage(string a_pathToMaskImage)
Set path to a mask image.
virtual int StepBeforeIterationLoop()
This function is called at the beginning of the IterateCPU function.
int IterateCPU()
Perform the iterative loop of the algorithm, call the different object for optimization, projection, update, etc. Function designed to be executed on the CPU only.
This class is designed to manage the image-based deformation part of the reconstruction.
Declaration of class oImageSpace.
This class is designed to manage the different image processing modules and to apply them...
This class is designed to manage the projection part of the reconstruction.
Declaration of class oImageProcessingManager.
virtual int InitSpecificOptions(string a_specificOptions)
Set the selected output iterations.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:61
virtual int StepBeforeSubsetLoop(int a_iteration)
This function is called before starting the subset loop.
void SetImageSpace(oImageSpace *ap_ImageSpace)
Set the Image Space Object.
void SetImageConvolverManager(oImageConvolverManager *ap_ImageConvolverManager)
Set the Image Convolver Manager Object.
virtual int StepPreProcessInsideSubsetLoop(int a_iteration, int a_subset)
This function is called right after starting the subset loop. Apply any kind of processing on the for...
This class is designed to manage all dimensions and quantification related stuff. ...
oOptimizerManager * mp_OptimizerManager
Declaration of class sChronoManager.
Declaration of class oOptimizerManager.
oProjectorManager * mp_ProjectorManager
void SetOptimizerManager(oOptimizerManager *ap_OptimizerManager)
Set the Optimizer Manager Object.
Declaration of class oProjectorManager.
void ThreadBarrierIncrement()
Increment (thread safe) the m_nbThreadsWaiting variable.
void SetDataFile(vDataFile **a2p_DataFile)
Set the list of DataFile.
void SetDynamicModelManager(oDynamicModelManager *ap_DynamicModelManager)
Set the Dynamic Model Manager Object.
oImageDimensionsAndQuantification * mp_ID
virtual ~oIterativeAlgorithm()
oIterativeAlgorithm destructor.