[Insight-users] AnatomicalOrientation and OrientImageFilter

kurt Zhao kurtzhao at gmail.com
Thu Mar 1 08:31:04 EST 2007


Thanks Fucang.

-Kurt

On 3/1/07, jiafucang <jiafucang at anketech.com> wrote:
>
>  Hi, Kurt,
>
> This is a bug http://www.itk.org/Bug/bug.php?op=show&bugid=3311&pos=17
>
> Hope that helps!
>
> Fucang
>  ------------------------------
>  *发件人:* kurt Zhao
> *发送时间:* 2007-03-01 09:02:17
> *收件人:* insight-users at itk.org
> *抄送:*
> *主题:* [Insight-users] AnatomicalOrientation and OrientImageFilter
>
> Hi guys,
>
> I am trying to convert the AnatomicalOrientation of a 3D MRI from RPI to
> RSA using OrientImageFilter.
>
>
> However, the entry "AnatomicalOrientation" in the header of the output
> *mha file is always RPI. itkSNAP was not able to interpret the anatomical
> orientation as RSA either.
>
> so my question is:
>
> 1. is it a bug in OrientImageFilter?
>
> 2. How to verify the AnatomicalOrientation of a *.nii or *.mha file?
> should I look at the header of meta data? or load them into Slicer3 or SNAP?
>
>
> The data can be accessed at http://www.duke.edu/~kurtzhao/RPI.zip<http://www.duke.edu/%7Ekurtzhao/RPI.zip>
> The code is enclosed:
>
> Thanks a lot!
> -Kurt
>
>
> #include <iostream>
>
>
> #include <metaCommand.h>
> #include <itkImageFileWriter.h>
> #include <itkImageFileReader.h>
> #include <itkAnalyzeImageIO.h>
> #include <itkNiftiImageIO.h>
> #include <itkOrientImageFilter.h >
> #include <itkSpatialOrientation.h>
>
>
>
> int main(int argc, char **argv)
>   {
>
>   /**
>    * Typedefs and test reading to determine correct image types.
>    * *******************************************************************
>    */
>
>   /** Initial image type. */
>   const unsigned int    Dimension  =  3;
>   //typedef float PixelType;
>   typedef short PixelType;
>
>   /** Some typedef's. */
>   typedef itk::Image< PixelType, Dimension >      ImageType;
>   typedef itk::ImageFileReader< ImageType >       ReaderType;
>   typedef itk::ImageIOBase                        ImageIOBaseType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>
>   itk::AnalyzeImageIO::Pointer io = itk::AnalyzeImageIO::New();
>
>   //reader -> SetImageIO ( io ) ;
>   /** Setup the Reader. */
>   std::string inputFileName;
>   //inputFileName = "C:/data/formatConversion/c1002a3T1.hdr";
>   inputFileName = "C:/data/formatConversion/RPI.mha";
>
>   reader->SetFileName( inputFileName.c_str() );
>
>   /** Generate all information.
>   reader->GenerateOutputInformation();
>
>   ImageIOBaseType::Pointer testImageIOBase = testReader->GetImageIO();
>
>   unsigned int inputDimension = testImageIOBase->GetNumberOfDimensions();
>   unsigned int numberOfComponents =
> testImageIOBase->GetNumberOfComponents();
>   std::string inputPixelComponentType =
> testImageIOBase->GetComponentTypeAsString(
>     testImageIOBase->GetComponentType() );
>   std::cout<<inputPixelComponentType<<std::endl;
>   std::string pixelType = testImageIOBase->GetPixelTypeAsString(
>     testImageIOBase->GetPixelType() );
>   std::cout<<pixelType<<std::endl;
>
>   std::string  outputPixelComponentType = inputPixelComponentType;
>   */
>
>   try
>     {
>     reader -> Update ( ) ;
>     }
>   catch( itk::ExceptionObject  &  err  )
>     {
>     std::cerr  << "ExceptionObject caught !"  << std::endl;
>     std::cerr  << err <<  std::endl;
>     return EXIT_FAILURE;
>     }
>
>   typedef itk::OrientImageFilter<ImageType,ImageType> OrienterType;
>   OrienterType::Pointer orienter =  OrienterType::New();
>   orienter->UseImageDirectionOn();
>
> //orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPS);
>
>
> orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA);
>
>
> //orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI);
>
>   orienter->SetInput( reader -> GetOutput ( ) );
>   try
>     {
>     orienter->Update();
>     }
>   catch( itk::ExceptionObject  &  err  )
>     {
>     std::cerr  << "ExceptionObject caught !"  << std::endl;
>     std::cerr  << err <<  std::endl;
>     return EXIT_FAILURE;
>     }
>
>   typedef itk::ImageFileWriter < ImageType >      WriterType;
>
>   WriterType::Pointer writer = WriterType::New();
>
>   itk::NiftiImageIO::Pointer niftIio = itk::NiftiImageIO::New();
>
>   //writer -> SetImageIO ( niftIio ) ;
>
>   std::string outputFileName;
>
>   outputFileName = "C:/data/formatConversion/RSA.mha";
>   //outputFileName = "C:/data/formatConversion/LPS.mha";
>   //outputFileName = "C:/data/formatConversion/RPI.mha";
>
>   writer ->SetFileName( outputFileName.c_str() );
>
>   //writer -> SetInput ( reader -> GetOutput ( ) ) ;
>   writer -> SetInput ( orienter -> GetOutput ( ) ) ;
>
>   writer -> UseCompressionOn ( ) ;
>
>   try
>     {
>     writer -> Update ( ) ;
>     }
>   catch( itk::ExceptionObject  &  err  )
>     {
>     std::cerr  << "ExceptionObject caught !"  << std::endl;
>     std::cerr  << err <<  std::endl;
>     return EXIT_FAILURE;
>     }
>
>   return EXIT_SUCCESS;
>   }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070301/6c9ac2d2/attachment.htm


More information about the Insight-users mailing list