[ITK-users] [ITK] SimpleITK - Resampling Coronal Image in the Axial View

Timothee Evain tevain at telecom-paristech.fr
Wed Jul 13 05:54:55 EDT 2016


Hi Sara,

The origin of an image is the point in world coordinates where the image "start" (from lower indexes to higher ones), not to be confused with the origin of the reference frame, which is [0,0,0]. When dealing with geometry, a drawing is often helpful to know what happens to the image origin during transformation.

And yes, you could do it through direction modification, that's just a bit more complicated.
Since modifing direction means transforming the reference frame, you have to compute where and which point will be the new origin of the imageC.

Sticking with the previous hypothesis on imageC position, the "true" origin of imageC (origin of imageCA) is the point:
-last in the original Y imageC direction
-first in the original X imageC direction
-first in the original Z imageC direction

So if the original origin of imageC is [0,0,0], this point will be [0,SizeC[1]*SpacingC[1],0].
Then this "true" origin will be modified by the rotation of the frame. In your case , -pi/2, giving [0,0,-SizeC[1]*SpacingC[1]].
Put this as the output origin and you should be fine.
Of course, is the original origin of imageC isn't [0,0,0], you should compute the new point accordingly.

For general matters, it should be noted that this works because the default rotation center is also the reference frame origin (i.e. [0,0,0])

HTH,

Tim



----- Mail original -----
De: "Sara Gh" <sg.ele.eng at gmail.com>
À: "Timothee Evain" <tevain at telecom-paristech.fr>
Cc: insight-users at itk.org
Envoyé: Mardi 12 Juillet 2016 22:54:25
Objet: Re: [ITK] [ITK-users] SimpleITK - Resampling Coronal Image in the Axial View

Hello Tim,

Thank you for your helpful email and sorry for late reply.

Yes, that's right. The size of resampled imageC should be 256x68x256 and
imageC should be rotated -pi/2 around the X axis.
Now, my first question is: Can I use the direction of imageA as
the OutputDirection instead of using Euler3DTransform? Something like this:

# Direction of imageA: (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
# Direction of imageC: (1.0, 0.0, 0.0, 0.0, -0.0, 1.0, 0.0, -1.0, -0.0)
resample = sitk.ResampleImageFilter()
resample.SetTransform(sitk.Transform(3, sitk.sitkIdentity))
resample.SetReferenceImage(imageC)
resample.SetOutputDirection(imageA.GetDirection())
resample.SetOutputOrigin(imageA.GetOrigin())
spacingCA = [spacingC[0],spacingC[2],spacingC[1]]
resample.SetOutputSpacing(spacingCA)
sizeC = imageC.GetSize()
sizeCA = [sizeC[0], sizeC[2], sizeC[1]]
resample.SetSize(sizeCA)
imageCA=resample.Execute(imageC)
sitk.Show(imageCA)

Second, I think I haven't set the correct OutputOrigin for the resampled
image because when I compare imageCA with the axial view of imageC
(calculated by ImageJ > Stacks> Orthogonal Views), it seems that the
resulted imageCA is the translated version of the correct axial view.

I have read the ITK guide chapter 2.9 about transformation and resampling
processes but it is still vague to me how one should calculate/select the
correct origin for the output image. I would be thankful if you could refer
me to any other resources that could be helpful to me in this regard.

Thank you in advance.

Best regards,
Sara


On Mon, Jun 27, 2016 at 5:40 AM, Timothee Evain <tevain at telecom-paristech.fr
> wrote:

> Hello,
>
> First of all, it depends on the patient position in the data, but usually
> the X axis describe the left/right direction, the Y axis the
> anterior/posterior direction and the Z axis the top/bottom one.
> So I would expect the resampled imageC size to be 256x68x256 rather than
> 68x256x256.
>
> Then, I think you should try to transform your imageC to be in the imageA
> orientation. Let say the imageA have a LPS coordinate system.
> If the imageC :
> -first direction represents the axis going from the patient's right to the
> patient's left
> -second direction represents the axis going from the patient's top to the
> patient's bottom
> -third direction represents the axis going from the patient's front to the
> patient's rear
> Then you should rotate the imageC by a -pi/2 angle around the X axis.
>
> You could use the Euler3DTransform to get this rotation.
> Then you feed the resample filter with this transform, plus the needed
> parameters (origin, spacing, size,...), and you should be able to have your
> resampled data.
> Just be sure to fully understand the transformation you're making (I
> recommend the ResampleImageFilter part of the ITK guide which is quite
> useful).
>
> HTH,
>
> Tim
>
>
> ----- Mail original -----
> De: "Sara Gh" <sg.ele.eng at gmail.com>
> À: insight-users at itk.org
> Envoyé: Dimanche 26 Juin 2016 07:57:16
> Objet: [ITK] [ITK-users] SimpleITK - Resampling Coronal Image in the
> Axial      View
>
> Hello experts,
>
> I have two MRI scans: Axial and Coronal
> # imageA : Axial MRI scan, size : 256x256x56 (256mmx256mmx168mm) ,
> spacing: 1,1,3 ( slice gap : 1 => slice thickness : 2 )
> # imageC : Coronal MRI scan, size : 256x256x68 (256mmx256mmx204mm) ,
> spacing: 1,1,3 ( slice gap : 1 => slice thickness : 2 )
>
> I am trying to view Coronal image from the axial view i.e. resampling
> Coronal image using the direction of Axial image. Here is my code:
>
> resample = sitk.ResampleImageFilter()
> resample.SetReferenceImage(imageC)
> resample.SetOutputDirection(imageA.GetDirection())
> resample.SetOutputOrigin(imageA.GetOrigin())
> imageCA = resample.Execute(imageC)
> sitk.Show(imageCA)
>
> # Result: imageCA: size : 256x256x68 (256mmx256mmx204mm), spacing: 1,1,3
>
> I believe I have missed something because, in my idea, the size of
> resampled coronal image (imageCA) should be 68x256x256 ( 204mmx256mmx256mm)
> with the spacing [3,1,1] .
>
> I also tried to set the OutputSpacing to [3,1,1], but the size of the
> imageCA changes to 256x256x68 (768mmx256mmx68mm).
>
> I would be thankful if someone could help me in this regard.
>
> Best regards,
> Sara Gh
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community
>



-- 
Sara Gharabaghi, Ph.D. Student
Graduate Research Assistant
Advanced Visual Data Analysis (AViDA) Lab
Biomedical Imaging Lab
Wright State University


More information about the Insight-users mailing list