CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
vDynamicModel.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 VDYNAMICMODEL_HH
31 #define VDYNAMICMODEL_HH 1
32 
33 #include "gVariables.hh"
35 #include "oOptimizerManager.hh"
36 // #include "oArterialInputCurve.hh"
37 
38 class oImageSpace;
39 
63 {
64  // -----------------------------------------------------------------------------------------
65  // Constructor & Destructor
66  public:
71  vDynamicModel();
76  virtual ~vDynamicModel();
77 
78 
79  // -----------------------------------------------------------------------------------------
80  // Public member functions related to the initialization of the model
81  public:
87  inline void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification* ap_ImageDimensionsAndQuantification)
88  {mp_ID = ap_ImageDimensionsAndQuantification;}
94  inline void SetVerbose(int a_verbose)
95  {m_verbose = a_verbose;}
102  virtual int CheckParameters();
109  virtual int CheckSpecificParameters() = 0;
118  int ReadAndCheckConfigurationFile(string a_fileOptions);
125  virtual int ReadAndCheckConfigurationFileSpecific() = 0;
133  virtual int ReadAndCheckOptionsList(string a_listOptions) = 0;
142  int Initialize();
152  virtual int InitializeSpecific() = 0;
158  virtual void ShowHelp() = 0;
159 
160 
161  // -----------------------------------------------------------------------------------------
162  // Public member functions called by the main iterative algorithm class
163  public:
173  virtual int EstimateModel(oImageSpace* ap_Image, int a_ite, int a_sset);
184  virtual int EstimateModelParameters(oImageSpace* ap_Image, int a_ite, int a_sset) = 0;
194  virtual int EstimateImage(oImageSpace* ap_Image, int a_ite, int a_sset);
204  virtual int EstimateImageWithModel(oImageSpace* ap_Image, int a_ite, int a_sset) = 0;
213  int SaveParametricImages(int a_iteration, int a_subset = -1);
220 
225  inline bool GetAICflag() {return m_AICfileProvided; }
235  inline int GetNbTimeBasisFunctions() {return m_nbTimeBF; }
241 
246  virtual void ComputeOutputParImage();
247 
282  int NNLS( FLTNB **A,
283  int m,
284  int n,
285  FLTNB *B,
286  FLTNB *X,
287  FLTNB *rnorm,
288  FLTNB *wp,
289  FLTNB *zzp,
290  int *indexp );
291 
292 
293  private:
294 
326  int NNLS_LSS_H12( int mode,
327  int lpivot,
328  int l1,
329  int m,
330  FLTNB *u,
331  int u_dim1,
332  FLTNB *up,
333  FLTNB *cm,
334  int ice,
335  int icv,
336  int ncv );
337 
356  void NNLS_LSS_G1(FLTNB a, FLTNB b, FLTNB *cterm, FLTNB *sterm, FLTNB *sig);
357 
358 
359  // -----------------------------------------------------------------------------------------
360  // Data members
361  protected:
363  int m_verbose;
370  string m_AICfile;
406  string m_fileOptions;
407  string m_listOptions;
409  bool m_checked;
426  // NNLS function
433  int** m2p_nnlsIdx;
435  uint16_t m_nnlsN=0;
436 };
437 
438 // ----------------------------------------------------------------------
439 // Part of code that manages the auto declaration of children classes
440 // ----------------------------------------------------------------------
441 
442 // Macro for the function that creates the object
443 #define FUNCTION_DYNAMICMODEL(CLASS) \
444  static vDynamicModel *make_dynamic_model() { return new CLASS(); };
445 
446 // Macro for the class that links the appropriate function to the map of objects
447 #define CLASS_DYNAMICMODEL(NAME,CLASS) \
448  class NAME##DynamicModelCreator \
449  { \
450  public: \
451  NAME##DynamicModelCreator() \
452  { sAddonManager::GetInstance()->mp_listOfDynamicModels[#NAME] = CLASS::make_dynamic_model; } \
453  }; \
454  static NAME##DynamicModelCreator DynamicModelCreator##NAME;
455 
456 #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)
This function is used by the NNLS function() Construction and/or application of a single Householder ...
bool GetModelBasisFunctionsRequiredFlag()
int NNLS(FLTNB **A, int m, int n, FLTNB *B, FLTNB *X, FLTNB *rnorm, FLTNB *wp, FLTNB *zzp, int *indexp)
Implementation of NNLS (non-negative least squares) algorithm Derived from Turku PET center libraries...
This header file is mainly used to declare some macro definitions and all includes needed from the st...
Declaration of class oImageDimensionsAndQuantification.
virtual int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
virtual int InitializeSpecific()=0
A private function used to initialize everything specific to the child model.
#define FLTNB
Definition: gVariables.hh:81
string m_listOptions
int GetNbTimeBasisFunctions()
oArterialInputCurve * mp_ArterialInputCurve
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
uint16_t m_nnlsN
int ReadAndCheckConfigurationFile(string a_fileOptions)
This function is used to read options from a configuration file. It looks for the parameters implem...
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)
oImageDimensionsAndQuantification * mp_ID
This is the mother class of dynamic model classes.
FLTNB ** m2p_nnlsB
bool m_saveBlacklistedImageMaskFlag
virtual int ApplyOutputFOVMaskingOnParametricImages()
Mask the outside of the transaxial FOV based on the m_fovOutPercent.
FLTNB ** m2p_RGParametricImages
virtual int ReadAndCheckOptionsList(string a_listOptions)=0
This function is used to read parameters from a string. It is pure virtual so must be implemented b...
virtual void ShowHelp()=0
This function is used to print out specific help about the deformation and its options. It is pure virtual so must be implemented by children.
string m_fileOptions
virtual int EstimateImage(oImageSpace *ap_Image, int a_ite, int a_sset)
virtual int EstimateModel(oImageSpace *ap_Image, int a_ite, int a_sset)
This function checks if the EstimateModelParameters() function (specific to each model) must be calle...
FLTNB ** m2p_outputParImages
FLTNB ** m2p_CGParametricImages
FLTNB * mp_maskModel
FLTNB ** m2p_nnlsWp
bool m_ModelSpecificBasisFunctionsRequired
virtual int ReadAndCheckConfigurationFileSpecific()=0
This function is used to read options from a configuration file. It is pure virtual so must be impl...
int Initialize()
A public function used to initialize the dynamic model.
void SetVerbose(int a_verbose)
Set the verbose level.
FLTNB ** m2p_nestedModelTimeBasisFunctions
bool m_noParametersUpdateFlag
virtual ~vDynamicModel()
Destructor of vDynamicModel.
vDynamicModel()
Constructor of vDynamicModel. Simply set all data members to default values.
#define INTNB
Definition: gVariables.hh:92
FLTNB ** GetTimeBasisFunctions()
FLTNB ** m2p_parametricImages
This class holds all the matrices in the image domain that can be used in the algorithm: image...
Definition: oImageSpace.hh:60
FLTNB ** m2p_nnlsX
This class is designed to manage all dimensions and quantification related stuff. ...
virtual int EstimateImageWithModel(oImageSpace *ap_Image, int a_ite, int a_sset)=0
This function checks if the EstimateImageWithModel() function (specific to each model) must be called...
Declaration of class oOptimizerManager.
FLTNB ** m2p_nnlsMat
bool m_noImageUpdateFlag
virtual void ComputeOutputParImage()
Compute output image using the m2p_parametricImages matrix Store the result in the m2p_outputParImage...
virtual int EstimateModelParameters(oImageSpace *ap_Image, int a_ite, int a_sset)=0
This function is pure virtual so must be implemented by children. It can be used to estimate any te...
int SaveParametricImages(int a_iteration, int a_subset=-1)
This function is virtual it can be overloaded by children if required.
This class is designed to manage the Arterial Input Curve provided by the user.
FLTNB * mp_blackListedvoxelsImage
FLTNB *** m3p_nnlsA