CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
include/dynamic/vDynamicModel.hh
Go to the documentation of this file.
1 
8 #ifndef VDYNAMICMODEL_HH
9 #define VDYNAMICMODEL_HH 1
10 
11 #include "gVariables.hh"
12 #include "oImageDimensionsAndQuantification.hh"
13 #include "oOptimizerManager.hh"
14 // #include "oArterialInputCurve.hh"
15 
16 class oImageSpace;
17 
40 class vDynamicModel
41 {
42  // -----------------------------------------------------------------------------------------
43  // Constructor & Destructor
44  public:
49  vDynamicModel();
54  virtual ~vDynamicModel();
55 
56 
57  // -----------------------------------------------------------------------------------------
58  // Public member functions related to the initialization of the model
59  public:
65  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
66  {mp_ID = ap_ImageDimensionsAndQuantification;}
72  inline void SetVerbose(int a_verbose)
73  {m_verbose = a_verbose;}
80  virtual int CheckParameters();
87  virtual int CheckSpecificParameters() = 0;
96  int ReadAndCheckConfigurationFile(string a_fileOptions);
103  virtual int ReadAndCheckConfigurationFileSpecific() = 0;
111  virtual int ReadAndCheckOptionsList(string a_listOptions) = 0;
120  int Initialize();
130  virtual int InitializeSpecific() = 0;
136  virtual void ShowHelpModelSpecific() = 0;
141  void ShowHelp() ;
142 
143 
144  // -----------------------------------------------------------------------------------------
145  // Public member functions called by the main iterative algorithm class
146  public:
156  virtual int EstimateModel(oImageSpace* ap_Image, int a_ite, int a_sset);
167  virtual int EstimateModelParameters(oImageSpace* ap_Image, int a_ite, int a_sset) = 0;
177  virtual int EstimateImage(oImageSpace* ap_Image, int a_ite, int a_sset);
187  virtual int EstimateImageWithModel(oImageSpace* ap_Image, int a_ite, int a_sset) = 0;
196  int SaveParametricImages(int a_iteration, int a_subset = -1);
203 
208  inline bool GetAICflag() {return m_AICfileProvided; }
218  inline int GetNbTimeBasisFunctions() {return m_nbTimeBF; }
224 
229  virtual void ComputeOutputParImage();
236  inline void SetUseModelInReconstruction(bool a_useModelInReconstruction)
237  {m_useModelInReconstruction=a_useModelInReconstruction;}
238 
273  int NNLS( FLTNB **A,
274  int m,
275  int n,
276  FLTNB *B,
277  FLTNB *X,
278  FLTNB *rnorm,
279  FLTNB *wp,
280  FLTNB *zzp,
281  int *indexp );
282 
283 
284  private:
285 
317  int NNLS_LSS_H12( int mode,
318  int lpivot,
319  int l1,
320  int m,
321  FLTNB *u,
322  int u_dim1,
323  FLTNB *up,
324  FLTNB *cm,
325  int ice,
326  int icv,
327  int ncv );
328 
347  void NNLS_LSS_G1(FLTNB a, FLTNB b, FLTNB *cterm, FLTNB *sterm, FLTNB *sig);
348 
349 
350  // -----------------------------------------------------------------------------------------
351  // Data members
352  protected:
354  int m_verbose;
355  int m_nbTimeBF;
356  int m_nbWeightFactors;
357  int m_nbModelParam;
358  int m_nbRGModelParam;
359  int m_nbCGModelParam;
361  string m_AICfile;
397  string m_fileOptions;
398  string m_listOptions;
400  bool m_checked;
401  bool m_initialized;
403  bool m_saveParImageFlag;
405  bool m_AICfileProvided;
408  bool m_noImageUpdateFlag;
418  // NNLS function
419  FLTNB* mp_w;
420  FLTNB*** m3p_nnlsA;
421  FLTNB** m2p_nnlsB;
422  FLTNB** m2p_nnlsMat;
423  FLTNB** m2p_nnlsX;
424  FLTNB** m2p_nnlsWp;
425  int** m2p_nnlsIdx;
427  uint16_t m_nnlsN=0;
428 };
429 
430 // ----------------------------------------------------------------------
431 // Part of code that manages the auto declaration of children classes
432 // ----------------------------------------------------------------------
433 
434 // Macro for the function that creates the object
435 #define FUNCTION_DYNAMICMODEL(CLASS) \
436  static vDynamicModel *make_dynamic_model() { return new CLASS(); };
437 
438 // Macro for the class that links the appropriate function to the map of objects
439 #define CLASS_DYNAMICMODEL(NAME,CLASS) \
440  class NAME##DynamicModelCreator \
441  { \
442  public: \
443  NAME##DynamicModelCreator() \
444  { sAddonManager::GetInstance()->mp_listOfDynamicModels[#NAME] = CLASS::make_dynamic_model; } \
445  }; \
446  static NAME##DynamicModelCreator DynamicModelCreator##NAME;
447 
448 #endif
virtual int CheckSpecificParameters()=0
This function is used to check the parameters of the child functions before initialization if require...
void NNLS_LSS_G1(FLTNB a, FLTNB b, FLTNB *cterm, FLTNB *sterm, FLTNB *sig)
int NNLS(FLTNB **A, int m, int n, FLTNB *B, FLTNB *X, FLTNB *rnorm, FLTNB *wp, FLTNB *zzp, int *indexp)
void SetVerbose(int a_verbose)
virtual int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
virtual int EstimateImageWithModel(oImageSpace *ap_Image, int a_ite, int a_sset)=0
virtual int InitializeSpecific()=0
A private function used to initialize everything specific to the child model.
oImageDimensionsAndQuantification * mp_ID
void ShowHelp()
This function is used to print out general help about dynamic models.
int ReadAndCheckConfigurationFile(string a_fileOptions)
int NNLS_LSS_H12(int mode, int lpivot, int l1, int m, FLTNB *u, int u_dim1, FLTNB *up, FLTNB *cm, int ice, int icv, int ncv)
This is the mother class of dynamic model classes.
virtual int ApplyOutputFOVMaskingOnParametricImages()
Mask the outside of the transaxial FOV based on the m_fovOutPercent.
virtual void ShowHelpModelSpecific()=0
This function is used to print out specific help about the dynamic model and its options. It is pure virtual so must be implemented by children.
virtual int EstimateImage(oImageSpace *ap_Image, int a_ite, int a_sset)
virtual int EstimateModel(oImageSpace *ap_Image, int a_ite, int a_sset)
void SetUseModelInReconstruction(bool a_useModelInReconstruction)
virtual int ReadAndCheckConfigurationFileSpecific()=0
This function is used to read options from a configuration file. It is pure virtual so must be impl...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
int Initialize()
A public function used to initialize the dynamic model.
virtual int ReadAndCheckOptionsList(string a_listOptions)=0
virtual ~vDynamicModel()
Destructor of vDynamicModel.
vDynamicModel()
Constructor of vDynamicModel. Simply set all data members to default values.
virtual int EstimateModelParameters(oImageSpace *ap_Image, int a_ite, int a_sset)=0
oArterialInputCurve * mp_ArterialInputCurve
This class holds all the matrices in the image domain that can be used in the algorithm: image...
This class is designed to manage all dimensions and quantification related stuff. ...
virtual void ComputeOutputParImage()
Compute output image using the m2p_parametricImages matrix Store the result in the m2p_outputParImage...
int SaveParametricImages(int a_iteration, int a_subset=-1)
This class is designed to manage the Arterial Input Curve provided by the user.