diff --git a/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkDiffusionImageToDiffusionImageFilter.cpp b/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkDiffusionImageToDiffusionImageFilter.cpp deleted file mode 100644 index 69623e4da8..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkDiffusionImageToDiffusionImageFilter.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/*=================================================================== - -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 _mitk_DiffusionImageToDiffusionImageFilter_cpp -#define _mitk_DiffusionImageToDiffusionImageFilter_cpp - -#include "mitkDiffusionImageToDiffusionImageFilter.h" - -template -mitk::DiffusionImageToDiffusionImageFilter -::DiffusionImageToDiffusionImageFilter() -{ - this->SetNumberOfRequiredInputs(1); - this->SetNumberOfRequiredOutputs(1); -} - -template -void mitk::DiffusionImageToDiffusionImageFilter -::SetInput(const InputImageType *input) -{ - // call to the more general method - this->SetInput(0, input); -} - -template -void mitk::DiffusionImageToDiffusionImageFilter -::SetInput(unsigned int index, const InputImageType *input) -{ - if( index+1 > this->GetNumberOfInputs() ) - { - this->SetNumberOfRequiredInputs( index + 1 ); - } - // Process object is not const-correct so the const_cast is required here - this->itk::ProcessObject::SetNthInput(index, - const_cast< typename Self::InputImageType *>( input ) ); -} - - -template -const typename mitk::DiffusionImageToDiffusionImageFilter::InputImageType* -mitk::DiffusionImageToDiffusionImageFilter -::GetInput() -{ - // call to the more general method - return this->GetInput(0); -} - -template -const typename mitk::DiffusionImageToDiffusionImageFilter::InputImageType* -mitk::DiffusionImageToDiffusionImageFilter -::GetInput(unsigned int idx) -{ - return static_cast< const typename Self::InputImageType * > - (this->itk::ProcessObject::GetInput(idx)); -} - - - - -#endif diff --git a/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkDiffusionImageToDiffusionImageFilter.h b/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkDiffusionImageToDiffusionImageFilter.h deleted file mode 100644 index 8108b9888d..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/Algorithms/mitkDiffusionImageToDiffusionImageFilter.h +++ /dev/null @@ -1,73 +0,0 @@ -/*=================================================================== - -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 MITKDIFFUSIONIMAGETODIFFUSIONIMAGEFILTER_H -#define MITKDIFFUSIONIMAGETODIFFUSIONIMAGEFILTER_H - -#include "mitkDiffusionImageSource.h" -#include "mitkDiffusionImage.h" - - -namespace mitk { -/** - * @class DiffusionImageToDiffusionImageFilter - * @brief Base class for all DiffusionImage filters - * - * The class inherits the mitk::ImageToImageFilter to gain access to the filtering pipline. - */ -template -class DiffusionImageToDiffusionImageFilter - : public DiffusionImageSource< DiffusionPixelType > -{ -public: - /** typedefs for compatibility */ - typedef mitk::DiffusionImage< DiffusionPixelType > InputImageType; - typedef typename InputImageType::Pointer InputImagePointerType; - - mitkClassMacro( DiffusionImageToDiffusionImageFilter, - DiffusionImageSource ) - - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef typename Superclass::OutputType OutputImageType; - typedef typename OutputImageType::Pointer OutputImagePointerType; - - using itk::ProcessObject::SetInput; - virtual void SetInput( const InputImageType* image); - virtual void SetInput( unsigned int, const InputImageType* image); - - const InputImageType* GetInput(void); - const InputImageType* GetInput(unsigned int); - - -protected: - DiffusionImageToDiffusionImageFilter(); - virtual ~DiffusionImageToDiffusionImageFilter() {} - - virtual void PrintSelf(std::ostream &os, itk::Indent indent) const {} - virtual void GenerateInputRequestedRegion() {} - -private: - // purposely not implemented - void operator=(const Self&); -}; - -} // end namespace mitk - -#include "mitkDiffusionImageToDiffusionImageFilter.cpp" - -#endif // MITKDIFFUSIONIMAGETODIFFUSIONIMAGEFILTER_H diff --git a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.h b/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.h deleted file mode 100644 index b5d61d4946..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.h +++ /dev/null @@ -1,218 +0,0 @@ -/*=================================================================== - -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 __mitkDiffusionImage__h -#define __mitkDiffusionImage__h - -#include "mitkImage.h" -#include "itkVectorImage.h" -#include "itkVectorImageToImageAdaptor.h" -#include -#include "MitkDiffusionCoreExports.h" - -namespace mitk -{ - -/** - * \brief this class encapsulates diffusion volumes (vectorimages not - * yet supported by mitkImage) - */ -template< class TPixelType > -class MITK_EXPORT DiffusionImage : public Image -{ - -public: - typedef typename itk::VectorImage ImageType; - typedef vnl_vector_fixed< double, 3 > GradientDirectionType; - typedef itk::VectorContainer< unsigned int,GradientDirectionType > GradientDirectionContainerType; - typedef GradientDirectionContainerType::Pointer GradientDirectionContainerTypePointer; - typedef vnl_matrix_fixed< double, 3, 3 > MeasurementFrameType; - typedef std::vector< unsigned int > IndicesVector; - typedef itk::VectorImage< TPixelType, 3 > ItkDwiType; - typedef itk::ImageDuplicator< ItkDwiType > DwiDuplicatorType; - - /** - * \brief The BValueMap contains seperated IndicesVectors for each b value (index for GradientDirectionContainer) - * key := b value - * value := indicesVector - */ - typedef std::map< unsigned int , IndicesVector > BValueMap; - - mitkClassMacro( DiffusionImage, Image ) - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - mitkCloneMacro(Self) - - /** - * \brief Return the itkVectorImage as pointer - */ - typename ImageType::Pointer GetVectorImage(); - - /** - * \brief Return the itkVectorImage as const pointer - */ - const typename ImageType::Pointer GetVectorImage() const; - - /** - * \brief Set the itkVectorImage - * - * \param SmartPointer ofitk::VectorImage - */ - void SetVectorImage(typename ImageType::Pointer image ); - - /** - * \brief Initialize the mitkImage (base-class) using the first b-zero value of the itkVectorImage - * - * \warning First set itkVectorImage, GradientDirectionContainer and the b value of the image. - * Has to be called. - */ - void InitializeFromVectorImage(); - - /** - * \brief Return the directions as GradientDirectionContainer const pointer - * - * \warning MeasurementFrame already applied - */ - GradientDirectionContainerType::Pointer GetDirections() const; - - /** - * \brief Return the directions as GradientDirectionContainer const pointer - * - * \warning no MeasurmentFrame applied - */ - GradientDirectionContainerType::Pointer GetDirectionsWithoutMeasurementFrame() const; - - /** - * \brief Set the original and current GradientDirectionContainer - * \param GradientdirectionContainer as pointer - * \warning Replace the original (m_OriginalDirections) and current (m_Directions) GradientDirectionContainer. - * For the current directions the MeasurmentFrame is applied. Remove existing GradientDirectionContainer observer - * of m_Directions and add a new observer to it (observer update the m_B_ValueMap if modifications occours on the container) - */ - void SetDirections( GradientDirectionContainerType::Pointer directions ); - - /** - * \brief Set the original and current GradientDirectionContainer - * \param std::vector > - * \warning Replace the original (m_OriginalDirections) and current (m_Directions) GradientDirectionContainer. - * For the current directions the MeasurmentFrame is applied. - * Remove existing GradientDirectionContainer observer of m_Directions and add a new observer to it - * (observer update the m_B_ValueMap if modifications occours on the container). - * Calls the overloaded GradientDirectionContainer pointer version of the method. - */ - void SetDirections( const std::vector > & directions ); - - /** - * \brief Return a copy of the MeasurmentFrame (m_MeasurementFrame) - */ - MeasurementFrameType GetMeasurementFrame() const; - - /** - * \brief Set the MeasurementFrame - * - * \param Const reference of MeasurementFrameType - */ - void SetMeasurementFrame( const MeasurementFrameType & mFrame ); - - /** - * \brief Return true if gradients of with diffrent b-values exist - */ - bool GetNumberOfBValues() const; - - /** - * \brief Return a BValueMap (key: b value, Value: IndicesVector of the GradientDirectionContainer) - */ - const BValueMap & GetBValueMap() const; - - /** - * \brief Return the reference b value - * GradientsLength * referenceBValue encoding the true b value of the corresponding GradientDirection - */ - float GetReferenceBValue() const; - - /** - * \brief Set the reference b value s - */ - void SetReferenceBValue( float val ); - - GradientDirectionContainerType::Pointer CalcAveragedDirectionSet(double precision, GradientDirectionContainerType::Pointer directions); - void AverageRedundantGradients(double precision); - void SetDisplayIndexForRendering(int displayIndex); - -protected: - DiffusionImage(); - DiffusionImage(const DiffusionImage &); - virtual ~DiffusionImage(); - - // Helper Methods - bool AreAlike(GradientDirectionType g1, GradientDirectionType g2, double precision); - float GetB_Value(unsigned int i); - - /** - * \brief Apply the previouse set MeasurmentFrame to all gradients in the GradientsDirectionContainer (m_Directions) - * - * \warning first set the MeasurmentFrame - */ - void ApplyMeasurementFrame(); - - /** - * \brief Update the BValueMap (m_B_ValueMap) using the current gradient directions (m_Directions) - * - * \warning Have to be called after each manipulation on the GradientDirectionContainer - * !especially after manipulation of the m_Directions (GetDirections()) container via pointer access! - */ - void UpdateBValueMap(); - - typename ImageType::Pointer m_VectorImage; - float m_B_Value; - MeasurementFrameType m_MeasurementFrame; - GradientDirectionContainerType::Pointer m_OriginalDirections; - GradientDirectionContainerType::Pointer m_Directions; - int m_DisplayIndex; - BValueMap m_B_ValueMap; - -}; - -/** -* @brief Equal A function comparing two images for beeing equal in meta- and imagedata -* -* @ingroup MITKTestingAPI -* -* Following aspects are tested for equality: -* - mitk image equal test -* - GradientDirectionContainer -* - MeasurementFrame -* - reference BValue -* - BValueMap -* - itkVectorImage -* -* @param rightHandSide An image to be compared -* @param leftHandSide An image to be compared -* @param eps Tolarence for comparison. You can use mitk::eps in most cases. -* @param verbose Flag indicating if the user wants detailed console output or not. -* @return true, if all subsequent comparisons are true, false otherwise -*/ - -template -inline bool Equal(const mitk::DiffusionImage &leftHandSide, const mitk::DiffusionImage &rightHandSide, ScalarType eps, bool verbose ); - - -} // namespace mitk - -#include "mitkDiffusionImage.txx" - -#endif /* __mitkDiffusionImage__h */ diff --git a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.txx b/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.txx deleted file mode 100644 index 75baf432c6..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImage.txx +++ /dev/null @@ -1,631 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIterator.h" -#include "mitkImageCast.h" - -#include "mitkDiffusionImage.h" - -#include "itkImageDuplicator.h" -#include "itkTestingComparisonImageFilter.h" - - -template -mitk::DiffusionImage::DiffusionImage() - : m_VectorImage(0), m_B_Value(-1.0), m_OriginalDirections(0), m_Directions(0) -{ - MeasurementFrameType mf; - for(int i=0; i<3; i++) - for(int j=0; j<3; j++) - mf[i][j] = 0; - for(int i=0; i<3; i++) - mf[i][i] = 1; - m_MeasurementFrame = mf; -} - -template -mitk::DiffusionImage::DiffusionImage(const DiffusionImage & orig) - : mitk::Image(orig), - m_VectorImage( 0 ), - m_B_Value(0), - m_OriginalDirections(0), - m_Directions(0) -{ - // Deep copy VectorImage - typename itk::ImageDuplicator::Pointer duplicator = itk::ImageDuplicator::New(); - duplicator->SetInputImage( orig.m_VectorImage ); - duplicator->Update(); - - GradientDirectionContainerType::ConstIterator origIt; - GradientDirectionContainerType::ConstIterator origItEnd; - - // Deep Copy OrignalDirectioncontainer - GradientDirectionContainerType::Pointer OriginalDirectionscontainer = GradientDirectionContainerType::New(); - origIt = orig.GetDirectionsWithoutMeasurementFrame()->Begin(); - origItEnd = orig.GetDirectionsWithoutMeasurementFrame()->End(); - - for(;origIt != origItEnd; ++origIt) - OriginalDirectionscontainer->push_back(origIt.Value()); - - // Deep Copy Directioncontainer - GradientDirectionContainerType::Pointer DirectionsContainer = GradientDirectionContainerType::New(); - origIt = orig.GetDirections()->Begin(); - origItEnd = orig.GetDirections()->End(); - - for(;origIt != origItEnd; ++origIt) - DirectionsContainer->push_back(origIt.Value()); - - // Set member of the new clone - m_VectorImage = duplicator->GetOutput(); - m_B_Value = orig.GetReferenceBValue(); - m_OriginalDirections = OriginalDirectionscontainer; - m_Directions = DirectionsContainer; - m_MeasurementFrame = orig.GetMeasurementFrame(); - ApplyMeasurementFrame(); - UpdateBValueMap(); - InitializeFromVectorImage(); - - // m_VectorImage = duplicator->GetOutput(); - // m_B_Value = orig.GetB_Value(); - // m_MeasurementFrame = orig.GetMeasurementFrame(); - // m_Directions = copyInContainer; - // m_OriginalDirections = copyInContainer; - - -} - - -template -mitk::DiffusionImage::~DiffusionImage() -{ - // Remove Observer for m_Directions - //RemoveObserver(); -} - -template -void mitk::DiffusionImage -::InitializeFromVectorImage() -{ - if(!m_VectorImage || !m_Directions || m_B_Value==-1.0) - { - MITK_INFO << "DiffusionImage could not be initialized. Set all members first!" << std::endl; - // Fehjlermedlung updaten - return; - } - - // find bzero index - int firstZeroIndex = -1; - for(GradientDirectionContainerType::ConstIterator it = m_Directions->Begin(); - it != m_Directions->End(); ++it) - { - firstZeroIndex++; - GradientDirectionType g = it.Value(); - if(g[0] == 0 && g[1] == 0 && g[2] == 0 ) - break; - } - - typedef itk::Image ImgType; - typename ImgType::Pointer img = ImgType::New(); - img->SetSpacing( m_VectorImage->GetSpacing() ); // Set the image spacing - img->SetOrigin( m_VectorImage->GetOrigin() ); // Set the image origin - img->SetDirection( m_VectorImage->GetDirection() ); // Set the image direction - img->SetLargestPossibleRegion( m_VectorImage->GetLargestPossibleRegion()); - img->SetBufferedRegion( m_VectorImage->GetLargestPossibleRegion() ); - img->Allocate(); - - int vecLength = m_VectorImage->GetVectorLength(); - InitializeByItk( img.GetPointer(), 1, vecLength ); - - itk::ImageRegionIterator itw (img, img->GetLargestPossibleRegion() ); - itw.GoToBegin(); - - itk::ImageRegionConstIterator itr (m_VectorImage, m_VectorImage->GetLargestPossibleRegion() ); - itr.GoToBegin(); - - while(!itr.IsAtEnd()) - { - itw.Set(itr.Get().GetElement(firstZeroIndex)); - ++itr; - ++itw; - } - - // init - SetImportVolume(img->GetBufferPointer()); - - m_DisplayIndex = firstZeroIndex; - MITK_INFO << "Diffusion-Image successfully initialized."; -} - -template -void mitk::DiffusionImage -::SetDisplayIndexForRendering(int displayIndex) -{ - int index = displayIndex; - int vecLength = m_VectorImage->GetVectorLength(); - index = index > vecLength-1 ? vecLength-1 : index; - if( m_DisplayIndex != index ) - { - typedef itk::Image ImgType; - typename ImgType::Pointer img = ImgType::New(); - CastToItkImage(this, img); - - itk::ImageRegionIterator itw (img, img->GetLargestPossibleRegion() ); - itw.GoToBegin(); - - itk::ImageRegionConstIterator itr (m_VectorImage, m_VectorImage->GetLargestPossibleRegion() ); - itr.GoToBegin(); - - while(!itr.IsAtEnd()) - { - itw.Set(itr.Get().GetElement(index)); - ++itr; - ++itw; - } - } - - m_DisplayIndex = index; -} - -template -bool mitk::DiffusionImage::AreAlike(GradientDirectionType g1, - GradientDirectionType g2, - double precision) -{ - GradientDirectionType diff = g1 - g2; - GradientDirectionType diff2 = g1 + g2; - return diff.two_norm() < precision || diff2.two_norm() < precision; -} - - -template -mitk::DiffusionImage::GradientDirectionContainerType::Pointer -mitk::DiffusionImage::CalcAveragedDirectionSet(double precision, GradientDirectionContainerType::Pointer directions) -{ - // save old and construct new direction container - GradientDirectionContainerType::Pointer newDirections = GradientDirectionContainerType::New(); - - // fill new direction container - for(GradientDirectionContainerType::ConstIterator gdcitOld = directions->Begin(); - gdcitOld != directions->End(); ++gdcitOld) - { - // already exists? - bool found = false; - for(GradientDirectionContainerType::ConstIterator gdcitNew = newDirections->Begin(); - gdcitNew != newDirections->End(); ++gdcitNew) - { - if(AreAlike(gdcitNew.Value(), gdcitOld.Value(), precision)) - { - found = true; - break; - } - } - - // if not found, add it to new container - if(!found) - { - newDirections->push_back(gdcitOld.Value()); - } - } - - return newDirections; -} - -template -void mitk::DiffusionImage::AverageRedundantGradients(double precision) -{ - - GradientDirectionContainerType::Pointer newDirs = - CalcAveragedDirectionSet(precision, m_Directions); - - GradientDirectionContainerType::Pointer newOriginalDirs = - CalcAveragedDirectionSet(precision, m_OriginalDirections); - - // if sizes equal, we do not need to do anything in this function - if(m_Directions->size() == newDirs->size() || m_OriginalDirections->size() == newOriginalDirs->size()) - return; - - GradientDirectionContainerType::Pointer oldDirections = m_OriginalDirections; - m_Directions = newDirs; - m_OriginalDirections = newOriginalDirs; - - // new image - typename ImageType::Pointer oldImage = m_VectorImage; - m_VectorImage = ImageType::New(); - m_VectorImage->SetSpacing( oldImage->GetSpacing() ); // Set the image spacing - m_VectorImage->SetOrigin( oldImage->GetOrigin() ); // Set the image origin - m_VectorImage->SetDirection( oldImage->GetDirection() ); // Set the image direction - m_VectorImage->SetLargestPossibleRegion( oldImage->GetLargestPossibleRegion() ); - m_VectorImage->SetVectorLength( m_Directions->size() ); - m_VectorImage->SetBufferedRegion( oldImage->GetLargestPossibleRegion() ); - m_VectorImage->Allocate(); - - // average image data that corresponds to identical directions - itk::ImageRegionIterator< ImageType > newIt(m_VectorImage, m_VectorImage->GetLargestPossibleRegion()); - newIt.GoToBegin(); - itk::ImageRegionIterator< ImageType > oldIt(oldImage, oldImage->GetLargestPossibleRegion()); - oldIt.GoToBegin(); - - // initial new value of voxel - typename ImageType::PixelType newVec; - newVec.SetSize(m_Directions->size()); - newVec.AllocateElements(m_Directions->size()); - - std::vector > dirIndices; - for(GradientDirectionContainerType::ConstIterator gdcitNew = m_Directions->Begin(); - gdcitNew != m_Directions->End(); ++gdcitNew) - { - dirIndices.push_back(std::vector(0)); - for(GradientDirectionContainerType::ConstIterator gdcitOld = oldDirections->Begin(); - gdcitOld != oldDirections->End(); ++gdcitOld) - { - if(AreAlike(gdcitNew.Value(), gdcitOld.Value(), precision)) - { - //MITK_INFO << gdcitNew.Value() << " " << gdcitOld.Value(); - dirIndices[gdcitNew.Index()].push_back(gdcitOld.Index()); - } - } - } - - //int ind1 = -1; - while(!newIt.IsAtEnd()) - { - - // progress - //typename ImageType::IndexType ind = newIt.GetIndex(); - //ind1 = ind.m_Index[2]; - - // init new vector with zeros - newVec.Fill(0.0); - - // the old voxel value with duplicates - typename ImageType::PixelType oldVec = oldIt.Get(); - - for(unsigned int i=0; i -void mitk::DiffusionImage::ApplyMeasurementFrame() -{ - if(m_OriginalDirections.IsNull()) - { - // original direction container was not set - return; - } - - m_Directions = GradientDirectionContainerType::New(); - int c = 0; - for(GradientDirectionContainerType::ConstIterator gdcit = m_OriginalDirections->Begin(); - gdcit != m_OriginalDirections->End(); ++gdcit) - { - vnl_vector vec = gdcit.Value(); - vec = vec.pre_multiply(m_MeasurementFrame); - m_Directions->InsertElement(c, vec); - c++; - } -} - -template -void mitk::DiffusionImage::UpdateBValueMap() -{ - if(!m_B_ValueMap.empty()) - m_B_ValueMap.clear(); - - GradientDirectionContainerType::ConstIterator gdcit; - for( gdcit = this->m_Directions->Begin(); gdcit != this->m_Directions->End(); ++gdcit) - m_B_ValueMap[this->GetB_Value(gdcit.Index())].push_back(gdcit.Index()); -} - -template -float mitk::DiffusionImage::GetB_Value(unsigned int i) -{ - if(i > m_Directions->Size()-1) - return -1; - - if(m_Directions->ElementAt(i).one_norm() <= 0.0) - { - return 0; - } - else - { - double twonorm = m_Directions->ElementAt(i).two_norm(); - double bval = m_B_Value*twonorm*twonorm; - - if (bval<0) - bval = ceil(bval - 0.5); - else - bval = floor(bval + 0.5); - - return bval; - } -} - -template -void mitk::DiffusionImage::SetDirections( GradientDirectionContainerType::Pointer directions ) -{ - this->m_OriginalDirections = directions; - ApplyMeasurementFrame(); - UpdateBValueMap(); -} - -template -void mitk::DiffusionImage::SetDirections(const std::vector > &directions) -{ - GradientDirectionContainerType::Pointer tempContainer = GradientDirectionContainerType::New(); - for(unsigned int i=0; iInsertElement( i, directions[i].GetVnlVector() ); - SetDirections(tempContainer); -} - -template -typename mitk::DiffusionImage::MeasurementFrameType mitk::DiffusionImage::GetMeasurementFrame() const -{ - return m_MeasurementFrame; -} - -template -void mitk::DiffusionImage::SetMeasurementFrame( const MeasurementFrameType & mFrame ) -{ - m_MeasurementFrame = mFrame; - ApplyMeasurementFrame(); -} - -template -bool mitk::DiffusionImage::GetNumberOfBValues() const -{ - return m_B_ValueMap.size(); -} - -template -const typename mitk::DiffusionImage::BValueMap & mitk::DiffusionImage::GetBValueMap() const -{ - return m_B_ValueMap; -} - -template -float mitk::DiffusionImage::GetReferenceBValue() const -{ - return m_B_Value; -} - -template -void mitk::DiffusionImage::SetReferenceBValue( float val ) -{ - m_B_Value = val; -} - -template -typename mitk::DiffusionImage::GradientDirectionContainerTypePointer mitk::DiffusionImage::GetDirections() const -{ - return m_Directions; -} - -template -typename mitk::DiffusionImage::GradientDirectionContainerTypePointer mitk::DiffusionImage::GetDirectionsWithoutMeasurementFrame() const -{ - return m_OriginalDirections; -} - -template -typename itk::VectorImage::Pointer mitk::DiffusionImage::GetVectorImage() -{ - return m_VectorImage; -} - -template -const typename itk::VectorImage::Pointer mitk::DiffusionImage::GetVectorImage() const -{ - return m_VectorImage; -} - -template -void mitk::DiffusionImage::SetVectorImage(typename ImageType::Pointer image ) -{ - m_VectorImage = image; -} - -template -inline bool mitk::Equal(const mitk::DiffusionImage& leftHandSide, const mitk::DiffusionImage &rightHandSide, ScalarType eps, bool verbose ) -{ - - bool returnValue = true; - - if(leftHandSide.GetReferenceBValue() != rightHandSide.GetReferenceBValue()) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] Reference BValue is not Equal."; - returnValue = false; - } - - if(leftHandSide.GetMeasurementFrame() != rightHandSide.GetMeasurementFrame()) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] MeasurementFrame is not Equal."; - returnValue = false; - } - - if(leftHandSide.GetBValueMap().size() != rightHandSide.GetBValueMap().size()) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] BValue Map: Size is not Equal."; - returnValue = false; - } - - if(leftHandSide.GetNumberOfBValues() != rightHandSide.GetNumberOfBValues()) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] BValue Map (GetNumberOfBValues): Size is not Equal."; - returnValue = false; - } - - // Slow testing area - - const mitk::Image* img1 = dynamic_cast(&leftHandSide); - const mitk::Image* img2 = dynamic_cast(&rightHandSide); - - if(mitk::Equal(*img1,*img2,eps,verbose) == false) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] Base-Class (mitk::Image) is not Equal."; - returnValue = false; - } - - { - typename mitk::DiffusionImage::GradientDirectionContainerType::Iterator lhsIt = leftHandSide.GetDirectionsWithoutMeasurementFrame()->Begin(); - typename mitk::DiffusionImage::GradientDirectionContainerType::Iterator lhsItEnd = leftHandSide.GetDirectionsWithoutMeasurementFrame()->End(); - typename mitk::DiffusionImage::GradientDirectionContainerType::Iterator rhsIt = rightHandSide.GetDirectionsWithoutMeasurementFrame()->Begin(); - - for(;lhsIt != lhsItEnd;) - { - bool vectorNotEqual = false; - for(unsigned int i = 0 ; i < lhsIt.Value().size(); i++) - vectorNotEqual |= !mitk::Equal(lhsIt.Value().get(i),rhsIt.Value().get(i),0.0001); - - if(vectorNotEqual) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] Original GradientDirections are not Equal."; - returnValue = false; - break; - } - ++rhsIt; - ++lhsIt; - } - } - - { - typename mitk::DiffusionImage::GradientDirectionContainerType::Iterator lhsIt = leftHandSide.GetDirections()->Begin(); - typename mitk::DiffusionImage::GradientDirectionContainerType::Iterator lhsItEnd = leftHandSide.GetDirections()->End(); - typename mitk::DiffusionImage::GradientDirectionContainerType::Iterator rhsIt = rightHandSide.GetDirections()->Begin(); - - for(;lhsIt != lhsItEnd;) - { - bool vectorNotEqual = false; - for(unsigned int i = 0 ; i < lhsIt.Value().size(); i++) - vectorNotEqual |= !mitk::Equal(lhsIt.Value().get(i),rhsIt.Value().get(i),0.0001); - - if(vectorNotEqual) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] GradientDirections are not Equal."; - returnValue = false; - break; - } - ++rhsIt; - ++lhsIt; - } - } - - { - - typename mitk::DiffusionImage::BValueMap rhsMap = rightHandSide.GetBValueMap(); - typename mitk::DiffusionImage::BValueMap lhsMap = leftHandSide.GetBValueMap(); - typename mitk::DiffusionImage::BValueMap::const_iterator lhsIt = lhsMap.begin(); - typename mitk::DiffusionImage::BValueMap::const_iterator lhsItEnd = lhsMap.end(); - typename mitk::DiffusionImage::BValueMap::const_iterator rhsIt = rhsMap.begin(); - - for(;lhsIt != lhsItEnd;) - { - if(lhsIt->first != rhsIt->first) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] BValue Map: lhsKey " << lhsIt->first << " != rhsKey " << rhsIt->first << " is not Equal."; - returnValue = false; - break; - } - - if(lhsIt->second.size() != rhsIt->second.size()) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] BValue Map: Indices vector size is not Equal. (Key: " << lhsIt->first <<")"; - returnValue = false; - break; - } - - - typename mitk::DiffusionImage::IndicesVector::const_iterator lhsIndVecIt = lhsIt->second.begin(); - typename mitk::DiffusionImage::IndicesVector::const_iterator lhsIndVecItEnd = lhsIt->second.end(); - typename mitk::DiffusionImage::IndicesVector::const_iterator rhsIndVecIt = rhsIt->second.begin(); - - for(;lhsIndVecIt != lhsIndVecItEnd;) - { - if(*lhsIndVecIt != *rhsIndVecIt) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] BValue Map: Indices are not Equal. (Key: " << lhsIt->first <<")"; - returnValue = false; - break; - } - ++rhsIndVecIt; - ++lhsIndVecIt; - } - - lhsIt++; - rhsIt++; - } - } - - - try{ - itk::ImageRegionIterator< itk::VectorImage< TPixelType, 3 > > it1(leftHandSide.GetVectorImage(), leftHandSide.GetVectorImage()->GetLargestPossibleRegion()); - itk::ImageRegionIterator< itk::VectorImage< TPixelType, 3 > > it2(rightHandSide.GetVectorImage(), rightHandSide.GetVectorImage()->GetLargestPossibleRegion()); - while(!it1.IsAtEnd()) - { - if (it1.Get()!=it2.Get()){ - if(verbose) - MITK_INFO << "[( DiffusionImage )] Capsulated itk::VectorImage is not Equal."; - returnValue = false; - break; - } - ++it1; - ++it2; - } - } - catch(...) - { - if(verbose) - MITK_INFO << "[( DiffusionImage )] Comparision of itk Vector image abort by exception."; - returnValue = false; - } - - return returnValue; -} - diff --git a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.cpp b/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.cpp deleted file mode 100644 index ce24a5b93e..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/*=================================================================== - -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 __MITK_DIFFUSIONIMAGE_SOURCE_CPP__ -#define __MITK_DIFFUSIONIMAGE_SOURCE_CPP__ - -#include "mitkDiffusionImageSource.h" -#include "mitkDiffusionImage.h" - -template -mitk::DiffusionImageSource::DiffusionImageSource() -{ - // Create the output. We use static_cast<> here because we know the default - // output must be of type DiffusionImage - typename mitk::DiffusionImage::Pointer output - = static_cast*>(this->MakeOutput(0).GetPointer()); - - Superclass::SetNumberOfRequiredOutputs(1); - Superclass::SetNthOutput(0, output.GetPointer()); -} - -template -mitk::DiffusionImageSource::~DiffusionImageSource() -{ -} - -template -itk::DataObject::Pointer mitk::DiffusionImageSource::MakeOutput ( DataObjectPointerArraySizeType /*idx*/ ) -{ - return OutputType::New().GetPointer(); -} - - -template -itk::DataObject::Pointer mitk::DiffusionImageSource::MakeOutput( const DataObjectIdentifierType & name ) -{ - itkDebugMacro("MakeOutput(" << name << ")"); - if( this->IsIndexedOutputName(name) ) - { - return this->MakeOutput( this->MakeIndexFromOutputName(name) ); - } - return static_cast(OutputType::New().GetPointer()); -} - -template -typename mitk::DiffusionImageSource::OutputType* -mitk::DiffusionImageSource::GetOutput(void) -{ - return itkDynamicCastInDebugMode( this->GetPrimaryOutput() ); -} - -template -const typename mitk::DiffusionImageSource::OutputType* -mitk::DiffusionImageSource::GetOutput(void) const -{ - return itkDynamicCastInDebugMode( this->GetPrimaryOutput() ); -} - -template -typename mitk::DiffusionImageSource::OutputType* -mitk::DiffusionImageSource::GetOutput(DataObjectPointerArraySizeType idx) -{ - OutputType* out = dynamic_cast( this->ProcessObject::GetOutput(idx) ); - if ( out == NULL && this->ProcessObject::GetOutput(idx) != NULL ) - { - itkWarningMacro (<< "Unable to convert output number " << idx << " to type " << typeid( OutputType ).name () ); - } - return out; -} - -template -const typename mitk::DiffusionImageSource::OutputType* -mitk::DiffusionImageSource::GetOutput(DataObjectPointerArraySizeType idx) const -{ - const OutputType* out = dynamic_cast( this->ProcessObject::GetOutput(idx) ); - if ( out == NULL && this->ProcessObject::GetOutput(idx) != NULL ) - { - itkWarningMacro (<< "Unable to convert output number " << idx << " to type " << typeid( OutputType ).name () ); - } - return out; -} - -#endif //__MITK_DIFFUSIONIMAGE_SOURCE_CPP__ diff --git a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.h b/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.h deleted file mode 100644 index ae199534a9..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkDiffusionImageSource.h +++ /dev/null @@ -1,85 +0,0 @@ -/*=================================================================== - -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 _MITK_DIFFUSION_IMAGE_DATA_SOURCE_H_HEADER_ -#define _MITK_DIFFUSION_IMAGE_DATA_SOURCE_H_HEADER_ - -#include "mitkImageSource.h" - -namespace mitk { - - template - class DiffusionImage; - /*class DiffusionImage; - class DiffusionImage; - class DiffusionImage; - class DiffusionImage; - class DiffusionImage; - class DiffusionImage; - class DiffusionImage; - class DiffusionImage; - class DiffusionImage;*/ - -//##Documentation -//## @brief Superclass of all classes generating diffusion volumes (instances -//## of class DiffusionImage) as output. -//## -//## @ingroup Process -template -class DiffusionImageSource : public ImageSource -{ -public: - mitkClassMacro(DiffusionImageSource, BaseDataSource); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - typedef DiffusionImage OutputType; - typedef itk::DataObject::Pointer DataObjectPointer; - - /** - * @brief Get the output data of the diffusion image source object. - */ - mitkBaseDataSourceGetOutputDeclarations - - /** - * Allocates a new output object and returns it. Currently the - * index idx is not evaluated. - * @param idx the index of the output for which an object should be created - * @returns the new object - */ - virtual itk::DataObject::Pointer MakeOutput ( DataObjectPointerArraySizeType idx ); - - /** - * This is a default implementation to make sure we have something. - * Once all the subclasses of ProcessObject provide an appopriate - * MakeOutput(), then ProcessObject::MakeOutput() can be made pure - * virtual. - */ - virtual itk::DataObject::Pointer MakeOutput(const DataObjectIdentifierType &name); - -protected: - DiffusionImageSource(); - - virtual ~DiffusionImageSource(); -}; - -} // namespace mitk - -#include "mitkDiffusionImageSource.cpp" - - -#endif /* _MITK_DIFFUSION_IMAGE_DATA_SOURCE_H_HEADER_ */ diff --git a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkImageToDiffusionImageSource.cpp b/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkImageToDiffusionImageSource.cpp deleted file mode 100644 index 6dcbfbba98..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkImageToDiffusionImageSource.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/*=================================================================== - -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 __mitk_ImageToDiffusionImageSource_txx -#define __mitk_ImageToDiffusionImageSource_txx - -#include "mitkImageToDiffusionImageSource.h" - -#include -#include - -#include "mitkImageTimeSelector.h" - -#include -#include - -#include "mitkImageCast.h" - -#include "mitkException.h" - -template< typename TPixelType> -mitk::ImageToDiffusionImageSource::ImageToDiffusionImageSource() - : m_SourceImage(0), - m_GradientDirections(0) -{ - -} - -template< typename TPixelType> -void mitk::ImageToDiffusionImageSource -::GenerateOutputInformation() -{ - // sanity checks ( input not null, timesteps corresponds to number of directions specified ) - if( m_GradientDirections.IsNull() || m_GradientDirections->empty() ) - { - mitkThrow() << "No gradient directions were set. Cannot proceed."; - } - - if( m_SourceImage.IsNull() ) - { - mitkThrow() << "No input image was set. Cannot proceed."; - } - - if( m_GradientDirections->size() != m_SourceImage->GetTimeSteps() ) - { - mitkThrow() << "Size mismatch between container size " << m_GradientDirections->size() << - "and image volumes."<< m_SourceImage->GetTimeSteps() <<" Cannot proceed."; - } - - - // already pass in the meta-data - typename OutputType::Pointer metaImage = OutputType::New(); - - // set identity as measurement frame - vnl_matrix_fixed< double, 3, 3 > measurement_frame; - measurement_frame.set_identity(); - metaImage->SetMeasurementFrame( measurement_frame ); - - // set directions and bvalue - metaImage->SetDirections(this->m_GradientDirections); - metaImage->SetReferenceBValue(this->m_BValue); - - m_OutputCache = metaImage; - m_CacheTime.Modified(); - -} - -template< typename TPixelType> -void mitk::ImageToDiffusionImageSource -::GenerateData() -{ - if ( ( ! m_OutputCache ) || ( this->GetMTime( ) > m_CacheTime.GetMTime( ) ) ) - { - this->GenerateOutputInformation(); - itkWarningMacro("Cache regenerated!"); - } - - // now cast the mitk image to the vector image and pass in as volume - typedef itk::Image< TPixelType, 4 > InputItkType; - typedef itk::Image< TPixelType, 3> SingleVolumeType; - typedef itk::VectorImage< TPixelType, 3> VectorImageType; - - typedef itk::ComposeImageFilter< SingleVolumeType > ComposeFilterType; - typename ComposeFilterType::Pointer vec_composer = ComposeFilterType::New(); - - mitk::ImageTimeSelector::Pointer t_selector = - mitk::ImageTimeSelector::New(); - - t_selector->SetInput( m_SourceImage ); - - for( unsigned int i=0; i< m_SourceImage->GetTimeSteps(); i++) - { - t_selector->SetTimeNr(i); - t_selector->Update(); - - typename SingleVolumeType::Pointer singleImageItk; - mitk::CastToItkImage( t_selector->GetOutput(), singleImageItk ); - - vec_composer->SetInput( i, singleImageItk ); - - } - - try - { - vec_composer->Update(); - } - catch( const itk::ExceptionObject& e) - { - MITK_ERROR << "Caugt exception while updating compose filter: " << e.what(); - } - - - m_OutputCache->SetVectorImage( vec_composer->GetOutput() ); - - // transfer to the output image - static_cast(this->GetOutput()) - ->SetVectorImage(m_OutputCache->GetVectorImage()); - static_cast(this->GetOutput()) - ->SetReferenceBValue(m_OutputCache->GetReferenceBValue()); - static_cast(this->GetOutput()) - ->SetMeasurementFrame(m_OutputCache->GetMeasurementFrame()); - static_cast(this->GetOutput()) - ->SetDirections(m_OutputCache->GetDirections()); - static_cast(this->GetOutput()) - ->InitializeFromVectorImage(); - - -} - -#endif //__mitk_ImageToDiffusionImageSource_txx diff --git a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkImageToDiffusionImageSource.h b/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkImageToDiffusionImageSource.h deleted file mode 100644 index 0b31f3c261..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/IODataStructures/DiffusionWeightedImages/mitkImageToDiffusionImageSource.h +++ /dev/null @@ -1,104 +0,0 @@ -/*=================================================================== - -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 MITKIMAGETODIFFUSIONIMAGESOURCE_H -#define MITKIMAGETODIFFUSIONIMAGESOURCE_H - -#include "mitkDiffusionImageSource.h" - -namespace mitk -{ -/** - * @class ImageToDiffusionImageSource - * @brief The class requires a 3d+t image, list of gradient directions and a corresponding b-value - * and reinterprets the input image as a diffusion-weighted image. - * - * The filter throws an mitk::Exception if - * - no gradient list was set - * - no input image was set - * - the size of the gradient list and the count of timesteps do not match - */ -template< typename TPixelType > -class ImageToDiffusionImageSource - : public DiffusionImageSource< TPixelType > -{ -public: - - typedef vnl_vector_fixed< double, 3 > GradientDirectionType; - typedef vnl_matrix_fixed< double, 3, 3 > MeasurementFrameType; - typedef itk::VectorContainer< unsigned int, - GradientDirectionType >::Pointer GradientDirectionContainerType; - - mitkClassMacro( ImageToDiffusionImageSource, - DiffusionImageSource ) - - itkSimpleNewMacro(Self) - - typedef typename Superclass::OutputType OutputType; - typedef itk::VectorImage ImageType; - - /** - * @brief Set the mitk image ( a 3d+t image ) which is to be reinterpreted as dw image - * @param mitkImage - */ - void SetImage( mitk::Image::Pointer mitkImage ) - { - m_SourceImage = mitkImage; - } - - /** - * @brief Set the gradient directions corresponding to the volumes of the input image - * @param container the container with the gradient directions - * - * @note The gradient directions must correspond to the volumes stored in the 3d+t input - */ - void SetGradientDirections( GradientDirectionContainerType container ) - { - m_GradientDirections = container; - } - - /** - * @brief Set the b-value - * @param bvalue the b-value associated with the gradient list - */ - void SetBValue( float bvalue ) - { - this->m_BValue = bvalue; - } - - -protected: - ImageToDiffusionImageSource(); - virtual ~ImageToDiffusionImageSource(){} - - virtual void GenerateData(); - - virtual void GenerateOutputInformation(); - - mitk::Image::Pointer m_SourceImage; - GradientDirectionContainerType m_GradientDirections; - - typename OutputType::Pointer m_OutputCache; - itk::TimeStamp m_CacheTime; - - float m_BValue; -}; - - -} - -#include "mitkImageToDiffusionImageSource.cpp" -#endif // MITKIMAGETODIFFUSIONIMAGESOURCE_H diff --git a/Modules/DiffusionImaging/DiffusionCore/Rendering/mitkDiffusionImageMapper.cpp b/Modules/DiffusionImaging/DiffusionCore/Rendering/mitkDiffusionImageMapper.cpp deleted file mode 100644 index dd8b9888ce..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/Rendering/mitkDiffusionImageMapper.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*=================================================================== - -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 DiffusionImageMapper_txx_HEADER_INCLUDED -#define DiffusionImageMapper_txx_HEADER_INCLUDED - -#include "mitkProperties.h" -#include "mitkDiffusionImage.h" - -template -mitk::DiffusionImageMapper::DiffusionImageMapper() -{ - -} - -template -mitk::DiffusionImageMapper::~DiffusionImageMapper() -{ - -} - -template -void -mitk::DiffusionImageMapper::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) -{ - int displayIndex(0); - - - this->GetDataNode()->GetIntProperty( "DisplayChannel", displayIndex, renderer ); - mitk::Image *input = const_cast< mitk::Image* >( - this->GetInput() - ); - mitk::DiffusionImage *input2 = dynamic_cast< mitk::DiffusionImage* >( - input - ); - - input2->SetDisplayIndexForRendering(displayIndex); - Superclass::GenerateDataForRenderer(renderer); -} - -template -void mitk::DiffusionImageMapper::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) -{ - node->AddProperty( "DisplayChannel", mitk::IntProperty::New( 0 ), renderer, overwrite ); - Superclass::SetDefaultProperties(node, renderer, overwrite); -} - -#endif diff --git a/Modules/DiffusionImaging/DiffusionCore/Rendering/mitkDiffusionImageMapper.h b/Modules/DiffusionImaging/DiffusionCore/Rendering/mitkDiffusionImageMapper.h deleted file mode 100644 index fa53102f1d..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/Rendering/mitkDiffusionImageMapper.h +++ /dev/null @@ -1,54 +0,0 @@ -/*=================================================================== - -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 DiffusionImageMapper_H_HEADER_INCLUDED -#define DiffusionImageMapper_H_HEADER_INCLUDED - -#include "mitkImageVtkMapper2D.h" - -namespace mitk { - - //##Documentation - //## @brief Mapper for raw diffusion weighted images - //## @ingroup Mapper - template - class DiffusionImageMapper : public ImageVtkMapper2D - { - public: - - mitkClassMacro(DiffusionImageMapper,ImageVtkMapper2D); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - void GenerateDataForRenderer( mitk::BaseRenderer *renderer ); - - static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = NULL, bool overwrite = false ); - - protected: - - DiffusionImageMapper(); - virtual ~DiffusionImageMapper(); - - }; - -} // namespace mitk - -#include "mitkDiffusionImageMapper.cpp" - - -#endif /* COMPOSITEMAPPER_H_HEADER_INCLUDED */ - diff --git a/Modules/DiffusionImaging/DiffusionCore/Testing/mitkDiffusionImageEqualTest.cpp b/Modules/DiffusionImaging/DiffusionCore/Testing/mitkDiffusionImageEqualTest.cpp deleted file mode 100644 index 8f33698338..0000000000 --- a/Modules/DiffusionImaging/DiffusionCore/Testing/mitkDiffusionImageEqualTest.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -#include "mitkDiffusionImage.h" -#include "mitkIOUtil.h" -#include "mitkTestingMacros.h" -#include "mitkTestFixture.h" -#include "itkDwiGradientLengthCorrectionFilter.h" - -class mitkDiffusionImageEqualTestSuite : public mitk::TestFixture -{ - - CPPUNIT_TEST_SUITE(mitkDiffusionImageEqualTestSuite); - MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue); - MITK_TEST(Equal_DifferentGradientContainerElements_ReturnsFalse); - MITK_TEST(Equal_DifferentBValue_ReturnsFalse); - MITK_TEST(Equal_DifferentVectorImagePixel_ReturnFalse); - MITK_TEST(Equal_GetNumberOfBValues_ReturnFalse); - MITK_TEST(Equal_DifferentMeasurmentFrame_ReturnFalse); - //MITK_TEST(Equal_DifferentChannels_ReturnFalse); - - - CPPUNIT_TEST_SUITE_END(); - -private: - - /** Members used inside the different (sub-)tests. All members are initialized via setUp().*/ - mitk::DiffusionImage::Pointer m_Image; - mitk::DiffusionImage::Pointer m_AnotherImage; - -public: - - /** -* @brief Setup Always call this method before each Test-case to ensure correct and new intialization of the used members for a new test case. (If the members are not used in a test, the method does not need to be called). -*/ - void setUp() - { - //generate a gradient test image - std::string imagePath = GetTestDataFilePath("DiffusionImaging/ImageReconstruction/test_multi.dwi"); - m_Image = static_cast*>( mitk::IOUtil::LoadImage(imagePath).GetPointer()); - m_AnotherImage = m_Image->Clone(); - } - - void tearDown() - { - m_Image = NULL; - m_AnotherImage = NULL; - } - - void Equal_CloneAndOriginal_ReturnsTrue() - { - MITK_ASSERT_EQUAL( m_Image, m_AnotherImage, "A clone should be equal to its original."); - } - - void Equal_DifferentGradientContainerElements_ReturnsFalse() - { - mitk::DiffusionImage::GradientDirectionType dummyVec; - dummyVec.fill(std::numeric_limits::max()); - mitk::DiffusionImage::GradientDirectionContainerType::ElementIdentifier mid_pos(m_AnotherImage->GetDirections()->Size()*0.5); - m_AnotherImage->GetDirections()->SetElement(mid_pos, dummyVec); - MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "GradientDirectionContainer Elements are not equal."); - } - - void Equal_DifferentBValue_ReturnsFalse() - { - m_AnotherImage->SetReferenceBValue(std::numeric_limits::max()); - MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "BValue is not equal."); - } - - void Equal_DifferentVectorImagePixel_ReturnFalse() - { - mitk::DiffusionImage::ImageType::IndexType indx; - indx.Fill(0); - mitk::DiffusionImage::ImageType::PixelType pix; - short* val = new short[pix.Size()]; - pix.SetData(val); - pix.Fill(std::numeric_limits::min()); - m_AnotherImage->GetVectorImage()->SetPixel(indx,pix); - MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "itkVectorImage voxel at pos [0,0,0] should be different."); - } - - void Equal_DifferentMeasurmentFrame_ReturnFalse() - { - mitk::DiffusionImage::MeasurementFrameType null_measurementframe; - null_measurementframe.fill(0); - m_AnotherImage->SetMeasurementFrame(null_measurementframe); - MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "MeasurementFrame is an empty matrix. Result should be false."); - } - - void Equal_GetNumberOfBValues_ReturnFalse() - { - itk::DwiGradientLengthCorrectionFilter::Pointer lengthCorrectionFilter = itk::DwiGradientLengthCorrectionFilter::New(); - lengthCorrectionFilter->SetReferenceBValue(m_AnotherImage->GetReferenceBValue()); - lengthCorrectionFilter->SetReferenceGradientDirectionContainer(m_AnotherImage->GetDirections()); - lengthCorrectionFilter->SetRoundingValue(10000); - lengthCorrectionFilter->Update(); - m_AnotherImage->SetDirections(lengthCorrectionFilter->GetOutputGradientDirectionContainer()); - MITK_ASSERT_NOT_EQUAL( m_Image, m_AnotherImage, "NumberOfBValues should different."); - } - -}; - -MITK_TEST_SUITE_REGISTRATION(mitkDiffusionImageEqual) diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkDiffusionImageSerializer.cpp b/Modules/DiffusionImaging/DiffusionIO/mitkDiffusionImageSerializer.cpp deleted file mode 100644 index 5e67c079e7..0000000000 --- a/Modules/DiffusionImaging/DiffusionIO/mitkDiffusionImageSerializer.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*=================================================================== - -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. - -===================================================================*/ - -#include "mitkDiffusionImageSerializer.h" -#include "mitkDiffusionImage.h" -#include "mitkNrrdDiffusionImageWriter.h" - -#include - - -MITK_REGISTER_SERIALIZER(DiffusionImageSerializer) - - -mitk::DiffusionImageSerializer::DiffusionImageSerializer() -{ -} - - -mitk::DiffusionImageSerializer::~DiffusionImageSerializer() -{ -} - - -std::string mitk::DiffusionImageSerializer::Serialize() -{ - const DiffusionImage* image = dynamic_cast*>( m_Data.GetPointer() ); - if (image == NULL) - { - MITK_ERROR << " Object at " << (const void*) this->m_Data - << " is not an mitk::DiffusionImage. Cannot serialize as DiffusionImage."; - return ""; - } - - std::string filename( this->GetUniqueFilenameInWorkingDirectory() ); - filename += "_"; - filename += m_FilenameHint; - filename += ".dwi"; - - std::string fullname(m_WorkingDirectory); - fullname += "/"; - fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str()); - - try - { - NrrdDiffusionImageWriter writer; - writer.SetOutputLocation(fullname); - writer.SetInput(const_cast*>(image)); - writer.Write(); - } - catch (std::exception& e) - { - MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data - << " to " - << fullname - << ": " - << e.what(); - return ""; - } - return filename; -} - diff --git a/Modules/DiffusionImaging/DiffusionIO/mitkDiffusionImageSerializer.h b/Modules/DiffusionImaging/DiffusionIO/mitkDiffusionImageSerializer.h deleted file mode 100644 index d1b4a593d0..0000000000 --- a/Modules/DiffusionImaging/DiffusionIO/mitkDiffusionImageSerializer.h +++ /dev/null @@ -1,39 +0,0 @@ -/*=================================================================== - -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 mitkDiffusionImageSerializer_h_included -#define mitkDiffusionImageSerializer_h_included - -#include "mitkBaseDataSerializer.h" - -namespace mitk -{ -/** - \brief Serializes mitk::Surface for mitk::SceneIO -*/ -class DiffusionImageSerializer : public BaseDataSerializer -{ - public: - mitkClassMacro( DiffusionImageSerializer, BaseDataSerializer ); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - virtual std::string Serialize(); - protected: - DiffusionImageSerializer(); - virtual ~DiffusionImageSerializer(); -}; -} // namespace -#endif