ANIMA  4.0
animaBaseCompartment.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <vnl/vnl_vector_fixed.h>
5 #include <itkMatrix.h>
6 #include <itkLightObject.h>
7 #include <itkObjectFactory.h>
8 #include <itkVariableLengthVector.h>
9 
10 #include <AnimaMCMBaseExport.h>
11 #include <animaMCMConstants.h>
12 
13 namespace anima
14 {
15 
16 // Types of diffusion model compartments, update if new derived class of base compartment is created
18 {
19  FreeWater = 0,
28 };
29 
30 class ANIMAMCMBASE_EXPORT BaseCompartment : public itk::LightObject
31 {
32 public:
33  // Useful typedefs
35  typedef itk::LightObject Superclass;
36  typedef itk::SmartPointer<Self> Pointer;
37  typedef itk::SmartPointer<const Self> ConstPointer;
38  typedef itk::Matrix <double, 3, 3> Matrix3DType;
39 
41  itkTypeMacro(BaseCompartment, itk::LightObject)
42 
43 
44  virtual DiffusionModelCompartmentType GetCompartmentType() = 0;
45 
46  typedef vnl_vector_fixed <double,3> Vector3DType;
47  typedef std::vector <double> ListType;
48  typedef itk::VariableLengthVector <double> ModelOutputVectorType;
49 
50  virtual double GetFourierTransformedDiffusionProfile(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient) = 0;
51  virtual ListType &GetSignalAttenuationJacobian(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient) = 0;
52  virtual double GetLogDiffusionProfile(const Vector3DType &sample) = 0;
53 
55  virtual void SetParametersFromVector(const ListType &params) = 0;
56  virtual ListType &GetParametersAsVector() = 0;
57 
58  virtual ListType &GetParameterLowerBounds() = 0;
59  virtual ListType &GetParameterUpperBounds() = 0;
60 
62  virtual ModelOutputVectorType &GetCompartmentVector() = 0;
63 
65  virtual void SetCompartmentVector(ModelOutputVectorType &compartmentVector) = 0;
66 
68  virtual void CopyFromOther(Self *rhs);
69 
71  virtual bool IsEqual(Self *rhs, double tolerance = 1.0e-2, double absoluteTolerance = 1.0e-8);
72 
74  virtual unsigned int GetCompartmentSize() = 0;
75 
77  virtual unsigned int GetNumberOfParameters() = 0;
78 
80  virtual void Reorient(vnl_matrix <double> &orientationMatrix, bool affineTransform);
81 
82  virtual double GetOrientationTheta() {return m_OrientationTheta;}
83  virtual double GetOrientationPhi() {return m_OrientationPhi;}
84  virtual double GetPerpendicularAngle() {return m_PerpendicularAngle;}
85  virtual double GetAxialDiffusivity() {return m_AxialDiffusivity;}
86  virtual double GetRadialDiffusivity1() {return m_RadialDiffusivity1;}
87  virtual double GetRadialDiffusivity2() {return m_RadialDiffusivity2;}
88  virtual double GetOrientationConcentration() {return m_OrientationConcentration;}
89  virtual double GetExtraAxonalFraction() {return m_ExtraAxonalFraction;}
90  virtual double GetTissueRadius() {return m_TissueRadius;}
91 
92  // Can be re-implemented, always re-use this implementation though
93  virtual void SetOrientationTheta(double num) {m_OrientationTheta = num;}
94  virtual void SetOrientationPhi(double num) {m_OrientationPhi = num;}
95  virtual void SetPerpendicularAngle(double num) {m_PerpendicularAngle = num;}
96  virtual void SetAxialDiffusivity(double num) {m_AxialDiffusivity = num;}
97  virtual void SetRadialDiffusivity1(double num) {m_RadialDiffusivity1 = num;}
98  virtual void SetRadialDiffusivity2(double num) {m_RadialDiffusivity2 = num;}
99  virtual void SetOrientationConcentration(double num) {m_OrientationConcentration = num;}
100  virtual void SetExtraAxonalFraction(double num) {m_ExtraAxonalFraction = num;}
101  virtual void SetTissueRadius(double num) {m_TissueRadius = num;}
102 
103  double GetPredictedSignal(double smallDelta, double bigDelta, double gradientStrength, const Vector3DType &gradient);
104 
105  virtual bool GetTensorCompatible() {return true;}
107  virtual const Matrix3DType &GetDiffusionTensor();
108 
109  // Getters for complex properties of compartment
110  virtual double GetApparentFractionalAnisotropy();
111  virtual double GetApparentMeanDiffusivity();
112 
114  virtual double GetApparentParallelDiffusivity();
115 
117  virtual double GetApparentPerpendicularDiffusivity();
118 
119 protected:
120  BaseCompartment() : Superclass()
121  {
122  m_OrientationTheta = 0.0;
123  m_OrientationPhi = 0.0;
124  m_PerpendicularAngle = anima::MCMAzimuthAngleUpperBound / 2.0;
125  m_AxialDiffusivity = 1.71e-3;
126  m_RadialDiffusivity1 = 1.5e-4;
127  m_RadialDiffusivity2 = 1.5e-4;
128  m_OrientationConcentration = 5.0;
129  m_ExtraAxonalFraction = 0.1;
130  m_TissueRadius = 0.01;
131 
132  m_DiffusionTensor.SetIdentity();
133  }
134 
135  virtual ~BaseCompartment() {}
136 
137  static const unsigned int m_SpaceDimension = 3;
138 
140  Matrix3DType m_DiffusionTensor;
141 
144 
147 
150 
153 
155  ModelOutputVectorType m_CompartmentVector;
156 
157 private:
158  double m_OrientationTheta, m_OrientationPhi;
159  double m_PerpendicularAngle;
160  double m_AxialDiffusivity;
161  double m_RadialDiffusivity1, m_RadialDiffusivity2;
162  double m_OrientationConcentration;
163  double m_ExtraAxonalFraction;
164  double m_TissueRadius;
165 };
166 
167 } // end namespace anima
168 
virtual bool GetTensorCompatible()
std::vector< double > ListType
virtual void SetAxialDiffusivity(double num)
ListType m_ParametersLowerBoundsVector
Vector holding current parameters lower bounds.
const double MCMAzimuthAngleUpperBound
Azimuth angle upper bound.
virtual void SetRadialDiffusivity2(double num)
virtual void SetTissueRadius(double num)
virtual double GetOrientationPhi()
itk::VariableLengthVector< double > ModelOutputVectorType
virtual void SetRadialDiffusivity1(double num)
itk::Matrix< double, 3, 3 > Matrix3DType
vnl_vector_fixed< double, 3 > Vector3DType
virtual void SetPerpendicularAngle(double num)
virtual double GetAxialDiffusivity()
ListType m_ParametersVector
Vector holding current parameters vector.
virtual double GetPerpendicularAngle()
virtual double GetOrientationTheta()
virtual void SetOrientationConcentration(double num)
DiffusionModelCompartmentType
virtual void SetExtraAxonalFraction(double num)
virtual double GetExtraAxonalFraction()
itk::SmartPointer< Self > Pointer
virtual void SetOrientationTheta(double num)
ListType m_ParametersUpperBoundsVector
Vector holding current parameters upper bounds.
virtual double GetRadialDiffusivity2()
ListType m_JacobianVector
Vector holding current jacobian value.
virtual double GetRadialDiffusivity1()
virtual void SetOrientationPhi(double num)
virtual double GetTissueRadius()
Matrix3DType m_DiffusionTensor
Matrix to hold working value of diffusion tensor approximation to the model.
itk::SmartPointer< const Self > ConstPointer
ModelOutputVectorType m_CompartmentVector
Vector to hold working value of compartment vector.
virtual double GetOrientationConcentration()