ANIMA  4.0
animaB1T2RelaxometryDistributionCostFunction.cxx
Go to the documentation of this file.
2 
3 namespace anima
4 {
5 
8 {
9  double residualValue = 0;
10  unsigned int numT2Signals = m_T2RelaxometrySignals.size();
11  unsigned int numValues = m_T2WorkingValues.size();
12  unsigned int numDistributions = m_T2DistributionSamples.size();
13 
14  m_T2SignalSimulator.SetNumberOfEchoes(numT2Signals);
15  m_T2SignalSimulator.SetEchoSpacing(m_EchoSpacing);
16  m_T2SignalSimulator.SetExcitationFlipAngle(m_ExcitationFlipAngle);
17 
18  m_SimulatedEPGValues.resize(numValues);
19  m_SimulatedSignalValues.resize(numT2Signals);
20  std::fill(m_SimulatedSignalValues.begin(),m_SimulatedSignalValues.end(),0.0);
21 
22  for (unsigned int i = 0;i < numValues;++i)
23  m_SimulatedEPGValues[i] = m_T2SignalSimulator.GetValue(m_T1Value,m_T2WorkingValues[i],parameters[0] * m_T2FlipAngles[0],m_M0Value);
24 
25  for (unsigned int i = 0;i < numDistributions;++i)
26  {
27  if (m_T2Weights[i] <= 0)
28  continue;
29 
30  unsigned int numSamples = m_T2DistributionSamples[i].size();
31  for (unsigned int j = 0;j < numT2Signals;++j)
32  {
33  double integralValue = m_T2DistributionSamples[i][0] * m_SimulatedEPGValues[m_DistributionSamplesT2Correspondences[i][0]][j] * m_T2IntegrationStep / 2.0;
34  for (unsigned int k = 1;k < numSamples;++k)
35  integralValue += m_T2DistributionSamples[i][k] * m_SimulatedEPGValues[m_DistributionSamplesT2Correspondences[i][k]][j] * m_T2IntegrationStep;
36 
37  m_SimulatedSignalValues[j] += m_T2Weights[i] * integralValue;
38  }
39  }
40 
41  for (unsigned int i = 0;i < numT2Signals;++i)
42  residualValue += (m_SimulatedSignalValues[i] - m_T2RelaxometrySignals[i]) * (m_SimulatedSignalValues[i] - m_T2RelaxometrySignals[i]);
43 
44  return residualValue;
45 }
46 
47 } // end namespace anima
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)