Difference between revisions of "MITK DiffusionImage Replacement Guide"

From mitk.org
Jump to navigation Jump to search
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
= MITK Diffusion Image Replacement Guide =
+
We have decided to remove the MITK::DiffusionImage and instead represent diffusion weighted images by mitk::Image pointing to an itk::VectorImage . This is mainly due to the fact, that there is no longer a reason to use separate classes and unifying the image reduces the maintenance cost.
  
We have decided to remove the MITK::DiffusionImage and instead represent diffusion weighted images by mitk::Image pointing to an itk::VectorImage . This is mainly due to the fact, that there is no longer a reason to use separate classes and unifying the image reduces the maintenance cost.
 
  
 
== What to replace ==
 
== What to replace ==
  
 
When adjusting your code to use the new data type you will have to replace the some calls, mitkDiffusionImagePointer is a MITK::DiffusionImage::Pointer, mitkImagePointer is the MITK::Image::Pointer containing the same data.
 
When adjusting your code to use the new data type you will have to replace the some calls, mitkDiffusionImagePointer is a MITK::DiffusionImage::Pointer, mitkImagePointer is the MITK::Image::Pointer containing the same data.
 +
  
 
=== Old code ===
 
=== Old code ===
  
<pre><nowiki>#!highlight c++
+
<syntaxhighlight lang="cpp">
 
   typedef mitk::DiffusionImage<DiffusionPixelType> DiffusionImageType;
 
   typedef mitk::DiffusionImage<DiffusionPixelType> DiffusionImageType;
 
   typedef DiffusionImageType::GradientDirectionContainerType GradientDirectionContainerType;
 
   typedef DiffusionImageType::GradientDirectionContainerType GradientDirectionContainerType;
Line 40: Line 40:
 
   if ( mitkDiffusionImagePointer.IsNotNull() )
 
   if ( mitkDiffusionImagePointer.IsNotNull() )
  
</nowiki></pre>
+
</syntaxhighlight>
  
  
 
=== New Code ===
 
=== New Code ===
  
 
+
<syntaxhighlight lang="cpp">
<pre><nowiki>#!highlight c++
 
 
   typedef itk::VectorImage<DiffusionPixelType, dimension> ITKDiffusionImageType;
 
   typedef itk::VectorImage<DiffusionPixelType, dimension> ITKDiffusionImageType;
 
   typedef mitk::GradientDirectionsProperty::GradientDirectionsContainerType GradientDirectionContainerType;
 
   typedef mitk::GradientDirectionsProperty::GradientDirectionsContainerType GradientDirectionContainerType;
Line 57: Line 56:
  
 
   // get gradient directions
 
   // get gradient directions
   static_cast<mitk::GradientDirectionsProperty*>( mitkImagePointer->GetProperty("GradientDirections").GetPointer() )->GetGradientDirectionsContainer();
+
   static_cast<mitk::GradientDirectionsProperty*>( mitkImagePointer->GetProperty(
 +
    mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str()).GetPointer() )
 +
    ->GetGradientDirectionsContainer();
  
 
   // get reference b value
 
   // get reference b value
   static_cast<mitk::FloatProperty*>(mitkImagePointer->GetProperty("ReferenceBValue").GetPointer() )->GetValue();
+
   static_cast<mitk::FloatProperty*>(mitkImagePointer->GetProperty
 +
    (mitk::DiffusionPropertyHelper::REFERENCEBVALUEPROPERTYNAME.c_str()).GetPointer() )
 +
    ->GetValue();
  
 
   // get b value map
 
   // get b value map
   static_cast<mitk::BValueMapProperty*>(mitkImagePointer->GetProperty("BValueMap").GetPointer() )->GetBValueMap();
+
   static_cast<mitk::BValueMapProperty*>(mitkImagePointer->GetProperty
 +
    (mitk::DiffusionPropertyHelper::BVALUEMAPPROPERTYNAME.c_str()).GetPointer() )
 +
    ->GetBValueMap();
  
 
   // get the vector image data
 
   // get the vector image data
 
   ITKDiffusionImageType::Pointer itkVectorImagePointer = ITKDiffusionImageType::New();
 
   ITKDiffusionImageType::Pointer itkVectorImagePointer = ITKDiffusionImageType::New();
   mitk::CastToItkVectorImage(mitkImagePointer, itkVectorImagePointer);
+
   mitk::CastToItkImage(mitkImagePointer, itkVectorImagePointer);
  
 
   // initialize image from contained data
 
   // initialize image from contained data
Line 73: Line 78:
  
 
   // add node to datastorage
 
   // add node to datastorage
   imageNode->SetProperty( "DiffusionWeightedImage", mitk::BoolProperty::New( true ) );
+
   imageNode->SetProperty
 +
  (mitk::DiffusionPropertyHelper::ISDIFFUSIONWEIGHTEDIMAGEPROPERTYNAME.c_str(),  
 +
  mitk::BoolProperty::New( true ) );
  
 
   // check whether something is a diffusion image
 
   // check whether something is a diffusion image
 
   bool isDiffusionImage(false);
 
   bool isDiffusionImage(false);
   m_SelectedImageNode->GetBoolProperty( "DiffusionWeightedImage", isDiffusionImage );
+
   imageNode->GetBoolProperty
 +
  (mitk::DiffusionPropertyHelper::ISDIFFUSIONWEIGHTEDIMAGEPROPERTYNAME.c_str(),  
 +
  isDiffusionImage);
 
   if ( isDiffusionImage )
 
   if ( isDiffusionImage )
</nowiki></pre>
+
</syntaxhighlight>
 +
 
 +
 
 +
for an example of how to create a new mitk::Image containing a VectorImage take a look at

Latest revision as of 15:36, 4 December 2014

We have decided to remove the MITK::DiffusionImage and instead represent diffusion weighted images by mitk::Image pointing to an itk::VectorImage . This is mainly due to the fact, that there is no longer a reason to use separate classes and unifying the image reduces the maintenance cost.


What to replace

When adjusting your code to use the new data type you will have to replace the some calls, mitkDiffusionImagePointer is a MITK::DiffusionImage::Pointer, mitkImagePointer is the MITK::Image::Pointer containing the same data.


Old code

<syntaxhighlight lang="cpp">

 typedef mitk::DiffusionImage<DiffusionPixelType> DiffusionImageType;
 typedef DiffusionImageType::GradientDirectionContainerType GradientDirectionContainerType;
 // cast node
 DiffusionImageType* mitkDiffusionImagePointer= static_cast<DiffusionImageType*>(node->GetData());
 // create new vector image data
 mitkDiffusionImagePointer->SetVectorImage( filter-GetOutput() );
 // get gradient directions
 mitkDiffusionImagePointer->GetDirections();
 // get reference b value
 mitkDiffusionImagePointer->GetReferenceBValue();
 // get b value map
 mitkDiffusionImagePointer->GetBValueMap();
 // get the vector image data
 mitkDiffusionImagePointer->GetVectorImage();
 // initialize image from contained data
 mitkDiffusionImagePointer->InitializeFromVectorImage();

 // add node to datastorage
 // check whether something is a diffusion image
 if ( mitkDiffusionImagePointer.IsNotNull() )

</syntaxhighlight>


New Code

<syntaxhighlight lang="cpp">

 typedef itk::VectorImage<DiffusionPixelType, dimension> ITKDiffusionImageType;
 typedef mitk::GradientDirectionsProperty::GradientDirectionsContainerType GradientDirectionContainerType;
 // cast node
 mitk::Image* mitkImagePointer = static_cast<mitk::Image*>(node->GetData());
 // create new vector image data
 mitk::Image::Pointer mitkImagePointer = mitk::ImportItkImage( filter->GetOutput() );
 // get gradient directions
 static_cast<mitk::GradientDirectionsProperty*>( mitkImagePointer->GetProperty(
   mitk::DiffusionPropertyHelper::GRADIENTCONTAINERPROPERTYNAME.c_str()).GetPointer() )
   ->GetGradientDirectionsContainer();
 // get reference b value
 static_cast<mitk::FloatProperty*>(mitkImagePointer->GetProperty
   (mitk::DiffusionPropertyHelper::REFERENCEBVALUEPROPERTYNAME.c_str()).GetPointer() )
   ->GetValue();
 // get b value map
 static_cast<mitk::BValueMapProperty*>(mitkImagePointer->GetProperty
   (mitk::DiffusionPropertyHelper::BVALUEMAPPROPERTYNAME.c_str()).GetPointer() )
   ->GetBValueMap();
 // get the vector image data
 ITKDiffusionImageType::Pointer itkVectorImagePointer = ITKDiffusionImageType::New();
 mitk::CastToItkImage(mitkImagePointer, itkVectorImagePointer);
 // initialize image from contained data
 mitkImagePointer->InitializeByItk( itkVectorImagePointer.GetPointer() );
 // add node to datastorage
 imageNode->SetProperty
  (mitk::DiffusionPropertyHelper::ISDIFFUSIONWEIGHTEDIMAGEPROPERTYNAME.c_str(), 
  mitk::BoolProperty::New( true ) );
 // check whether something is a diffusion image
 bool isDiffusionImage(false);
 imageNode->GetBoolProperty
 (mitk::DiffusionPropertyHelper::ISDIFFUSIONWEIGHTEDIMAGEPROPERTYNAME.c_str(), 
  isDiffusionImage);
 if ( isDiffusionImage )

</syntaxhighlight>


for an example of how to create a new mitk::Image containing a VectorImage take a look at