Personal tools
User menu

DiffusionImageMigrationGuide

From mitk.org

Jump to: navigation, search

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

//includes you might need
#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();

you would now use

//includes you might need
#include <mitkImage.h>
#include <mitkITKImageImport.h>
#include <mitkImageCast.h>
#include <mitkProperties.h>
#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();
  • This page was last modified on 7 January 2015, at 16:28.
  • This page has been accessed 1,464 times.