ANIMA  4.0
animaT1SERelaxometryCostFunction.cxx
Go to the documentation of this file.
2 
3 namespace anima
4 {
5 
8 {
9  double m0Value = parameters[0];
10  double t1Value = parameters[1];
11 
12  double residualValue = 0;
13  unsigned int numSignals = m_RelaxometrySignals.size();
14 
15  for (unsigned int i = 0;i < numSignals;++i)
16  {
17  double simulatedSignal = m0Value * (1.0 - std::exp(- m_TRValues[i] / t1Value));
18  residualValue += (simulatedSignal - m_RelaxometrySignals[i]) * (simulatedSignal - m_RelaxometrySignals[i]);
19  }
20 
21  return residualValue;
22 }
23 
24 void
26  DerivativeType & derivative) const
27 {
28  double m0Value = parameters[0];
29  double t1Value = parameters[1];
30 
31  derivative.SetSize(this->GetNumberOfParameters());
32 
33  unsigned int numSignals = m_RelaxometrySignals.size();
34 
35  derivative[0] = 0;
36  derivative[1] = 0;
37  for (unsigned int i = 0;i < numSignals;++i)
38  {
39  double expValue = 1.0 - std::exp(- m_TRValues[i] / t1Value);
40  //M0 derivative
41  derivative[0] += expValue * (m0Value * expValue - m_RelaxometrySignals[i]);
42  //T1 derivative
43  derivative[1] += (m0Value * expValue - m_RelaxometrySignals[i]) * m0Value * m_TRValues[i] * (1.0 - expValue) / (t1Value * t1Value);
44  }
45 }
46 
47 } // end namespace anima
virtual void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const ITK_OVERRIDE
unsigned int GetNumberOfParameters() const ITK_OVERRIDE
virtual MeasureType GetValue(const ParametersType &parameters) const ITK_OVERRIDE