DiffusionImageMigrationGuide

From mitk.org
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This guide aims to help with the migration from using the mitk::DiffusionImage to using the mitk::Image. For more information take a look at bug 17928

Instead of having its own class derived from the mitk::Image diffusion images are now mitk::Images with added information in their BaseData PropertyList.

Where previously code might have read

<source lang="cpp"> //includes you might need

  1. include <mitkDiffusionImage.h>

// Setting the gradient images for filters FilterType::Pointer filter = FilterType::New(); filter->SetGradientImage( dwi->GetDirections(), dwi->GetVectorImage() );

// Filling the dwi information for images mitk::DiffusionImage<short>::Pointer output = mitk::DiffusionImage<short>::New(); output->SetVectorImage(resampler->GetOutput()); output->SetDirections( dwi->GetDirections() ); output->SetReferenceBValue( dwi->GetReferenceBValue() ); output->SetMeasurementFrame( dwi->GetMeasurementFrame() ); output->InitializeFromVectorImage(); </source>

you would now use

<source lang="cpp"> //includes you might need

  1. include <mitkImage.h>
  2. include <mitkITKImageImport.h>
  3. include <mitkImageCast.h>
  4. include <mitkProperties.h>
  5. include <mitkDiffusionPropertyHelper.h>

// Setting the gradient images for filters mitk::DiffusionPropertyHelper::ImageType::Pointer itkVectorImagePointer = mitk::DiffusionPropertyHelper::ImageType::New(); mitk::CastToItkImage(dwi, itkVectorImagePointer);

FilterType::Pointer filter = FilterType::New(); filter->SetGradientImage( mitk::DiffusionPropertyHelper::GetGradientContainer(dwi), itkVectorImagePointer );


// Filling the dwi information for images mitk::Image::Pointer output = mitk::GrabItkImageMemory( filter->GetOutput() ); output->SetProperty( mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str(), mitk::GradientDirectionsProperty::New( mitk::DiffusionPropertyHelper::GetGradientContainer(dwi) ) ); output->SetProperty( mitk::DiffusionPropertyHelper::MEASUREMENTFRAMEPROPERTYNAME.c_str(), mitk::MeasurementFrameProperty::New( mitk::DiffusionPropertyHelper::GetMeasurementFrame(dwi) ) ); output->SetProperty( mitk::DiffusionPropertyHelper::REFERENCEBVALUEPROPERTYNAME.c_str(), mitk::FloatProperty::New( mitk::DiffusionPropertyHelper::GetReferenceBValue(dwi) ) ); mitk::DiffusionPropertyHelper propertyHelper( output); propertyHelper.InitializeImage(); </source>