Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkOrientationDistributionFunction_h
00019 #define __itkOrientationDistributionFunction_h
00020
00022
00023
00024
00025
00026 #include "MitkDiffusionImagingExports.h"
00027 #include "itkIndent.h"
00028 #include "itkFixedArray.h"
00029 #include "itkMatrix.h"
00030 #include "itkSymmetricEigenAnalysis.h"
00031 #include "itkSimpleFastMutexLock.h"
00032 #include "itkDiffusionTensor3D.h"
00033
00034 #include "vtkPolyData.h"
00035 #include "vtkPoints.h"
00036 #include "vtkCellArray.h"
00037 #include "vtkDelaunay2D.h"
00038 #include "vtkCleanPolyData.h"
00039 #include "vtkAppendPolyData.h"
00040 #include "vtkPlane.h"
00041
00042 namespace itk
00043 {
00044
00055 template < typename TComponent, unsigned int NOdfDirections >
00056 class OrientationDistributionFunction: public
00057 FixedArray<TComponent,NOdfDirections>
00058 {
00059 public:
00060
00061 enum InterpolationMethods {
00062 ODF_NEAREST_NEIGHBOR_INTERP,
00063 ODF_TRILINEAR_BARYCENTRIC_INTERP,
00064 ODF_SPHERICAL_GAUSSIAN_BASIS_FUNCTIONS
00065 };
00066
00068 typedef OrientationDistributionFunction Self;
00069 typedef FixedArray<TComponent,NOdfDirections> Superclass;
00070
00072 itkStaticConstMacro(InternalDimension, unsigned int, NOdfDirections);
00073
00075 typedef FixedArray<TComponent,
00076 itkGetStaticConstMacro(InternalDimension)> BaseArray;
00077
00079 typedef TComponent ComponentType;
00080 typedef typename Superclass::ValueType ValueType;
00081 typedef typename NumericTraits<ValueType>::RealType AccumulateValueType;
00082 typedef typename NumericTraits<ValueType>::RealType RealValueType;
00083
00084 typedef Matrix<TComponent, NOdfDirections, NOdfDirections> MatrixType;
00085
00086 typedef vnl_matrix_fixed<double, 3, NOdfDirections> DirectionsType;
00087
00089 OrientationDistributionFunction() {this->Fill(0);}
00090
00091 OrientationDistributionFunction (const ComponentType& r) { this->Fill(r); }
00092
00093 typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ];
00094
00096 OrientationDistributionFunction(const Self& r): BaseArray(r) {}
00097 OrientationDistributionFunction(const ComponentArrayType r): BaseArray(r) {}
00098
00100 Self& operator= (const Self& r);
00101 Self& operator= (const ComponentType& r);
00102 Self& operator= (const ComponentArrayType r);
00103
00105 Self operator+(const Self &vec) const;
00106 Self operator-(const Self &vec) const;
00107 const Self & operator+=(const Self &vec);
00108 const Self & operator-=(const Self &vec);
00109
00111 Self operator*(const RealValueType & scalar ) const;
00112 Self operator/(const RealValueType & scalar ) const;
00113 const Self & operator*=(const RealValueType & scalar );
00114 const Self & operator/=(const RealValueType & scalar );
00115
00117 static DirectionsType* GetDirections()
00118 {
00119 return itkGetStaticConstMacro(m_Directions);
00120 }
00121
00123 static unsigned int GetNumberOfComponents()
00124 {
00125 return itkGetStaticConstMacro(InternalDimension);
00126 }
00127
00129 ComponentType GetNthComponent(int c) const
00130 { return this->operator[](c); }
00131
00133 ComponentType GetInterpolatedComponent( vnl_vector_fixed<double,3> dir, InterpolationMethods method ) const;
00134
00136 void SetNthComponent(int c, const ComponentType& v)
00137 { this->operator[](c) = v; }
00138
00140 ValueType & operator()( unsigned int row, unsigned int col );
00141 const ValueType & operator()( unsigned int row, unsigned int col ) const;
00142
00144 void SetIsotropic();
00145
00146 void InitFromTensor(itk::DiffusionTensor3D<TComponent> tensor);
00147
00149 Self PreMultiply( const MatrixType & m ) const;
00150
00152 Self PostMultiply( const MatrixType & m ) const;
00153
00154 void Normalize();
00155
00156 Self MinMaxNormalize() const;
00157
00158 Self MaxNormalize() const;
00159
00160 int GetPrincipleDiffusionDirection() const;
00161
00162 int GetNthDiffusionDirection(int n, vnl_vector_fixed<double,3> rndVec) const;
00163
00164 TComponent GetGeneralizedFractionalAnisotropy() const;
00165
00166 TComponent GetGeneralizedGFA(int k, int p) const;
00167
00168 TComponent GetNormalizedEntropy() const;
00169
00170 TComponent GetNematicOrderParameter() const;
00171
00172 TComponent GetStdDevByMaxValue() const;
00173
00174 TComponent GetPrincipleCurvature(double alphaMinDegree, double alphaMaxDegree, int invert) const;
00175
00176 static std::vector<int> GetNeighbors(int idx);
00177
00178 static vtkPolyData* GetBaseMesh(){ComputeBaseMesh(); return m_BaseMesh;}
00179
00180 static void ComputeBaseMesh();
00181
00182 static double GetMaxChordLength();
00183
00184 static vnl_vector_fixed<double,3> GetDirection(int i);
00185
00186 private:
00187
00188 static vtkPolyData* m_BaseMesh;
00189
00190 static double m_MaxChordLength;
00191
00192 static DirectionsType* m_Directions;
00193
00194 static std::vector< std::vector<int>* >* m_NeighborIdxs;
00195
00196 static std::vector< std::vector<int>* >* m_AngularRangeIdxs;
00197
00198 static std::vector<int>* m_HalfSphereIdxs;
00199
00200 static itk::SimpleFastMutexLock m_MutexBaseMesh;
00201 static itk::SimpleFastMutexLock m_MutexHalfSphereIdxs;
00202 static itk::SimpleFastMutexLock m_MutexNeighbors;
00203 static itk::SimpleFastMutexLock m_MutexAngularRange;
00204
00205 };
00206
00209 typedef std::ostream OutputStreamType;
00210 typedef std::istream InputStreamType;
00211
00212 template< typename TComponent, unsigned int NOdfDirections >
00213 MitkDiffusionImaging_EXPORT OutputStreamType& operator<<(OutputStreamType& os,
00214 const OrientationDistributionFunction<TComponent,NOdfDirections> & c);
00215 template< typename TComponent, unsigned int NOdfDirections >
00216 MitkDiffusionImaging_EXPORT InputStreamType& operator>>(InputStreamType& is,
00217 OrientationDistributionFunction<TComponent,NOdfDirections> & c);
00218
00219
00220
00221 }
00222
00223
00224
00225
00226
00227 #define ITK_TEMPLATE_OrientationDistributionFunction(_, EXPORT, x, y) namespace itk { \
00228 _(2(class MitkDiffusionImaging_EXPORT EXPORT OrientationDistributionFunction< ITK_TEMPLATE_2 x >)) \
00229 namespace Templates { typedef OrientationDistributionFunction< ITK_TEMPLATE_2 x > \
00230 OrientationDistributionFunction##y; } \
00231 }
00232
00233 #if ITK_TEMPLATE_EXPLICIT
00234 # include "Templates/itkOrientationDistributionFunction+-.h"
00235 #endif
00236
00237 #if ITK_TEMPLATE_TXX
00238 # include "itkOrientationDistributionFunction.txx"
00239 #endif
00240
00241
00242 #endif //__itkOrientationDistributionFunction_h