ANIMA  4.0
animaBaseIsotropicCompartment.cxx
Go to the documentation of this file.
2 #include <animaMCMConstants.h>
3 
4 #include <cmath>
5 
6 namespace anima
7 {
8 
9 double BaseIsotropicCompartment::GetFourierTransformedDiffusionProfile(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient)
10 {
11  double bValue = anima::GetBValueFromAcquisitionParameters(smallDelta, bigDelta, gradientStrength);
12  return std::exp(- bValue * this->GetAxialDiffusivity());
13 }
14 
15 BaseCompartment::ListType &BaseIsotropicCompartment::GetSignalAttenuationJacobian(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient)
16 {
18 
19  if (m_JacobianVector.size() == 0)
20  return m_JacobianVector;
21 
22  double signalAttenuation = this->GetFourierTransformedDiffusionProfile(smallDelta, bigDelta, gradientStrength, gradient);
23  double bValue = anima::GetBValueFromAcquisitionParameters(smallDelta, bigDelta, gradientStrength);
24 
25  m_JacobianVector[0] = - bValue * signalAttenuation;
26  return m_JacobianVector;
27 }
28 
30 {
31  double resVal = - 1.5 * std::log(2.0 * M_PI * this->GetAxialDiffusivity());
32 
33  resVal -= sample.squared_magnitude() / (2.0 * this->GetAxialDiffusivity());
34 
35  return resVal;
36 }
37 
39 {
40  if (params.size() != this->GetNumberOfParameters())
41  return;
42 
43  if (m_EstimateAxialDiffusivity)
44  this->SetAxialDiffusivity(params[0]);
45 }
46 
48 {
50 
51  if (m_EstimateAxialDiffusivity)
53 
54  return m_ParametersVector;
55 }
56 
58 {
59  if (m_EstimateAxialDiffusivity == arg)
60  return;
61 
62  m_EstimateAxialDiffusivity = arg;
63  m_ChangedConstraints = true;
64 }
65 
67 {
68  if (compartmentVector.GetSize() != this->GetCompartmentSize())
69  itkExceptionMacro("The input vector size does not match the size of the compartment");
70 
71  this->SetAxialDiffusivity(compartmentVector[0]);
72 }
73 
75 {
76  return 1;
77 }
78 
80 {
81  if (!m_ChangedConstraints)
82  return m_NumberOfParameters;
83 
84  m_NumberOfParameters = this->GetCompartmentSize();
85 
86  if (!m_EstimateAxialDiffusivity)
87  --m_NumberOfParameters;
88 
89  m_ChangedConstraints = false;
90  return m_NumberOfParameters;
91 }
92 
94 {
95  if (m_CompartmentVector.GetSize() != this->GetCompartmentSize())
96  m_CompartmentVector.SetSize(this->GetCompartmentSize());
97 
99 
100  return m_CompartmentVector;
101 }
102 
104 {
105  m_DiffusionTensor.Fill(0);
106 
107  for (unsigned int i = 0;i < m_SpaceDimension;++i)
108  m_DiffusionTensor(i,i) = this->GetAxialDiffusivity();
109 
110  return m_DiffusionTensor;
111 }
112 
114 {
115  return 0;
116 }
117 
119 {
120  return this->GetAxialDiffusivity();
121 }
122 
124 {
125  return this->GetAxialDiffusivity();
126 }
127 
129 {
130  return this->GetAxialDiffusivity();
131 }
132 
133 } //end namespace anima
134 
std::vector< double > ListType
virtual void SetAxialDiffusivity(double num)
unsigned int GetNumberOfParameters() ITK_OVERRIDE
Number of optimized parameters: smaller than total number of parameters.
itk::VariableLengthVector< double > ModelOutputVectorType
const Matrix3DType & GetDiffusionTensor() ITK_OVERRIDE
Get compartment as a 3D tensor (default behavior: throw exception if not supported by the compartment...
vnl_vector_fixed< double, 3 > Vector3DType
ModelOutputVectorType & GetCompartmentVector() ITK_OVERRIDE
Get compartment overall description vector, mainly for writing, should be self-contained.
unsigned int GetCompartmentSize() ITK_OVERRIDE
Number of parameters to describe the model, these parameters will be self-contained, i.e. include fixed parameters for example.
virtual double GetAxialDiffusivity()
ListType m_ParametersVector
Vector holding current parameters vector.
virtual ListType & GetParametersAsVector() ITK_OVERRIDE
double GetBValueFromAcquisitionParameters(double smallDelta, double bigDelta, double gradientStrength)
Given gyromagnetic ratio in rad/s/T, gradient strength in T/mm and deltas in s, computes b-value in s...
double GetApparentPerpendicularDiffusivity() ITK_OVERRIDE
Get approximation to perpendicular diffusivity of the compartment (may be different from radial diffu...
virtual void SetParametersFromVector(const ListType &params) ITK_OVERRIDE
Various methods for optimization parameters setting and getting.
virtual double GetFourierTransformedDiffusionProfile(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient) ITK_OVERRIDE
virtual ListType & GetSignalAttenuationJacobian(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient) ITK_OVERRIDE
Superclass::ModelOutputVectorType ModelOutputVectorType
ListType m_JacobianVector
Vector holding current jacobian value.
virtual double GetLogDiffusionProfile(const Vector3DType &sample) ITK_OVERRIDE
ModelOutputVectorType m_CompartmentVector
Vector to hold working value of compartment vector.
void SetCompartmentVector(ModelOutputVectorType &compartmentVector) ITK_OVERRIDE
Set compartment overall description vector, for setting automatically the individual parameters when ...
static const unsigned int m_SpaceDimension
double GetApparentParallelDiffusivity() ITK_OVERRIDE
Get approximation to parallel diffusivity of the compartment (may be different from axial diffusivity...