ANIMA  4.0
animaT2EPGRelaxometryCostFunction.cxx
Go to the documentation of this file.
3 
4 namespace anima
5 {
6 
9 {
10  m_T2Value = parameters[0];
11  m_B1Value = parameters[1];
12 
13  double residualValue = 0;
14  unsigned int numT2Signals = m_T2RelaxometrySignals.size();
15 
16  anima::EPGSignalSimulator t2SignalSimulator;
17  t2SignalSimulator.SetNumberOfEchoes(m_T2RelaxometrySignals.size());
18  t2SignalSimulator.SetEchoSpacing(m_T2EchoSpacing);
19  t2SignalSimulator.SetExcitationFlipAngle(m_T2ExcitationFlipAngle);
20 
21  anima::EPGSignalSimulator::RealVectorType simulatedT2Values = t2SignalSimulator.GetValue(m_T1Value,m_T2Value,m_B1Value * m_T2FlipAngles[0],1.0);
22 
23  double sumSignals = 0;
24  double sumSimulatedSignals = 0;
25  for (unsigned int i = 0;i < numT2Signals;++i)
26  {
27  sumSignals += m_T2RelaxometrySignals[i];
28  sumSimulatedSignals += simulatedT2Values[i];
29  }
30 
31  m_M0Value = sumSignals / sumSimulatedSignals;
32 
33  for (unsigned int i = 0;i < numT2Signals;++i)
34  residualValue += (m_M0Value * simulatedT2Values[i] - m_T2RelaxometrySignals[i]) * (m_M0Value * simulatedT2Values[i] - m_T2RelaxometrySignals[i]);
35 
36  return residualValue;
37 }
38 
39 } // end namespace anima
std::vector< double > RealVectorType
virtual MeasureType GetValue(const ParametersType &parameters) const ITK_OVERRIDE
RealVectorType & GetValue(double t1Value, double t2Value, double flipAngle, double m0Value)
Get EPG values at given point.
void SetNumberOfEchoes(unsigned int val)