Slicer 5.9
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
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 "itkMath.h"
19#include <itkMatrix.h>
22
23namespace itk
24{
25
44namespace Functor
45{
46
47template <class TInput, class TOutput>
49{
50public:
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
90template <class TInputImage, class TOutputImage>
92 public
93 UnaryFunctorImageFilter<TInputImage, TOutputImage,
94 Functor::DiffusionTensor3DZero<
95 typename TInputImage::PixelType::ComponentType,
96 typename TOutputImage::PixelType::ComponentType> >
97{
98public:
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
109 void operator=( const Self & ) = delete;
110
113
116
117#ifdef ITK_USE_CONCEPT_CHECKING
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
128protected:
131};
132
133} // end namespace itk
134
135#endif
void SetTensorFromMatrix(Matrix< C, 3, 3 > matrix)
DiffusionTensor3DZeroCorrectionFilter(const Self &)=delete
itkTypeMacro(DiffusionTensor3DZeroCorrectionFilter, UnaryFunctorImageFilter)
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::DiffusionTensor3DZero< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
~DiffusionTensor3DZeroCorrectionFilter() override=default
bool operator==(const DiffusionTensor3DZero &other) const
bool operator!=(const DiffusionTensor3DZero &other) const
#define ITK_DIFFUSION_TENSOR_3D_ZERO
Simplified inverse ITK transforms.