CASToR  3.1
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-2020 all CASToR contributors listed below:
18 
19  --> Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Thibaut MERLIN, Mael MILLARDET, Simon STUTE, Valentin VIELZEUF, Zacharias CHALAMPALAKIS
20 
21 This is CASToR version 3.1.
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 ShowHelpModelSpecific() = 0;
163  void ShowHelp() ;
164 
165 
166  // -----------------------------------------------------------------------------------------
167  // Public member functions called by the main iterative algorithm class
168  public:
178  virtual int EstimateModel(oImageSpace* ap_Image, int a_ite, int a_sset);
189  virtual int EstimateModelParameters(oImageSpace* ap_Image, int a_ite, int a_sset) = 0;
199  virtual int EstimateImage(oImageSpace* ap_Image, int a_ite, int a_sset);
209  virtual int EstimateImageWithModel(oImageSpace* ap_Image, int a_ite, int a_sset) = 0;
218  int SaveParametricImages(int a_iteration, int a_subset = -1);
225 
230  inline bool GetAICflag() {return m_AICfileProvided; }
240  inline int GetNbTimeBasisFunctions() {return m_nbTimeBF; }
246 
251  virtual void ComputeOutputParImage();
258  inline void SetUseModelInReconstruction(bool a_useModelInReconstruction)
259  {m_useModelInReconstruction=a_useModelInReconstruction;}
260 
295  int NNLS( FLTNB **A,
296  int m,
297  int n,
298  FLTNB *B,
299  FLTNB *X,
300  FLTNB *rnorm,
301  FLTNB *wp,
302  FLTNB *zzp,
303  int *indexp );
304 
305 
306  private:
307 
339  int NNLS_LSS_H12( int mode,
340  int lpivot,
341  int l1,
342  int m,
343  FLTNB *u,
344  int u_dim1,
345  FLTNB *up,
346  FLTNB *cm,
347  int ice,
348  int icv,
349  int ncv );
350 
369  void NNLS_LSS_G1(FLTNB a, FLTNB b, FLTNB *cterm, FLTNB *sterm, FLTNB *sig);
370 
371 
372  // -----------------------------------------------------------------------------------------
373  // Data members
374  protected:
376  int m_verbose;
383  string m_AICfile;
419  string m_fileOptions;
420  string m_listOptions;
422  bool m_checked;
440  // NNLS function
447  int** m2p_nnlsIdx;
449  uint16_t m_nnlsN=0;
450 };
451 
452 // ----------------------------------------------------------------------
453 // Part of code that manages the auto declaration of children classes
454 // ----------------------------------------------------------------------
455 
456 // Macro for the function that creates the object
457 #define FUNCTION_DYNAMICMODEL(CLASS) \
458  static vDynamicModel *make_dynamic_model() { return new CLASS(); };
459 
460 // Macro for the class that links the appropriate function to the map of objects
461 #define CLASS_DYNAMICMODEL(NAME,CLASS) \
462  class NAME##DynamicModelCreator \
463  { \
464  public: \
465  NAME##DynamicModelCreator() \
466  { sAddonManager::GetInstance()->mp_listOfDynamicModels[#NAME] = CLASS::make_dynamic_model; } \
467  }; \
468  static NAME##DynamicModelCreator DynamicModelCreator##NAME;
469 
470 #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()
void SetUseModelInReconstruction(bool a_useModelInReconstruction)
Set flag to indicate if the dynamic model is used in the tomographic reconstruction.
oArterialInputCurve * mp_ArterialInputCurve
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
uint16_t m_nnlsN
void ShowHelp()
This function is used to print out general help about dynamic models.
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...
bool m_useModelInReconstruction
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.
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