[ITK] change orientation of images with OrientImageFilter

Butlers Home butlershomecoffee at gmail.com
Tue Jul 29 12:03:25 EDT 2014


On 29 July 2014 17:22, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:

> Hello Butlers,
>
> Just because the images look the same doesn't mean the filter didn't have
> an effect! Does ITK-SNAP have a way to look at the orientation of the
> direction cosine matrix? This should be different between the two images.
>

The matrices stay the same: For example
[-0.5    0    0    0
 0     -0.5   0    0
 0        0   0.5  1]        is the same for LSP and RAI orientations.



>
> My understanding of that orientation filter was that it changed the
> direction cosines AND the order of the pixels such that they still have the
> same physical location. Since you are using a viewer which is aware of this
> information I would not expect the image to visually change.
>

I've also checked their positions with Slicer and it yields the same
interpretation. However, if what you say is true, then any visualizer
should yield the same output provided that the same physical location is
preserved. I still don't understand why one would not display the image
with the orientation that corresponds to its specifications.


>
> I don't know how that orientation field in the MHA file is used... others
> have already chimed in on that.
>
> Brad
>
> On Jul 29, 2014, at 10:13 AM, Butlers Home <butlershomecoffee at gmail.com>
> wrote:
>
> I would like to know how I can change the orientation of two 3D images.
> Scenario:
> - both images are .mha
> - one image has RAI as the initial orientation
> - 2nd image has LPS as the initial orientation
>
> I would like to set the same orientation RAI for both images before
> processing them (i.e., registering them in my case). With the below
> mentioned code I manage to change the orientation specified textually in
> the .mha files but visually they do not change. Why is that? Is the
> orientation changing just within the header specifications without actually
> changing the visualization part? For visualization I used ITK-SNAP.
>
> Here is a code snippet from what I do:
>
> [...]
>
> typedef itk::ImageFileReader< ImageType2 > ImageReaderType1;
> typedef itk::ImageFileReader< ImageType1 > ImageReaderType2;
>
> ImageReaderType1::Pointer imReader1 = ImageReaderType1::New();
> ImageReaderType2::Pointer imReader2 = ImageReaderType2::New();
>
> imReader1->SetFileName("im1.mha");
> imReader2->SetFileName("im2.mha");
>
> imReader1->Update();
>
> // set both images to same orientation
>
> // orientation filter for 1st image
> itk::OrientImageFilter<ImageType1, ImageType1>::Pointer orienter1 =
> itk::OrientImageFilter<ImageType1, ImageType1>::New();
> orienter1->UseImageDirectionOn();
>
> orienter1->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
> orienter1->SetInput(imReader1->GetOutput());
> orienter1->Update();
>
> // orientation filter for 2nd image
> itk::OrientImageFilter<ImageType2, ImageType2>::Pointer orienter2 =
> itk::OrientImageFilter<ImageType2, ImageType2>::New();
> orienter2->UseImageDirectionOn();
>
> orienter2->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);
> orienter2->SetInput(imReader2->GetOutput());
> orienter2->Update();
>
> [...]
>
> I tried not using the cosine-based approach, i.e., use the
> itk::AnalyzeImageIO class together with itk::ExposeMetaData<>() but for
> some unknown reason, the orientation is not determined appropriately. I
> would also prefer not using them at all because, as far as I understood,
> they are deprecated.
>
> Thank you.
>
> Best regards,
> --
> Butlers
>  _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>
>
>

Best,
-- 
Butlers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140729/29b22a1e/attachment-0002.html>


More information about the Community mailing list