Transform of points using Euler3DTransform

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).

1 Like

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.

2 Likes

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.

1 Like

Indeed, it is quite counter-intuitive.

3 Likes