diff --git a/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkTensorReconstructionWithEigenvalueCorrectionFilter.h b/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkTensorReconstructionWithEigenvalueCorrectionFilter.h index 0f2317b83d..09605e0034 100644 --- a/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkTensorReconstructionWithEigenvalueCorrectionFilter.h +++ b/Modules/DiffusionImaging/DiffusionCore/Algorithms/itkTensorReconstructionWithEigenvalueCorrectionFilter.h @@ -1,257 +1,225 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_ #define _itk_TensorReconstructionWithEigenvalueCorrectionFilter_h_ #include "itkImageToImageFilter.h" #include #include #include #include #include namespace itk { template class TensorReconstructionWithEigenvalueCorrectionFilter : public ImageToImageFilter< itk::Image< TDiffusionPixelType, 3 >, itk::Image,3> > { public: typedef itk::VectorImage ImageType; typedef TensorReconstructionWithEigenvalueCorrectionFilter Self; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; typedef ImageToImageFilter< Image< TDiffusionPixelType, 3>, Image< DiffusionTensor3D< TTensorPixelType >, 3 > > Superclass; /** Method for creation through the object factory. */ itkNewMacro(Self) /** Runtime information support. */ itkTypeMacro(TensorReconstructionWithEigenvalueCorrectionFilter, ImageToImageFilter) typedef TDiffusionPixelType ReferencePixelType; typedef TDiffusionPixelType GradientPixelType; typedef DiffusionTensor3D< TTensorPixelType > TensorPixelType; - /** Reference image data, This image is aquired in the absence - * of a diffusion sensitizing field gradient */ - typedef typename Superclass::InputImageType ReferenceImageType; + typedef Image< TensorPixelType, 3 > TensorImageType; typedef TensorImageType OutputImageType; typedef typename Superclass::OutputImageRegionType OutputImageRegionType; /** Typedef defining one (of the many) gradient images. */ typedef Image< GradientPixelType, 3 > GradientImageType; /** An alternative typedef defining one (of the many) gradient images. * It will be assumed that the vectorImage has the same dimension as the * Reference image and a vector length parameter of \c n (number of * gradient directions) */ typedef VectorImage< GradientPixelType, 3 > GradientImagesType; typedef typename GradientImagesType::PixelType GradientVectorType; /* /** Holds the tensor basis coefficients G_k typedef vnl_matrix_fixed< double, 6, 6 > TensorBasisMatrixType; typedef vnl_matrix< double > CoefficientMatrixType; */ /** Holds each magnetic field gradient used to acquire one DWImage */ typedef vnl_vector_fixed< double, 3 > GradientDirectionType; /** Container to hold gradient directions of the 'n' DW measurements */ typedef VectorContainer< unsigned int, GradientDirectionType > GradientDirectionContainerType; /** Another set method to add a gradient directions and its corresponding * image. The image here is a VectorImage. The user is expected to pass the * gradient directions in a container. The ith element of the container * corresponds to the gradient direction of the ith component image the * VectorImage. For the baseline image, a vector of all zeros * should be set. */ void SetGradientImage( GradientDirectionContainerType *, const GradientImagesType *image); - /** Set method to set the reference image. */ - void SetReferenceImage( ReferenceImageType *referenceImage ) - { - if( m_GradientImageTypeEnumeration == GradientIsInASingleImage) - { - itkExceptionMacro( << "Cannot call both methods:" - << "AddGradientImage and SetGradientImage. Please call only one of them."); - } - - this->ProcessObject::SetNthInput( 0, referenceImage ); - - m_GradientImageTypeEnumeration = GradientIsInManyImages; - } - - /** Get reference image */ - virtual ReferenceImageType * GetReferenceImage() - { return ( static_cast< ReferenceImageType *>(this->ProcessObject::GetInput(0)) ); } - /** Return the gradient direction. idx is 0 based */ - virtual GradientDirectionType GetGradientDirection( unsigned int idx) const - { - if( idx >= m_NumberOfGradientDirections ) - { - itkExceptionMacro( << "Gradient direction " << idx << "does not exist" ); - } - return m_GradientDirectionContainer->ElementAt( idx+1 ); - } itkSetMacro( BValue, TTensorPixelType); itkSetMacro( B0Threshold, float); itkSetMacro (Flagstatus, int); itkGetMacro(PseudoInverse, vnl_matrix); itkGetMacro(H, vnl_matrix); itkGetMacro(BVec, vnl_vector); itkGetMacro(B0Mask, vnl_vector); itkGetMacro(Voxdim, vnl_vector); mitk::DiffusionImage::Pointer GetOutputDiffusionImage() { return m_OutputDiffusionImage; } ImageType::Pointer GetVectorImage() { return m_VectorImage; } itk::Image::Pointer GetMask() { return m_MaskImage; } - //itkGetMacro(OutputDiffusionImage, mitk::DiffusionImage) - - //itkGetMacro( GradientDirectionContainer, GradientDirectionContainerType::Pointer); - protected: TensorReconstructionWithEigenvalueCorrectionFilter(); ~TensorReconstructionWithEigenvalueCorrectionFilter() {}; void GenerateData(); typedef enum { GradientIsInASingleImage = 1, GradientIsInManyImages, Else } GradientImageTypeEnumeration; private: double CheckNeighbours(int x, int y, int z,int f, itk::Size<3> size, itk::Image ::Pointer mask,itk::VectorImage::Pointer corrected_diffusion_temp); void CalculateAttenuation(vnl_vector org_data, vnl_vector &atten,int nof,int numberb0); void CalculateTensor(vnl_vector atten, vnl_vector &tensor,int nof,int numberb0); void CorrectDiffusionImage(int nof,int numberb0,itk::Size<3> size,itk::VectorImage::Pointer corrected_diffusion_temp,itk::VectorImage::Pointer corrected_diffusion,itk::Image::Pointer mask,vnl_vector< double> pixel_max,vnl_vector< double> pixel_min); void GenerateTensorImage(int nof,int numberb0,itk::Size<3> size,itk::VectorImage::Pointer corrected_diffusion,itk::Image::Pointer mask,double what_mask,itk::Image< itk::DiffusionTensor3D, 3 >::Pointer tensorImg ); void DeepCopyTensorImage(itk::Image< itk::DiffusionTensor3D, 3 >::Pointer tensorImg, itk::Image< itk::DiffusionTensor3D, 3 >::Pointer temp_tensorImg); void DeepCopyDiffusionImage(itk::VectorImage::Pointer corrected_diffusion, itk::VectorImage::Pointer corrected_diffusion_temp,int nof); void TurnMask( itk::Size<3> size, itk::Image::Pointer mask, double previous_mask, double set_mask); double CheckNegatives ( itk::Size<3> size, itk::Image::Pointer mask, itk::Image< itk::DiffusionTensor3D, 3 >::Pointer tensorImg ); /** Gradient image was specified in a single image or in multiple images */ GradientImageTypeEnumeration m_GradientImageTypeEnumeration; /** Number of gradient measurements */ unsigned int m_NumberOfGradientDirections; /** container to hold gradient directions */ GradientDirectionContainerType::Pointer m_GradientDirectionContainer; /** b-value */ TTensorPixelType m_BValue; /** Number of baseline images */ unsigned int m_NumberOfBaselineImages; mitk::DiffusionImage::Pointer m_OutputDiffusionImage; ImageType::Pointer m_VectorImage; float m_B0Threshold; itk::Image::Pointer m_MaskImage; vnl_matrix m_PseudoInverse; vnl_matrix m_H; vnl_vector m_BVec; vnl_vector m_B0Mask; vnl_vector m_Voxdim; int m_Flagstatus; typename GradientImagesType::Pointer m_GradientImagePointer; }; } // end of namespace #ifndef ITK_MANUAL_INSTANTIATION #include "itkTensorReconstructionWithEigenvalueCorrectionFilter.txx" #endif #endif