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