16 #include "itkImageToImageFilter.h" 17 #include "itkDiffusionTensor3D.h" 18 #include "vnl/vnl_matrix.h" 19 #include "vnl/vnl_vector_fixed.h" 20 #include "vnl/vnl_matrix_fixed.h" 21 #include "vnl/algo/vnl_svd.h" 22 #include "itkVectorContainer.h" 23 #include "itkVectorImage.h" 24 #include "itkSpatialObject.h" 25 #include "itkNumericTraits.h" 28 __declspec(dllexport)
inline void getRidOfLNK4221(){};
130 template<
class TReferenceImagePixelType,
131 class TGradientImagePixelType=TReferenceImagePixelType,
132 class TTensorPixelType=
double >
134 public ImageToImageFilter< Image< TReferenceImagePixelType, 3 >,
135 Image< DiffusionTensor3D< TTensorPixelType >, 3 > >
141 typedef SmartPointer<Self> Pointer;
142 typedef SmartPointer<const Self> ConstPointer;
143 typedef ImageToImageFilter< Image< TReferenceImagePixelType, 3>,
144 Image< DiffusionTensor3D< TTensorPixelType >, 3 > >
154 typedef TReferenceImagePixelType ReferencePixelType;
156 typedef TGradientImagePixelType GradientPixelType;
158 typedef DiffusionTensor3D< TTensorPixelType > TensorPixelType;
160 typedef typename TensorPixelType::EigenValuesArrayType
161 TensorEigenValuesType;
163 typedef typename TensorPixelType::EigenVectorsMatrixType
164 TensorEigenVectorsType;
166 typedef typename TensorPixelType::MatrixType
174 typedef Image< TensorPixelType, 3 > TensorImageType;
176 typedef TensorImageType OutputImageType;
178 typedef typename Superclass::OutputImageRegionType
179 OutputImageRegionType;
192 typedef VectorImage< GradientPixelType, 3 >
194 typedef typename ResidualImageType::PixelType ResidualPixelType;
199 typedef typename ImageMaskType::Pointer ImageMaskPointer;
204 typedef vnl_matrix_fixed< double, 6, 6 > TensorBasisInverseMatrixType;
205 typedef vnl_matrix< double > CoefficientMatrixType;
211 typedef VectorContainer<
unsigned int,
230 if( m_GradientImageTypeEnumeration == GradientIsInASingleImage)
232 itkExceptionMacro( <<
"Cannot call both methods:" 233 <<
"AddGradientImage and SetGradientImage. Please call only one of them.");
236 this->ProcessObject::SetNthInput( 0, referenceImage );
238 m_GradientImageTypeEnumeration = GradientIsInManyImages;
243 {
return ( static_cast< ReferenceImageType *>(this->ProcessObject::GetInput(0)) ); }
248 if( idx >= m_NumberOfGradientDirections )
250 itkExceptionMacro( <<
"Gradient direction " << idx <<
"does not exist" );
252 return m_GradientDirectionContainer->ElementAt( idx+1 );
258 itkSetMacro( Threshold, ReferencePixelType );
259 itkGetMacro( Threshold, ReferencePixelType );
262 itkSetObjectMacro( ImageMask, ImageMaskType );
263 itkGetConstObjectMacro( ImageMask, ImageMaskType );
266 itkSetMacro( CalculateResidualImage,
bool );
267 itkGetMacro( CalculateResidualImage,
bool );
270 itkGetConstObjectMacro( ResidualImage, ResidualImageType );
278 itkSetMacro( BValue, TTensorPixelType);
282 itkGetConstReferenceMacro( BValue, TTensorPixelType);
284 #ifdef ITK_USE_CONCEPT_CHECKING 286 itkConceptMacro(ReferenceEqualityComparableCheck,
287 (Concept::EqualityComparable<ReferencePixelType>));
288 itkConceptMacro(TensorEqualityComparableCheck,
289 (Concept::EqualityComparable<TensorPixelType>));
290 itkConceptMacro(GradientConvertibleToDoubleCheck,
291 (Concept::Convertible<GradientPixelType, double>));
292 itkConceptMacro(DoubleConvertibleToTensorCheck,
293 (Concept::Convertible<double, TensorPixelType>));
294 itkConceptMacro(GradientReferenceAdditiveOperatorsCheck,
295 (Concept::AdditiveOperators<GradientPixelType, GradientPixelType,
296 ReferencePixelType>));
297 itkConceptMacro(ReferenceOStreamWritableCheck,
298 (Concept::OStreamWritable<ReferencePixelType>));
299 itkConceptMacro(TensorOStreamWritableCheck,
300 (Concept::OStreamWritable<TensorPixelType>));
307 void PrintSelf(std::ostream& os, Indent indent)
const;
309 void ComputeTensorBasis();
311 void BeforeThreadedGenerateData();
312 void ThreadedGenerateData(
const 313 OutputImageRegionType &outputRegionForThread,
int);
319 GradientIsInASingleImage = 1,
320 GradientIsInManyImages,
322 } GradientImageTypeEnumeration;
325 ResidualPixelType ComputeResidual( vnl_vector<double>, TensorPixelType,
double);
330 TensorBasisMatrixType m_TensorBasis;
333 TensorBasisInverseMatrixType m_TensorBasisInverse;
335 CoefficientMatrixType m_BMatrix;
338 GradientDirectionContainerType::Pointer m_GradientDirectionContainer;
341 unsigned int m_NumberOfGradientDirections;
344 unsigned int m_NumberOfBaselineImages;
347 ReferencePixelType m_Threshold;
350 TTensorPixelType m_BValue;
353 mutable ImageMaskPointer m_ImageMask;
356 GradientImageTypeEnumeration m_GradientImageTypeEnumeration;
358 typename ResidualImageType::Pointer m_ResidualImage;
359 bool m_CalculateResidualImage;
365 #ifndef ITK_MANUAL_INSTANTIATION 366 #include "itkDiffusionTensor3DReconstructionImageFilter.cpp" VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType
Container to hold gradient directions of the 'n' DW measurements.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:212
Image< GradientPixelType, 3 > GradientImageType
Typedef defining one (of the many) gradient images.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:182
VectorImage< GradientPixelType, 3 > GradientImagesType
An alternative typedef defining one (of the many) gradient images.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:188
vnl_vector_fixed< double, 3 > GradientDirectionType
Holds each magnetic field gradient used to acquire one DWImage.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:208
SpatialObject< 3 > ImageMaskType
Type for the mask of the fixed image.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:198
virtual GradientDirectionType GetGradientDirection(unsigned int idx) const
Return the gradient direction.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:246
This class takes as input one or more reference image (acquired in the absence of diffusion sensitizi...
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:133
void SetReferenceImage(ReferenceImageType *referenceImage)
Set method to set the reference image.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:228
vnl_matrix_fixed< double, 6, 6 > TensorBasisMatrixType
Holds the tensor basis coefficients G_k.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:203
Superclass::InputImageType ReferenceImageType
Reference image data, This image is acquired in the absence of a diffusion sensitizing field gradient...
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:172
VectorImage< GradientPixelType, 3 > ResidualImageType
Typedef defining the residual image.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:193
virtual ReferenceImageType * GetReferenceImage()
Get reference image.
Definition: itkDiffusionTensor3DReconstructionImageFilter.h:242