ANIMA  4.0
animaB1GammaDerivativeDistributionIntegrand.cxx
Go to the documentation of this file.
2 
3 #include <boost/math/special_functions/polygamma.hpp>
4 
5 namespace anima
6 {
7 
9 {
10  if ((m_EPGVectors.find(t) == m_EPGVectors.end())||(m_B1DerivativeFlag && (m_EPGVectors.find(t) == m_EPGVectors.end())))
11  {
12  m_EPGVectors.insert(std::make_pair(t,m_EPGSimulator.GetValue(m_T1Value, t, m_FlipAngle, 1.0)));
13  if (m_B1DerivativeFlag)
14  m_DerivativeEPGVectors.insert(std::make_pair(t,m_EPGSimulator.GetFADerivative()));
15  }
16 
17  if (m_B1DerivativeFlag)
18  {
19  // Derivative against flip angle parameter
20  double shape = m_GammaMean * m_GammaMean / m_GammaVariance;
21  double scale = m_GammaVariance / m_GammaMean;
22 
23  double gammaValue = boost::math::gamma_p_derivative(shape, t / scale) / scale;
24 
25  return m_DerivativeEPGVectors[t][m_EchoNumber] * gammaValue;
26  }
27  else
28  {
29  // Derivative against mean parameter of gamma distribution
30  double shape = m_GammaMean * m_GammaMean / m_GammaVariance;
31  double scale = m_GammaVariance / m_GammaMean;
32 
33  double internalTerm = (2.0 * std::log(t / scale) - 2.0 * boost::math::digamma(shape) + 1.0) / scale - t / m_GammaVariance;
34  double derivativeGammaValue = internalTerm * boost::math::gamma_p_derivative(shape, t / scale) / scale;
35 
36  return m_EPGVectors[t][m_EchoNumber] * derivativeGammaValue;
37  }
38 }
39 
40 } // end namespace anima
EPGVectorsMapType & m_EPGVectors
Since boost Gauss Legendre integration works on object copies, we need to keep a reference to EPG vec...
anima::EPGSignalSimulator & m_EPGSimulator
EPG signal simulator reference: instantiated outside.
RealVectorType & GetValue(double t1Value, double t2Value, double flipAngle, double m0Value)
Get EPG values at given point.
RealVectorType & GetFADerivative()
Get EPG derivative values at same point that was used for getting EPG values. Requires a run of GetVa...