Slicer  5.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
itkDiffusionTensor3DAbsCorrection.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 itkDiffusionTensor3DAbsCorrection_h
15 #define itkDiffusionTensor3DAbsCorrection_h
16 
17 #include "itkUnaryFunctorImageFilter.h"
18 #include "itkMath.h"
19 #include <itkMatrix.h>
21 
22 namespace itk
23 {
24 
44 namespace Functor
45 {
46 
47 template <class TInput, class TOutput>
49 {
50 public:
51  DiffusionTensor3DAbs() = default;
52  ~DiffusionTensor3DAbs() = default;
53  bool operator!=( const DiffusionTensor3DAbs & other ) const
54  {
55  return *this != other;
56  }
57 
58  bool operator==( const DiffusionTensor3DAbs & 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 ? -eigenValues[i] : 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::DiffusionTensor3DAbs<
95  typename TInputImage::PixelType::ComponentType,
96  typename TOutputImage::PixelType::ComponentType> >
97 {
98 public:
101  typedef UnaryFunctorImageFilter<TInputImage, TOutputImage,
102  Functor::DiffusionTensor3DAbs<typename TInputImage::PixelType,
103  typename TOutputImage::PixelType> > Superclass;
104  typedef SmartPointer<Self> Pointer;
105  typedef SmartPointer<const Self> ConstPointer;
106 
108  DiffusionTensor3DAbsCorrectionFilter( const Self & ) = delete;
109  void operator=( const Self & ) = delete;
110 
112  itkTypeMacro(DiffusionTensor3DAbsCorrectionFilter, 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  ~DiffusionTensor3DAbsCorrectionFilter() override = default;
131 };
132 
133 } // end namespace itk
134 
135 #endif
void SetTensorFromMatrix(Matrix< C, 3, 3 > matrix)
Computes pixel-wise the absolute value of the diffusion tensor eigenvalues.
Simplified inverse ITK transforms.
* itkConceptMacro(OutputEqualityComparableCheck, *(Concept::EqualityComparable< OutputImagePixelType >))
itkTypeMacro(DiffusionTensor3DAbsCorrectionFilter, UnaryFunctorImageFilter)
void operator=(const Self &)=delete
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::DiffusionTensor3DAbs< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
bool operator!=(const DiffusionTensor3DAbs &other) const
~DiffusionTensor3DAbsCorrectionFilter() override=default
bool operator==(const DiffusionTensor3DAbs &other) const