Slicer  4.11
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:
51  DiffusionTensor3DZero() = default;
52  ~DiffusionTensor3DZero() = default;
53  bool operator!=( const DiffusionTensor3DZero & other ) const
54  {
55  return *this != other;
56  }
57 
58  bool operator==( const DiffusionTensor3DZero & other ) const
59  {
60  return !( *this != other );
61  }
62 
63  inline DiffusionTensor3D<TOutput> operator()
64  ( const DiffusionTensor3D<TInput> & A )
65  {
66  DiffusionTensor3D<TOutput> tensor;
67  Matrix<double, 3, 3> mat;
68  Matrix<double, 3, 3> matcorrect;
71  DiffusionTensor3DExtended<double> tensorDouble( A );
72  tensorDouble.ComputeEigenAnalysis( eigenValues, eigenVectors );
73  for( int i = 0; i < 3; i++ )
74  {
75  mat[i][i] = ( eigenValues[i] <= 0 ? ITK_DIFFUSION_TENSOR_3D_ZERO : eigenValues[i] );
76  }
77  eigenVectors = eigenVectors.GetTranspose();
78  matcorrect = eigenVectors * mat * eigenVectors.GetInverse();
79  tensorDouble.SetTensorFromMatrix( matcorrect );
80  for( int i = 0; i < 6; i++ )
81  {
82  tensor[i] = ( TOutput ) tensorDouble[i];
83  }
84  return tensor;
85  }
86 
87 };
88 } // end of Functor namespace
89 
90 template <class TInputImage, class TOutputImage>
92  public
93  UnaryFunctorImageFilter<TInputImage, TOutputImage,
94  Functor::DiffusionTensor3DZero<
95  typename TInputImage::PixelType::ComponentType,
96  typename TOutputImage::PixelType::ComponentType> >
97 {
98 public:
101  typedef UnaryFunctorImageFilter<TInputImage, TOutputImage,
102  Functor::DiffusionTensor3DZero<typename TInputImage::PixelType,
103  typename TOutputImage::PixelType> > Superclass;
104  typedef SmartPointer<Self> Pointer;
105  typedef SmartPointer<const Self> ConstPointer;
106 
108  DiffusionTensor3DZeroCorrectionFilter( const Self & ) = delete;
109  void operator=( const Self & ) = delete;
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  ~DiffusionTensor3DZeroCorrectionFilter() override = default;
131 };
132 
133 } // end namespace itk
134 
135 #endif
bool operator==(const DiffusionTensor3DZero &other) const
itkTypeMacro(DiffusionTensor3DZeroCorrectionFilter, UnaryFunctorImageFilter)
void SetTensorFromMatrix(Matrix< C, 3, 3 > matrix)
Simplified inverse ITK transforms.
* itkConceptMacro(OutputEqualityComparableCheck, *(Concept::EqualityComparable< OutputImagePixelType >))
~DiffusionTensor3DZeroCorrectionFilter() override=default
bool operator!=(const DiffusionTensor3DZero &other) const
#define ITK_DIFFUSION_TENSOR_3D_ZERO
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::DiffusionTensor3DZero< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass