Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
itkDiffusionTensor3DZeroCorrection.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Diffusion Applications
4  Module: $HeadURL$
5  Language: C++
6  Date: $Date$
7  Version: $Revision$
8 
9  Copyright (c) Brigham and Women's Hospital (BWH) All Rights Reserved.
10 
11  See License.txt or http://www.slicer.org/copyright/copyright.txt for details.
12 
13 ==========================================================================*/
14 #ifndef itkDiffusionTensor3DZeroCorrection_h
15 #define itkDiffusionTensor3DZeroCorrection_h
16 
17 #include "itkUnaryFunctorImageFilter.h"
18 #include "vnl/vnl_math.h"
19 #include <itkMatrix.h>
22 
23 namespace itk
24 {
25 
44 namespace Functor
45 {
46 
47 template <class TInput, class TOutput>
49 {
50 public:
52  {
53  }
55  {
56  }
57  bool operator!=( const DiffusionTensor3DZero & other ) const
58  {
59  return *this != other;
60  }
61 
62  bool operator==( const DiffusionTensor3DZero & other ) const
63  {
64  return !( *this != other );
65  }
66 
67  inline DiffusionTensor3D<TOutput> operator()
68  ( const DiffusionTensor3D<TInput> & A )
69  {
70  DiffusionTensor3D<TOutput> tensor;
71  Matrix<double, 3, 3> mat;
72  Matrix<double, 3, 3> matcorrect;
75  DiffusionTensor3DExtended<double> tensorDouble( A );
76  tensorDouble.ComputeEigenAnalysis( eigenValues, eigenVectors );
77  for( int i = 0; i < 3; i++ )
78  {
79  mat[i][i] = ( eigenValues[i] <= 0 ? ITK_DIFFUSION_TENSOR_3D_ZERO : eigenValues[i] );
80  }
81  eigenVectors = eigenVectors.GetTranspose();
82  matcorrect = eigenVectors * mat * eigenVectors.GetInverse();
83  tensorDouble.SetTensorFromMatrix( matcorrect );
84  for( int i = 0; i < 6; i++ )
85  {
86  tensor[i] = ( TOutput ) tensorDouble[i];
87  }
88  return tensor;
89  }
90 
91 };
92 } // end of Functor namespace
93 
94 template <class TInputImage, class TOutputImage>
96  public
97  UnaryFunctorImageFilter<TInputImage, TOutputImage,
98  Functor::DiffusionTensor3DZero<
99  typename TInputImage::PixelType::ComponentType,
100  typename TOutputImage::PixelType::ComponentType> >
101 {
102 public:
105  typedef UnaryFunctorImageFilter<TInputImage, TOutputImage,
106  Functor::DiffusionTensor3DZero<typename TInputImage::PixelType,
107  typename TOutputImage::PixelType> > Superclass;
108  typedef SmartPointer<Self> Pointer;
109  typedef SmartPointer<const Self> ConstPointer;
110 
112  itkTypeMacro(DiffusionTensor3DZeroCorrectionFilter, UnaryFunctorImageFilter);
113 
115  itkNewMacro( Self );
116 
117 #ifdef ITK_USE_CONCEPT_CHECKING
118 
119  itkConceptMacro( InputTensorTypeCheck,
120  ( Concept::SameType<DiffusionTensor3D<typename TInputImage::PixelType::ComponentType>,
121  typename TInputImage::PixelType> ) );
122  itkConceptMacro( OutputTensorTypeCheck,
123  ( Concept::SameType<DiffusionTensor3D<typename TOutputImage::PixelType::ComponentType>,
124  typename TOutputImage::PixelType> ) );
125 
127 #endif
128 protected:
130  {
131  }
133  {
134  }
135 private:
136  DiffusionTensor3DZeroCorrectionFilter( const Self & ); // purposely not implemented
137  void operator=( const Self & ); // purposely not implemented
138 
139 };
140 
141 } // end namespace itk
142 
143 #endif
bool operator==(const DiffusionTensor3DZero &other) const
void SetTensorFromMatrix(Matrix< C, 3, 3 > matrix)
Simplified inverse ITK transforms.
* itkConceptMacro(OutputEqualityComparableCheck, *(Concept::EqualityComparable< OutputImagePixelType >))
bool operator!=(const DiffusionTensor3DZero &other) const
#define ITK_DIFFUSION_TENSOR_3D_ZERO
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::DiffusionTensor3DZero< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass