Effect of setting orientation on CenteredTransformInitializer

Hello,

I am a complete beginner in image registration, much more I am lacking experience in debugging and tuning a registration pipeline.

Goal : Translate a head CT to the center and rotate based on a CT template image. So let’s says moving.nii is my moving image and fixed.nii is the template, in the end I would like moving.nii to be of the same size as before the registration, in the common RAI space, centered and rotated. Even as a beginner, I think it’s basic rigid registration, should be easy… well

First thing I noticed is that moving.nii and fixed.nii have different orientations :

moving_image.GetDirection()
(1.0,
0.0,
0.0,
0.0,
0.9914448880836518,
0.13052598937071197,
0.0,
-0.1305259893385041,
0.9914448880794114)

fixed_image.GetDirection()
(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0)

Accordingly I decide to set a common space for both :

change orientation to RAI

fixed_image.SetDirection(np.eye(3, 3).flatten())
moving_image.SetDirection(np.eye(3, 3).flatten())

Am I wrong doing this, is there anything incorrect about this ?

After setting the orientation, I tried a Centered Transform :

initial_transform = sitk.CenteredTransformInitializer(fixed_image,
moving_image,
sitk.Euler3DTransform(),
sitk.CenteredTransformInitializerFilter.GEOMETRY)

moving_resampled = sitk.Resample(moving_image,
fixed_image,
initial_transform,
sitk.sitkLinear,
0.0,
moving_image.GetPixelID())

For a reason I don’t understand, the volume are aligned but relatively inverted (one is anterior-superior and the other one superior-anterior). Though, removing the previous orientation change solves this problem. I would like to get someone’s point of view on this, I am pretty sure to be doing something wrong :slight_smile:

Thanks !

Direction indicates orientation of image in physical space. If you change direction, so will image’s orientation in space. That is causing your inversion.

ITK handles weird orientations, so if you skip the step of changing directions, it should work fine - or at least better.

Thanks !

That makes sense ! I am mistaking the image orientation and the orientation of the patient within the space.
When changing the orientation, the image origin stays unchanged right ? and becomes the origin of the new space ?

Thank you

Correct. So just inverting the orientation (direction) inverts the image and moves it to the other side of the origin.

1 Like