Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkOrientationDistributionFunction.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef __itkOrientationDistributionFunction_h
18 #define __itkOrientationDistributionFunction_h
19 
21 #include "itkIndent.h"
22 #include "itkFixedArray.h"
23 #include "itkMatrix.h"
24 #include "itkSymmetricEigenAnalysis.h"
25 #include "itkSimpleFastMutexLock.h"
26 #include "itkDiffusionTensor3D.h"
27 
28 #include "vtkPolyData.h"
29 #include "vtkPoints.h"
30 #include "vtkCellArray.h"
31 #include "vtkDelaunay2D.h"
32 #include "vtkCleanPolyData.h"
33 #include "vtkAppendPolyData.h"
34 #include "vtkPlane.h"
35 
36 namespace itk
37 {
38 
49 template < typename TComponent, unsigned int NOdfDirections >
51  FixedArray<TComponent,NOdfDirections>
52 {
53 public:
54 
59  };
60 
63  typedef FixedArray<TComponent,NOdfDirections> Superclass;
64 
66  itkStaticConstMacro(InternalDimension, unsigned int, NOdfDirections);
67 
69  typedef FixedArray<TComponent,
70  itkGetStaticConstMacro(InternalDimension)> BaseArray;
71 
73  typedef TComponent ComponentType;
74  typedef typename Superclass::ValueType ValueType;
75  typedef typename NumericTraits<ValueType>::RealType AccumulateValueType;
76  typedef typename NumericTraits<ValueType>::RealType RealValueType;
77 
78  typedef Matrix<TComponent, NOdfDirections, NOdfDirections> MatrixType;
79 
80  typedef vnl_matrix_fixed<double, 3, NOdfDirections> DirectionsType;
81 
84 
85  OrientationDistributionFunction (const ComponentType& r) { this->Fill(r); }
86 
87  typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ];
88 
91  OrientationDistributionFunction(const ComponentArrayType r): BaseArray(r) {}
92 
94  Self& operator= (const Self& r);
95  Self& operator= (const ComponentType& r);
96  Self& operator= (const ComponentArrayType r);
97 
99  Self operator+(const Self &vec) const;
100  Self operator-(const Self &vec) const;
101  const Self & operator+=(const Self &vec);
102  const Self & operator-=(const Self &vec);
103 
105  Self operator*(const RealValueType & scalar ) const;
106  Self operator/(const RealValueType & scalar ) const;
107  const Self & operator*=(const RealValueType & scalar );
108  const Self & operator/=(const RealValueType & scalar );
109 
111  static DirectionsType* GetDirections()
112  {
113  return itkGetStaticConstMacro(m_Directions);
114  }
115 
117  static unsigned int GetNumberOfComponents()
118  {
119  return itkGetStaticConstMacro(InternalDimension);
120  }
121 
123  ComponentType GetNthComponent(int c) const
124  { return this->operator[](c); }
125 
127  ComponentType GetInterpolatedComponent( vnl_vector_fixed<double,3> dir, InterpolationMethods method ) const;
128 
130  void SetNthComponent(int c, const ComponentType& v)
131  { this->operator[](c) = v; }
132 
134  ValueType & operator()( unsigned int row, unsigned int col );
135  const ValueType & operator()( unsigned int row, unsigned int col ) const;
136 
138  void SetIsotropic();
139 
140  void InitFromTensor(itk::DiffusionTensor3D<TComponent> tensor);
141 
143  void InitFromEllipsoid(itk::DiffusionTensor3D<TComponent> tensor);
144 
146  Self PreMultiply( const MatrixType & m ) const;
147 
149  Self PostMultiply( const MatrixType & m ) const;
150 
151  void Normalize();
152 
153  Self MinMaxNormalize() const;
154 
155  Self MaxNormalize() const;
156 
157  void L2Normalize();
158 
159  int GetPrincipleDiffusionDirection() const;
160 
161  int GetNthDiffusionDirection(int n, vnl_vector_fixed<double,3> rndVec) const;
162 
163  TComponent GetGeneralizedFractionalAnisotropy() const;
164 
165  TComponent GetGeneralizedGFA(int k, int p) const;
166 
167  TComponent GetNormalizedEntropy() const;
168 
169  TComponent GetNematicOrderParameter() const;
170 
171  TComponent GetStdDevByMaxValue() const;
172 
173  ComponentType GetMaxValue() const;
174 
175  ComponentType GetMinValue() const;
176 
177  ComponentType GetMeanValue() const;
178 
179  TComponent GetPrincipleCurvature(double alphaMinDegree, double alphaMaxDegree, int invert) const;
180 
181  static std::vector<int> GetNeighbors(int idx);
182 
183  static vtkPolyData* GetBaseMesh(){ComputeBaseMesh(); return m_BaseMesh;}
184 
185  static void ComputeBaseMesh();
186 
187  static double GetMaxChordLength();
188 
189  static vnl_vector_fixed<double,3> GetDirection(int i);
190 
191 private:
192 
193  static vtkPolyData* m_BaseMesh;
194 
195  static double m_MaxChordLength;
196 
197  static DirectionsType* m_Directions;
198 
199  static std::vector< std::vector<int>* >* m_NeighborIdxs;
200 
201  static std::vector< std::vector<int>* >* m_AngularRangeIdxs;
202 
203  static std::vector<int>* m_HalfSphereIdxs;
204 
205  static itk::SimpleFastMutexLock m_MutexBaseMesh;
206  static itk::SimpleFastMutexLock m_MutexHalfSphereIdxs;
207  static itk::SimpleFastMutexLock m_MutexNeighbors;
208  static itk::SimpleFastMutexLock m_MutexAngularRange;
209 
210 };
211 
214 typedef std::ostream OutputStreamType;
215 typedef std::istream InputStreamType;
216 
217 template< typename TComponent, unsigned int NOdfDirections >
218 MITKDIFFUSIONCORE_EXPORT OutputStreamType& operator<<(OutputStreamType& os,
220 template< typename TComponent, unsigned int NOdfDirections >
221 MITKDIFFUSIONCORE_EXPORT InputStreamType& operator>>(InputStreamType& is,
223 
224 
225 
226 } // end namespace itk
227 
228 // Define instantiation macro for this template.
229 #define ITK_TEMPLATE_OrientationDistributionFunction(_, EXPORT, x, y) namespace itk { \
230  _(2(class MITKDIFFUSIONCORE_EXPORT EXPORT OrientationDistributionFunction< ITK_TEMPLATE_2 x >)) \
231  namespace Templates { typedef OrientationDistributionFunction< ITK_TEMPLATE_2 x > \
232  OrientationDistributionFunction##y; } \
233  }
234 
235 #if ITK_TEMPLATE_EXPLICIT
236 # include "Templates/itkOrientationDistributionFunction+-.h"
237 #endif
238 
239 #if ITK_TEMPLATE_TXX
241 #endif
242 
243 
244 #endif //__itkOrientationDistributionFunction_h
NumericTraits< ValueType >::RealType AccumulateValueType
Self operator+(const Self &vec) const
std::istream InputStreamType
ComponentType ComponentArrayType[itkGetStaticConstMacro(InternalDimension)]
vnl_matrix_fixed< double, 3, NOdfDirections > DirectionsType
ComponentType GetMinValue() const
TComponent GetPrincipleCurvature(double alphaMinDegree, double alphaMaxDegree, int invert) const
int GetNthDiffusionDirection(int n, vnl_vector_fixed< double, 3 > rndVec) const
void SetNthComponent(int c, const ComponentType &v)
ComponentType GetMeanValue() const
std::ostream OutputStreamType
ValueType & operator()(unsigned int row, unsigned int col)
const Self & operator*=(const RealValueType &scalar)
Self PostMultiply(const MatrixType &m) const
#define MITKDIFFUSIONCORE_EXPORT
Self PreMultiply(const MatrixType &m) const
Self operator-(const Self &vec) const
ComponentType GetMaxValue() const
const Self & operator+=(const Self &vec)
FixedArray< TComponent, NOdfDirections > Superclass
Represents an ODF for Q-Ball imaging.
static vnl_vector_fixed< double, 3 > GetDirection(int i)
Self operator/(const RealValueType &scalar) const
FixedArray< TComponent, itkGetStaticConstMacro(InternalDimension)> BaseArray
TComponent GetNormalizedEntropy() const
ValueType
Type of the value held by a Value object.
Definition: jsoncpp.h:345
static std::vector< int > GetNeighbors(int idx)
NumericTraits< ValueType >::RealType RealValueType
void InitFromEllipsoid(itk::DiffusionTensor3D< TComponent > tensor)
Self operator*(const RealValueType &scalar) const
TComponent GetNematicOrderParameter() const
TComponent GetGeneralizedGFA(int k, int p) const
TComponent GetStdDevByMaxValue() const
void InitFromTensor(itk::DiffusionTensor3D< TComponent > tensor)
itkStaticConstMacro(InternalDimension, unsigned int, NOdfDirections)
const Self & operator-=(const Self &vec)
MITKDIFFUSIONCORE_EXPORT InputStreamType & operator>>(InputStreamType &is, OrientationDistributionFunction< TComponent, NOdfDirections > &c)
MITKDIFFUSIONCORE_EXPORT OutputStreamType & operator<<(OutputStreamType &os, const OrientationDistributionFunction< TComponent, NOdfDirections > &c)
Matrix< TComponent, NOdfDirections, NOdfDirections > MatrixType
const Self & operator/=(const RealValueType &scalar)
ComponentType GetInterpolatedComponent(vnl_vector_fixed< double, 3 > dir, InterpolationMethods method) const
TComponent GetGeneralizedFractionalAnisotropy() const