19 #ifndef __itkDiffusionTensor_h 20 #define __itkDiffusionTensor_h 22 #include <itkDiffusionTensor3D.h> 45 template<
class TPrecision >
76 template<
class TTensorValueType >
83 if ((*
this)[i]!=mat[i])
93 inline bool IsSame(
const Self & mat,
const double eps=1e-8)
const 97 if ( std::fabs((*
this)[i]-mat[i]) > eps )
103 template<
class TMatrixType >
106 for (
unsigned int i = 0; i <
NDimension; i++ )
108 (*
this)[NDimension*i-(i+1)*i/2+j] = mat(i,j);
115 for (
unsigned int i = 0; i <
NDimension; i++ )
116 result[i] = ( *
this )[i] - mat[i];
122 for (
unsigned int i = 0; i <
NDimension; i++ )
123 result[i] = ( *
this )[i] + mat[i];
133 inline vnl_matrix<TPrecision>
operator*(
const vnl_matrix<TPrecision>& A)
const 146 result[i] += (*
this)(i,j)*v[j];
153 ValueType &
operator()(
unsigned int row,
unsigned int col);
155 const ValueType &
operator()(
unsigned int row,
unsigned int col)
const;
157 void Flip(
const int flipx,
const int flipy,
const int flipz)
159 double sign_xy = flipx^flipy ? -1 : 1;
160 double sign_xz = flipx^flipz ? -1 : 1;
161 double sign_yz = flipy^flipz ? -1 : 1;
162 (*this)[1] = sign_xy*(*this)[1];
163 (*this)[2] = sign_xz*(*this)[2];
164 (*this)[4] = sign_yz*(*this)[4];
173 void GetEigenValuesVectors(vnl_diag_matrix<TPrecision> & eigenValues, vnl_matrix<TPrecision> & eigenVectors)
const;
185 template<
class TArrayType,
class TMatrixType >
188 template <
class TArrayType >
190 template <
class TMatrixType >
194 inline void SetVnlMatrix(
const vnl_matrix<TPrecision> & mat);
203 inline Self
GetRotate (
const typename Self::MatrixType& mat)
const;
204 inline Self&
Rotate (
const typename Self::MatrixType& mat);
207 inline vnl_matrix<TPrecision>
GetRotate (
const vnl_matrix<TPrecision> & vec)
const;
209 double GetQuadraticForm(
const double x,
const double y,
const double z)
const;
214 template <
class TVectorType >
220 template <
class TVectorType >
226 template <
class TVectorType >
233 template <
class TVectorType >
241 RealValueType
GetGA()
const;
243 RealValueType
GetFA()
const;
247 RealValueType
GetRA()
const;
249 RealValueType
GetADC()
const;
255 bool IsZero(
const double eps=1e-10)
const;
258 bool IsDiagonal(
const double eps=1e-10)
const;
263 inline Self
Log()
const;
266 inline Self
Exp ()
const;
269 inline Self
Pow (
const double& n)
const;
270 inline Self
Inv ()
const;
271 inline Self
Sqrt ()
const;
279 void Print(std::ostream& os, Indent indent=0)
const 284 for (
int j = 0; j < NDimension -1; j += 1 )
285 os<< (*
this)(i,j) <<
" ";
286 os << (*this)(i,NDimension-1) <<
"; ";
288 os <<
"];" << std::endl;
296 #define ITK_TEMPLATE_DiffusionTensor(_, EXPORT, TypeX, TypeY) \ 299 _( 2 ( class EXPORT DiffusionTensor< ITK_TEMPLATE_2 TypeX > ) ) \ 300 namespace Templates \ 302 typedef DiffusionTensor< ITK_TEMPLATE_2 TypeX > \ 303 DiffusionTensor##TypeY; \ 307 #if ITK_TEMPLATE_EXPLICIT 308 #include "Templates/itkDiffusionTensor+-.h" 311 #if !defined(ITK_MANUAL_INSTANTIATION) && !defined(__itkDiffusionTensor_hxx) Superclass::RealValueType RealValueType
NDArray is a N-Dimensional array class (row-major, c version)
void GetEAPSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const std::vector< TPrecision > &rValues, const TPrecision &tau) const
RealValueType GetMODE() const
TPrecision GeodesicDistance(const DiffusionTensor< TPrecision > &X) const
TPrecision LogEucDistance(const DiffusionTensor< TPrecision > &X) const
TPrecision EuclideanDistance(const DiffusionTensor< TPrecision > &X) const
static const unsigned int NDegreesOfFreedom
RealValueType GetRA() const
void GetDWISamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const std::vector< TPrecision > &bValues) const
RealValueType GetReturnToOrigin(const TPrecision tau) const
Self Pow(const double &n) const
void GetEigenValuesVectors(vnl_diag_matrix< TPrecision > &eigenValues, vnl_matrix< TPrecision > &eigenVectors) const
Return an array containing EigenValues in ascending order, and a matrix containing the corresponding ...
void GetEigenValuesVectorsAnalytic(TArrayType &eigenValues, TMatrixType &eigenVectors) const
analytic way to calculate eigenValues (in ascending order) and eigenVectors. In mathematica, Eigenvectors[( { {a, b, c}, {b, d, e}, {c, e, f} } )]
VectorType operator*(const VectorType &v) const
bool IsSame(const Self &mat, const double eps=1e-8) const
double GetDeterminant() const
RealValueType GetFA() const
Self & Rotate(const typename Self::MatrixType &mat)
ValueType & operator()(unsigned int row, unsigned int col)
bool operator==(const Self &mat) const
Self operator*(const Self &A) const
static const unsigned int NDimension
RealValueType GetADC() const
void Flip(const int flipx, const int flipy, const int flipz)
Self & operator=(const TMatrixType &mat)
Superclass::AccumulateValueType AccumulateValueType
Superclass::EigenValuesArrayType EigenValuesArrayType
DiffusionTensor(const Self &r)
void SetEigenValues(const TArrayType &array)
DiffusionTensor3D< TPrecision > Superclass
RealValueType GetMD() const
vnl_matrix< TPrecision > GetVnlMatrix() const
Superclass::EigenVectorsMatrixType EigenVectorsMatrixType
bool operator!=(const Self &mat) const
void SetVnlMatrix(const vnl_matrix< TPrecision > &mat)
bool IsZero(const double eps=1e-10) const
bool IsDiagonal(const double eps=1e-10) const
vnl_matrix< TPrecision > operator*(const vnl_matrix< TPrecision > &A) const
void Print(std::ostream &os, Indent indent=0) const
RealValueType GetGA() const
DiffusionTensor(const DiffusionTensor< TTensorValueType > &v)
Self operator+(const Self &mat) const
void GetSphericalSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients) const
RealValueType GetMeanSquaredDisplacement(const TPrecision tau) const
void GetODFSamples(TVectorType &vec, const utl::NDArray< TPrecision, 2 > &gradients, const int &odfOrder=2, const bool &isNormalize=false) const
Self GetRotate(const typename Self::MatrixType &mat) const
TPrecision KLDistance(const DiffusionTensor< TPrecision > &X) const
Superclass::ComponentType ComponentType
double GetQuadraticForm(const double x, const double y, const double z) const
tensor with some useful functions
Superclass::ValueType ValueType
Superclass::SymmetricEigenAnalysisType SymmetricEigenAnalysisType
Vector< TPrecision, NDimension > VectorType
Self operator-(const Self &mat) const
void SetEigenVectors(const TMatrixType &vectors)