CASToR  1.1
Tomographic Reconstruction (PET/SPECT)
 All Classes Files Functions Variables Typedefs Macros Groups Pages
vOptimizer.hh
Go to the documentation of this file.
1 
8 #ifndef VOPTIMIZER_HH
9 #define VOPTIMIZER_HH 1
10 
11 #include "gVariables.hh"
13 #include "oImageSpace.hh"
14 #include "vDataFile.hh"
15 #include "oProjectionLine.hh"
16 
37 {
38  // -------------------------------------------------------------------
39  // Constructor & Destructor
40  public:
47  vOptimizer();
55  virtual ~vOptimizer();
56 
57 
58  // -------------------------------------------------------------------
59  // Public member functions
60  public:
66  void ShowHelp();
75  int CheckParameters();
84  int Initialize();
96  int UpdateVisitedVoxels(oImageSpace* ap_Image);
110  int PreDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets);
124  int PostDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets);
125 
126 
127  // -------------------------------------------------------------------
128  // Virtual public member functions that may be overloaded by specific child optimizers
129  public:
150  virtual int DataStep1ForwardProjectModel( oProjectionLine* ap_Line, oImageSpace* ap_Image, vEvent* ap_Event,
151  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate,
152  int a_thread );
169  virtual int DataStep2Optional( oProjectionLine* ap_Line, oImageSpace* ap_Image, vEvent* ap_Event,
170  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration,
171  int a_thread );
190  virtual int DataStep3BackwardProjectSensitivity( oProjectionLine* ap_Line, oImageSpace* ap_Image, vEvent* ap_Event,
191  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate,
192  int a_thread );
209  virtual int DataStep4Optional( oProjectionLine* ap_Line, oImageSpace* ap_Image, vEvent* ap_Event,
210  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate,
211  int a_iteration, int a_thread );
229  virtual int DataStep5ComputeCorrections( oProjectionLine* ap_Line, vEvent* ap_Event,
230  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate,
231  int a_thread );
248  virtual int DataStep6Optional( oProjectionLine* ap_Line, oImageSpace* ap_Image, vEvent* ap_Event,
249  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate,
250  int a_iteration, int a_thread );
270  virtual int DataStep7BackwardProjectCorrections( oProjectionLine* ap_Line, oImageSpace* ap_Image, vEvent* ap_Event,
271  int a_bed, int a_timeFrame, int a_respGate, int a_cardGate,
272  int a_thread );
287  virtual int DataStep8ComputeFOM( oProjectionLine* ap_Line, vEvent* ap_Event,
288  int a_timeFrame, int a_respGate, int a_cardGate,
289  int a_thread );
301  virtual int ImageUpdateStep( oImageSpace* ap_Image, int a_iteration, int a_nbSubsets );
302 
303 
304  // -----------------------------------------------------------------------------------------
305  // Virtual private member functions that may be overloaded by specific child optimizers
306  private:
319  virtual int PreDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets);
332  virtual int PostDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets);
333 
334  // -----------------------------------------------------------------------------------------
335  // Pure virtual public member functions that need to be implemented by child optimizers
336  public:
347  virtual int ReadConfigurationFile( const string& a_configurationFile ) = 0;
358  virtual int ReadOptionsList( const string& a_optionsList ) = 0;
359 
360 
361  // -----------------------------------------------------------------------------------------
362  // Pure virtual private member functions that need to be implemented by child optimizers
363  private:
372  virtual void ShowHelpSpecific() = 0;
381  virtual int CheckSpecificParameters() = 0;
391  virtual int InitializeSpecific() = 0;
409  virtual int SensitivitySpecificOperations( FLTNB a_data, FLTNB a_forwardModel, FLTNB* ap_weight,
410  FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections,
411  FLTNB a_quantificationFactor, oProjectionLine* ap_Line ) = 0;
430  virtual int DataSpaceSpecificOperations( FLTNB a_data, FLTNB a_forwardModel, FLTNB* ap_backwardValues,
431  FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections,
432  FLTNB a_quantificationFactor, oProjectionLine* ap_Line ) = 0;
450  virtual int ImageSpaceSpecificOperations( FLTNB a_currentImageValue, FLTNB* ap_newImageValue,
451  FLTNB a_sensitivity, FLTNB* ap_correctionValues ) = 0;
452 
453 
454  // -------------------------------------------------------------------
455  // Public Get & Set functions
456  public:
462  inline void SetVerbose(int a_verbose)
463  {m_verbose = a_verbose;}
469  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
470  {mp_ImageDimensionsAndQuantification = ap_ImageDimensionsAndQuantification;}
476  inline void SetNbTOFBins(int a_nbTOFBins)
477  {m_nbTOFBins = a_nbTOFBins;}
483  inline void SetDataMode(int a_dataMode)
484  {m_dataMode = a_dataMode;}
490  inline void SetDataType(int a_dataType)
491  {m_dataType = a_dataType;}
498  inline void SetAttenuationImage(FLTNB* ap_attenuationImage, int a_thread)
499  {m2p_attenuationImage[a_thread] = ap_attenuationImage;}
505  inline void SetFOMFlag(bool a_optimizerFOMFlag)
506  {m_optimizerFOMFlag = a_optimizerFOMFlag;}
512  inline void SetImageStatFlag(bool a_optimizerImageStatFlag)
513  {m_optimizerImageStatFlag = a_optimizerImageStatFlag;}
519  inline int GetNbBackwardImages()
520  {return m_nbBackwardImages;}
527  {return m_initialValue;}
528  /*
529  inline bool GetAcceptPenalty()
530  {return m_penaltyEnergyFunctionDerivativesOrder>0;}
531  inline int GetPenaltyEnergyFunctionDerivativesOrder()
532  {return m_penaltyEnergyFunctionDerivativesOrder;}
533  */
534 
535 
536  // -------------------------------------------------------------------
537  // Private member functions
538  protected:
554  FLTNB ComputeSensitivity( FLTNB**** a4p_sensitivityImage,
555  int a_timeBasisFunction, int a_respBasisFunction, int a_cardBasisFunction,
556  int a_voxel, int a_nbSubsets );
566  FLTNB ForwardProject( oProjectionLine* ap_Line, FLTNB* ap_image = NULL );
577  void BackwardProject( oProjectionLine* ap_Line, FLTNB* ap_image, FLTNB a_value );
578 
579  // -------------------------------------------------------------------
580  // Data members
581  protected:
582  int m_verbose;
595  // Optimizer figures-of-merit computation
599  uint64_t**** m4p_FOMNbBins;
600  double**** m4p_FOMNbData;
601  // Image update statistics
610  //int m_penaltyEnergyFunctionDerivativesOrder; /*!< The penalty derivatives order accepted by the specific optimizer (0 if none) */
611 };
612 
613 
614 // ----------------------------------------------------------------------
615 // Part of code that manages the auto declaration of children classes
616 // ----------------------------------------------------------------------
617 
618 // Macro for the function that creates the object
619 #define FUNCTION_OPTIMIZER(CLASS) \
620  static vOptimizer *make_optimizer() { return new CLASS(); };
621 
622 // Macro for the class that links the appropriate function to the map of objects
623 #define CLASS_OPTIMIZER(NAME,CLASS) \
624  class NAME##OptimizerCreator \
625  { \
626  public: \
627  NAME##OptimizerCreator() \
628  { sAddonManager::GetInstance()->mp_listOfOptimizers[#NAME] = CLASS::make_optimizer; } \
629  }; \
630  static NAME##OptimizerCreator OptimizerCreator##NAME;
631 
632 #endif
double * mp_imageStatVariance
Definition: vOptimizer.hh:607
FLTNB * mp_imageStatMax
Definition: vOptimizer.hh:605
This header file is mainly used to declare some macro definitions and all includes needed from the st...
Declaration of class oImageDimensionsAndQuantification.
virtual int PostDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A private function used to perform any step required by the child optimizer, after the loop on event ...
Definition: vOptimizer.cc:461
#define FLTNB
Definition: gVariables.hh:55
FLTNB m_initialValue
Definition: vOptimizer.hh:587
bool m_listmodeCompatibility
Definition: vOptimizer.hh:588
void SetFOMFlag(bool a_optimizerFOMFlag)
Set the FOM flag specifying if figures-of-merit will be computed or not.
Definition: vOptimizer.hh:505
FLTNB * mp_imageStatMin
Definition: vOptimizer.hh:604
virtual int ReadConfigurationFile(const string &a_configurationFile)=0
A function used to read options from a configuration file.
double * mp_correctionStatMean
Definition: vOptimizer.hh:608
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
Definition: vOptimizer.hh:591
virtual int DataStep3BackwardProjectSensitivity(oProjectionLine *ap_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to back-project the sensitivity terms for the provided event.
Definition: vOptimizer.cc:548
virtual int CheckSpecificParameters()=0
A private function used to check the parameters settings specific to the child optimizer.
virtual int ImageUpdateStep(oImageSpace *ap_Image, int a_iteration, int a_nbSubsets)
A public function used to perform the image update step of the optimizer.
Definition: vOptimizer.cc:751
vOptimizer()
The constructor of vOptimizer.
Definition: vOptimizer.cc:25
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the pointer to the image dimensions in use.
Definition: vOptimizer.hh:469
FLTNB ForwardProject(oProjectionLine *ap_Line, FLTNB *ap_image=NULL)
A function used to forward project the provided image (or 1 if NULL), based on the provided oProjecti...
Definition: vOptimizer.cc:913
uint64_t **** m4p_FOMNbBins
Definition: vOptimizer.hh:599
double * mp_correctionStatVariance
Definition: vOptimizer.hh:609
virtual int ReadOptionsList(const string &a_optionsList)=0
A function used to read options from a list of options.
FLTNB **** m4p_FOMRMSE
Definition: vOptimizer.hh:598
int m_dataMode
Definition: vOptimizer.hh:592
virtual int DataStep1ForwardProjectModel(oProjectionLine *ap_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to compute the model: forward projection of the provided event.
Definition: vOptimizer.cc:472
bool m_optimizerFOMFlag
Definition: vOptimizer.hh:596
void SetNbTOFBins(int a_nbTOFBins)
Set the number of TOF bins in use.
Definition: vOptimizer.hh:476
void SetDataType(int a_dataType)
Set the data type in use.
Definition: vOptimizer.hh:490
INTNB * mp_imageStatNbVox
Definition: vOptimizer.hh:603
Declaration of class oProjectionLine.
virtual int DataSpaceSpecificOperations(FLTNB a_data, FLTNB a_forwardModel, FLTNB *ap_backwardValues, FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections, FLTNB a_quantificationFactor, oProjectionLine *ap_Line)=0
A private function used to compute the correction term in the data space from the provided data...
int m_nbBackwardImages
Definition: vOptimizer.hh:583
Declaration of class vDataFile.
virtual int InitializeSpecific()=0
A private function used to initialize everything specific to the child optimizer. ...
void BackwardProject(oProjectionLine *ap_Line, FLTNB *ap_image, FLTNB a_value)
A function used to backward project the provided value into the provided image, based on the provided...
Definition: vOptimizer.cc:928
int PreDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
Definition: vOptimizer.cc:355
FLTNB ** m2p_attenuationImage
Definition: vOptimizer.hh:594
virtual int DataStep4Optional(oProjectionLine *ap_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration, int a_thread)
A public function which does nothing but being virtual.
Definition: vOptimizer.cc:587
bool m_histogramCompatibility
Definition: vOptimizer.hh:589
bool m_optimizerImageStatFlag
Definition: vOptimizer.hh:602
virtual int DataStep8ComputeFOM(oProjectionLine *ap_Line, vEvent *ap_Event, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to update the computation of figures-of-merit in the data space.
Definition: vOptimizer.cc:703
double **** m4p_FOMNbData
Definition: vOptimizer.hh:600
void SetImageStatFlag(bool a_optimizerImageStatFlag)
Set the image stat flag specifying if basic statistics about image udpate will be computed or not...
Definition: vOptimizer.hh:512
int UpdateVisitedVoxels(oImageSpace *ap_Image)
A public function used to update the 'visited' voxels after each subset.
Definition: vOptimizer.cc:731
FLTNB ComputeSensitivity(FLTNB ****a4p_sensitivityImage, int a_timeBasisFunction, int a_respBasisFunction, int a_cardBasisFunction, int a_voxel, int a_nbSubsets)
A function used to compute the sensitivity of a given voxel and a given set of dynamic basis function...
Definition: vOptimizer.cc:943
FLTNB GetInitialValue()
Get the initial image value (for initialization)
Definition: vOptimizer.hh:526
int PostDataUpdateStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A public function used to do stuff that need to be done at the beginning of a subset (before the data...
Definition: vOptimizer.cc:397
virtual int PreDataUpdateSpecificStep(int a_iteration, int a_nbIterations, int a_subset, int a_nbSubsets)
A private function used to perform any step required by the child optimizer, before the loop on event...
Definition: vOptimizer.cc:386
virtual int DataStep2Optional(oProjectionLine *ap_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration, int a_thread)
A public function which does nothing but being virtual.
Definition: vOptimizer.cc:535
virtual ~vOptimizer()
The destructor of vOptimizer.
Definition: vOptimizer.cc:61
#define INTNB
Definition: gVariables.hh:64
This class is designed to generically described any iterative optimizer.
Definition: vOptimizer.hh:36
void SetAttenuationImage(FLTNB *ap_attenuationImage, int a_thread)
Set the attenuation image corresponding to the current thread and current event.
Definition: vOptimizer.hh:498
int m_nbTOFBins
Definition: vOptimizer.hh:584
This class is designed to manage and store system matrix elements associated to a vEvent...
Declaration of class oImageSpace.
FLTNB **** m4p_FOMLogLikelihood
Definition: vOptimizer.hh:597
int Initialize()
A public function used to initialize the optimizer.
Definition: vOptimizer.cc:277
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:41
int m_dataType
Definition: vOptimizer.hh:593
Mother class for the Event objects.
Definition: vEvent.hh:23
virtual int DataStep5ComputeCorrections(oProjectionLine *ap_Line, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to compute the correction terms in the data space, for the provided event...
Definition: vOptimizer.cc:600
This class is designed to manage all dimensions and quantification related stuff. ...
int GetNbBackwardImages()
Get the number of backward images used by the specific optimizer.
Definition: vOptimizer.hh:519
void SetVerbose(int a_verbose)
Set the verbose level.
Definition: vOptimizer.hh:462
virtual void ShowHelpSpecific()=0
A function used to show help about the child module.
virtual int ImageSpaceSpecificOperations(FLTNB a_currentImageValue, FLTNB *ap_newImageValue, FLTNB a_sensitivity, FLTNB *ap_correctionValues)=0
A private function used to update the image value from the provided data.
virtual int DataStep7BackwardProjectCorrections(oProjectionLine *ap_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_thread)
A public function used to back-project the correction terms into the backward correction image...
Definition: vOptimizer.cc:648
void SetDataMode(int a_dataMode)
Set the data mode in use.
Definition: vOptimizer.hh:483
void ShowHelp()
A function used to show help about the optimizer.
Definition: vOptimizer.cc:190
double * mp_imageStatMean
Definition: vOptimizer.hh:606
FLTNB ** m2p_forwardValues
Definition: vOptimizer.hh:585
virtual int DataStep6Optional(oProjectionLine *ap_Line, oImageSpace *ap_Image, vEvent *ap_Event, int a_bed, int a_timeFrame, int a_respGate, int a_cardGate, int a_iteration, int a_thread)
A public function which does nothing but being virtual.
Definition: vOptimizer.cc:635
FLTNB *** m3p_backwardValues
Definition: vOptimizer.hh:586
int CheckParameters()
A public function used to check the parameters settings.
Definition: vOptimizer.cc:206
virtual int SensitivitySpecificOperations(FLTNB a_data, FLTNB a_forwardModel, FLTNB *ap_weight, FLTNB a_multiplicativeCorrections, FLTNB a_additiveCorrections, FLTNB a_quantificationFactor, oProjectionLine *ap_Line)=0
A private function used to compute the sensitivity weight associated to the provided data...