15 #include "itkNaryFunctorImageFilter.h" 16 #include "itkNumericTraits.h" 17 #include "itkDiffusionTensor3D.h" 30 template<
class TInput,
class TOutput >
36 enum { EUCLIDEAN, LOGEUCLIDEAN };
37 typedef typename NumericTraits< TInput >::RealType DtiCompType;
38 typedef typename NumericTraits< TOutput >::RealType SymTensorCompType;
43 typedef typename DTICalculatorType::SymMatType SymMatType;
47 m_MetricType = LOGEUCLIDEAN;
48 dtiCalc = DTICalculatorType::New();
52 inline TOutput operator()(
const std::vector< TInput > & B)
54 TensorType meanVal = NumericTraits< TensorType >::Zero;
64 for(
unsigned int i=0; i< B.size(); i++ )
66 if ( !dtiCalc->IsPositiveDefinite(static_cast<TensorType>(B[i])) )
75 SymMatType sum = NumericTraits< SymMatType >::Zero;
77 for(
unsigned int i=0; i< B.size(); i++ )
79 sum += dtiCalc->CalculateMatrixLog(static_cast<TensorType>(B[i]));
81 meanVal = dtiCalc->CalculateMatrixExp(sum / B.size());
86 TensorType sum = NumericTraits< TensorType >::Zero;
87 for(
unsigned int i=0; i< B.size(); i++ )
89 sum += static_cast<TensorType>(B[i]);
91 meanVal = (sum / B.size());
96 return static_cast<TOutput>( meanVal.GetInnerScalarProduct() );
108 virtual void SetMetricType (
int _arg)
110 if (this->m_MetricType !=
111 (
bool)(_arg<EUCLIDEAN ? EUCLIDEAN : (_arg>LOGEUCLIDEAN ? LOGEUCLIDEAN : _arg)))
114 (bool)(_arg<EUCLIDEAN ? EUCLIDEAN : (_arg>LOGEUCLIDEAN ? LOGEUCLIDEAN : _arg));
120 typename DTICalculatorType::Pointer dtiCalc;
151 template <
class TInputImage,
class TOutputImage>
154 NaryFunctorImageFilter<TInputImage,TOutputImage,
155 Functor::DiffusionTensorMean<typename TInputImage::PixelType,
156 typename TOutputImage::PixelType > >
161 enum { EUCLIDEAN, LOGEUCLIDEAN };
165 typedef NaryFunctorImageFilter<TInputImage,TOutputImage,
167 typename TInputImage::PixelType > > Superclass;
168 typedef SmartPointer<Self> Pointer;
169 typedef SmartPointer<const Self> ConstPointer;
176 NaryFunctorImageFilter);
179 #ifdef ITK_USE_CONCEPT_CHECKING 181 itkConceptMacro(InputConvertibleToOutputCheck,
182 (Concept::Convertible<
typename TInputImage::PixelType,
183 typename TOutputImage::PixelType>));
184 itkConceptMacro(InputHasZeroCheck,
185 (Concept::HasZero<typename TInputImage::PixelType>));
189 virtual void SetMetricType (
int _arg)
190 { this->GetFunctor().SetMetricType(_arg);}
194 virtual ~NaryMeanDiffusionTensorImageFilter() {}
197 NaryMeanDiffusionTensorImageFilter(
const Self&);
198 void operator=(
const Self&);
The Purpose of this class is to provide common computations for diffusion tensors specifically.
Definition: itkDTILogEuclideanCalculator.h:37
NaryMeanDiffusionTensorImageFilter Self
Standard class typedefs.
Definition: itkNaryMeanDiffusionTensorImageFilter.h:164
Helper class to compute the Tensor mean which interfaces with NaryMeanDiffusionTensorImageFilter.
Definition: itkNaryMeanDiffusionTensorImageFilter.h:31
DiffusionTensor3D< TDtiCompType > DTType
Typedefs for methods.
Definition: itkDTILogEuclideanCalculator.h:55
Declaration of the DTILogEuclideanCalculator class.
Implements an operator for pixel-wise averaging of two Diffusion Tensor images.
Definition: itkNaryMeanDiffusionTensorImageFilter.h:152