ANIMA  4.0
animaBaseMCMCost.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkLightObject.h>
4 #include <itkArray2D.h>
5 #include <itkOptimizerParameters.h>
6 
8 #include <AnimaMCMBaseExport.h>
9 
10 namespace anima
11 {
12 
16 class ANIMAMCMBASE_EXPORT BaseMCMCost : public itk::LightObject
17 {
18 public:
20  typedef BaseMCMCost Self;
21  typedef itk::LightObject Superclass;
22  typedef itk::SmartPointer<Self> Pointer;
23  typedef itk::SmartPointer<const Self> ConstPointer;
24 
26  itkTypeMacro(BaseMCMCost, itk::LightObject)
27 
28  typedef itk::Array2D <double> DerivativeMatrixType;
29  typedef itk::Array <double> MeasureType;
30  typedef itk::Array <double> DerivativeType;
31  typedef itk::OptimizerParameters <double> ParametersType;
32 
34  typedef MCMType::Pointer MCMPointer;
35  typedef MCMType::Vector3DType Vector3DType;
36  typedef MCMType::ListType ListType;
37 
38  void SetObservedSignals(ListType &value) {m_ObservedSignals = value;}
39  void SetGradients(std::vector<Vector3DType> &value) {m_Gradients = value;}
40  void SetGradientStrengths(ListType &value) {m_GradientStrengths = value;}
41 
42  void SetMCMStructure(MCMType *model) {m_MCMStructure = model;}
43  MCMPointer &GetMCMStructure() {return m_MCMStructure;}
44 
46  virtual MeasureType GetValues(const ParametersType &parameters) = 0;
47 
49  virtual double GetCurrentCostValue() = 0;
50 
52  virtual void GetDerivativeMatrix(const ParametersType &parameters, DerivativeMatrixType &derivative) = 0;
53 
55  virtual void GetCurrentDerivative(DerivativeMatrixType &derivativeMatrix, DerivativeType &derivative) = 0;
56 
58  unsigned int GetNumberOfParameters() const
59  {
60  if (!m_MCMStructure)
61  itkExceptionMacro("A multi-compartment model has to be set, no computation can be done otherwise.");
62 
63  return m_MCMStructure->GetNumberOfParameters();
64  }
65 
66  unsigned int GetNumberOfObservations() const
67  {
68  return m_ObservedSignals.size();
69  }
70 
71  virtual double GetSigmaSquare() {return m_SigmaSquare;}
72 
73  void SetSmallDelta(double val) {m_SmallDelta = val;}
74  void SetBigDelta(double val) {m_BigDelta = val;}
75 
76 protected:
77  BaseMCMCost();
78  virtual ~BaseMCMCost() {}
79 
80  double m_SigmaSquare;
81  std::vector <double> m_PredictedSignals;
82 
84 
86  std::vector<Vector3DType> m_Gradients;
87 
88  double m_SmallDelta;
89  double m_BigDelta;
91 
93 
94 private:
95  BaseMCMCost(const Self&); //purposely not implemented
96  void operator=(const Self&); //purposely not implemented
97 };
98 
99 } // end namespace anima
itk::OptimizerParameters< double > ParametersType
std::vector< double > m_PredictedSignals
MCMPointer m_MCMStructure
void SetSmallDelta(double val)
itk::SmartPointer< const Self > ConstPointer
itk::LightObject Superclass
void SetGradientStrengths(ListType &value)
MCMPointer & GetMCMStructure()
void SetBigDelta(double val)
MCMType::Pointer MCMPointer
unsigned int GetNumberOfParameters() const
Returns number of optimized parameters.
void SetMCMStructure(MCMType *model)
MCMType::Vector3DType Vector3DType
virtual double GetSigmaSquare()
void SetGradients(std::vector< Vector3DType > &value)
MultiCompartmentModel: holds several diffusion compartments, ordered by type It also handles weights ...
Base cost function class to handle maximum likelihood estimation.
ListType m_GradientStrengths
MCMType::ListType ListType
itk::Array2D< double > DerivativeMatrixType
unsigned int GetNumberOfObservations() const
itk::Array< double > MeasureType
std::vector< Vector3DType > m_Gradients
itk::SmartPointer< Self > Pointer
itk::Array< double > DerivativeType