# Transform of points using Euler3DTransform

**URL:** https://discourse.itk.org/t/transform-of-points-using-euler3dtransform/5830
**Category:** Beginner Questions
**Tags:** itk, simpleitk
**Created:** [March 24, 2023, 11:01am UTC](https://discourse.itk.org/t/transform-of-points-using-euler3dtransform/5830 "2023-03-24T11:01:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jm\_nc](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jm\_nc](https://discourse.itk.org/u/jm_nc)
#### Post date: [March 24, 2023, 11:01am UTC](https://discourse.itk.org/t/transform-of-points-using-euler3dtransform/5830/1 "2023-03-24T11:01:17Z")

</div>

Hey Everyone - simple question from a newbie, I’m using simple ITK.

I know the registration transform between two (nifti) volumes - I did it manually in MITK and have read back in the offset and rotation. Then I created a Euler3DTransform and use the ‘SetTranslation’ and ‘SetMatrix’ functions to set this offset and rotation in the Euler3DTransform, and when I applied this transform to the source nifti (using SimpleITK.Resample function) the destination nifti is in the correct location.

I have points in the original source nifti space that I also want to also transform to the destination space. But when I call transform.TransformPoint(xyx) to the new space, it is wrong.

I’m doing this immediately after the first operation - it’s for sure the same transform instance, and I’ve double checked the input numbers.

Wondering if there is some hidden assumption I have that up to now has not come up, something about the coordinate systems or something else? How could something so simple possibly fail?

Any suggestions much appreciated.

EDIT: in fact to be specific

A physically identifiable point in source space is (66 48 23)

This same physical point in the destination nifti after I apply the transform is at (-5 46 -13)

Yet in code, when I call transform.TransformPoint(66,48,23), I get (-23 87 28).

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 24, 2023, 12:23pm UTC](https://discourse.itk.org/t/transform-of-points-using-euler3dtransform/5830/2 "2023-03-24T12:23:49Z")

</div>

Point transformations need the (direct) modeling transform, whereas image resampling needs the (inverse) transform which transforms points from the target (moving) image to the source (fixed) image. So if you have the resampling transform, invert it before applying it to points. See more in this [discussion](https://discourse.itk.org/t/applying-a-transform-from-tfm-file-in-itk/5566/3).

---

<div class="post-metadata">

### Author: ![jm\_nc](https://discourse.itk.org/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@jm\_nc](https://discourse.itk.org/u/jm_nc)
#### Post date: [March 24, 2023, 12:46pm UTC](https://discourse.itk.org/t/transform-of-points-using-euler3dtransform/5830/3 "2023-03-24T12:46:34Z")

</div>

Thank you, that works.

Now I reason it through, with the Resample function, I define new target bounds - a new origin, spacing, direction cosines etc. And the only logical way for this to work is for the Resample function to loop over each voxel in this new target space, and map to the correct location in the source space to see what is there and derive a new resampled value (via bspline or whatever).

So I think what happened was I had not thought about this clearly in advance, and had basically flipped a coin when I constructed my transform and this accidentally worked, and so I thought I understood. But now I see that the point in the source space is the opposite. So thanks, I learned something new today.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [March 24, 2023, 12:47pm UTC](https://discourse.itk.org/t/transform-of-points-using-euler3dtransform/5830/4 "2023-03-24T12:47:35Z")

</div>

Indeed, it is quite counter-intuitive.
