ANIMA  4.0
animaGaussianMCMVariableProjectionCost.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vnl/vnl_matrix.h>
4 #include <vnl/vnl_diag_matrix.h>
5 
6 #include <animaBaseMCMCost.h>
7 #include <animaNNLSOptimizer.h>
8 #include <animaBaseTensorTools.h>
9 #include <AnimaMCMExport.h>
10 
12 
13 namespace anima
14 {
15 
21 {
22 public:
26  typedef itk::SmartPointer<Self> Pointer;
27  typedef itk::SmartPointer<const Self> ConstPointer;
28 
29  itkNewMacro(Self)
30 
31 
33 
36 
38  MeasureType GetValues(const ParametersType &parameters) ITK_OVERRIDE;
39 
41  double GetCurrentCostValue() ITK_OVERRIDE;
42 
44  void GetDerivativeMatrix(const ParametersType &parameters, DerivativeMatrixType &derivative) ITK_OVERRIDE;
45 
47  void GetCurrentDerivative(DerivativeMatrixType &derivativeMatrix, DerivativeType &derivative) ITK_OVERRIDE;
48 
49  std::vector <double> &GetOptimalWeights() {return m_OptimalWeights;}
50 
51 protected:
53  {
54  m_NNLSBordersOptimizer = anima::NNLSOptimizer::New();
55  m_leCalculator = LECalculatorType::New();
56  }
57 
58  virtual ~GaussianMCMVariableProjectionCost() ITK_OVERRIDE {}
59 
61  void SolveLinearLeastSquares();
62 
63  bool CheckBoundaryConditions();
64  void PrepareDataForLLS();
65  void PrepareDataForDerivative();
66 
67 private:
68  GaussianMCMVariableProjectionCost(const Self&); //purposely not implemented
69  void operator=(const Self&); //purposely not implemented
70 
71  // Utility variables to make ML estimation faster
72  vnl_matrix <double> m_FMatrixInverseG;
73  std::vector <double> m_OptimalWeights;
74  MeasureType m_Residuals;
75  vnl_matrix <double> m_GramMatrix, m_InverseGramMatrix;
76  ParametersType m_FSignals, m_OptimalUsefulWeights;
77  anima::NNLSOptimizer::Pointer m_NNLSBordersOptimizer;
78 
79  std::vector <unsigned int> m_IndexesUsefulCompartments;
80  std::vector <bool> m_CompartmentSwitches;
81  vnl_matrix <double> m_PredictedSignalAttenuations, m_CholeskyMatrix;
82  std::vector< vnl_matrix<double> > m_SignalAttenuationsJacobian;
83 
84  CholeskyDecomposition m_CholeskySolver;
85  LECalculatorPointer m_leCalculator;
86 };
87 
88 } // end namespace anima
itk::SmartPointer< Self > Pointer
itk::OptimizerParameters< double > ParametersType
Class for computing variable projection costs and derivatives. Right now, it is only available for Ga...
STL namespace.
static Pointer New()
Base cost function class to handle maximum likelihood estimation.
itk::Array2D< double > DerivativeMatrixType
itk::Array< double > MeasureType
itk::Array< double > DerivativeType
Cholesky decomposition: decomposes a symmetric matrix A in the form L D L^T, where L is lower triangu...