ANIMA  4.0
animaB1T2RelaxometryDistributionCostFunction.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkSingleValuedCostFunction.h>
4 #include "AnimaRelaxometryExport.h"
5 
7 
8 namespace anima
9 {
10 
15 class ANIMARELAXOMETRY_EXPORT B1T2RelaxometryDistributionCostFunction :
16 public itk::SingleValuedCostFunction
17 {
18 public:
21  typedef itk::SingleValuedCostFunction Superclass;
22  typedef itk::SmartPointer<Self> Pointer;
23  typedef itk::SmartPointer<const Self> ConstPointer;
24 
25  itkNewMacro(Self)
26 
27 
28  itkTypeMacro(B1T2RelaxometryDistributionCostFunction, Superclass)
29 
30  typedef Superclass::MeasureType MeasureType;
31  typedef Superclass::DerivativeType DerivativeType;
32  typedef Superclass::ParametersType ParametersType;
33  typedef std::vector < std::complex <double> > ComplexVectorType;
34  typedef std::vector <ComplexVectorType> MatrixType;
35 
36  virtual MeasureType GetValue(const ParametersType & parameters) const ITK_OVERRIDE;
37  virtual void GetDerivative(const ParametersType & parameters, DerivativeType & derivative) const ITK_OVERRIDE {} // No derivative
38 
39  itkSetMacro(EchoSpacing, double)
40  itkSetMacro(ExcitationFlipAngle, double)
41 
42  void SetT2RelaxometrySignals(ParametersType &relaxoSignals) {m_T2RelaxometrySignals = relaxoSignals;}
43  void SetT2FlipAngles(std::vector <double> & flipAngles) {m_T2FlipAngles = flipAngles;}
44 
45  itkSetMacro(T1Value, double)
46  itkSetMacro(M0Value, double)
47 
48  void SetT2DistributionSamples(std::vector < std::vector <double> > &values) {m_T2DistributionSamples = values;}
49  void SetLowerT2Bound(double value) {m_LowerT2Bound = value;}
50  void SetUpperT2Bound(double value) {m_UpperT2Bound = value;}
51  void SetT2IntegrationStep(double value) {m_T2IntegrationStep = value;}
52 
53  void SetT2Weights(ParametersType &weights) {m_T2Weights = weights;}
54 
55  void SetT2WorkingValues(std::vector <double> &values) {m_T2WorkingValues = values;}
56  void SetDistributionSamplesT2Correspondences(std::vector < std::vector <unsigned int> > &values) {m_DistributionSamplesT2Correspondences = values;}
57 
58  unsigned int GetNumberOfParameters() const ITK_OVERRIDE
59  {
60  return 1;
61  }
62 
63 protected:
65  {
66  m_T1Value = 1;
67  m_M0Value = 1;
68 
69  m_EchoSpacing = 1;
70 
71  m_T2IntegrationStep = 1;
72  m_LowerT2Bound = 1.0e-4;
73  m_UpperT2Bound = 3000;
74  }
75 
77 
78 private:
79  B1T2RelaxometryDistributionCostFunction(const Self&); //purposely not implemented
80  void operator=(const Self&); //purposely not implemented
81 
82  double m_EchoSpacing;
83  ParametersType m_T2RelaxometrySignals;
84 
85  double m_ExcitationFlipAngle;
86  std::vector <double> m_T2FlipAngles;
87 
88  double m_T2IntegrationStep;
89  double m_LowerT2Bound, m_UpperT2Bound;
90  std::vector < std::vector <double> > m_T2DistributionSamples;
91  std::vector <double> m_T2WorkingValues;
92  std::vector < std::vector <unsigned int> > m_DistributionSamplesT2Correspondences;
93 
94  ParametersType m_T2Weights;
95 
96  double m_T1Value, m_M0Value;
97 
98  // Internal working variables, not thread safe but so much faster !
99  mutable anima::EPGSignalSimulator m_T2SignalSimulator;
100  mutable std::vector <anima::EPGSignalSimulator::RealVectorType> m_SimulatedEPGValues;
101  mutable anima::EPGSignalSimulator::RealVectorType m_SimulatedSignalValues;
102 };
103 
104 } // end namespace anima
void SetDistributionSamplesT2Correspondences(std::vector< std::vector< unsigned int > > &values)
STL namespace.
Cost function for estimating B1 from T2 relaxometry acquisition, following a multi-T2 EPG decay model...
std::vector< double > RealVectorType