Direction loosing negative sign

I have a nifti file, which if I read with nibabel, and print the affine matrix it looks like this:

[[-0.28 0. 0. 0. ]
[ 0. -0.28 0. 0. ]
[ 0. 0. 0.28 0. ]
[ 0. 0. 0. 1. ]]

How can I get the same matrix from simpleitk? I tried to get the Direction Matrix and multiply it with the Spacing, than adding the extra row and column. Howewer the result looses the negative signs of the first two nonzero coordinates. How can I receive those as negative from simpleitk?

Hello @Franciska,

Nifti uses an RAS coordinate system and ITK/SimpleITK use an LPS one which is why there is a difference in the axis signs. For a detailed description of the various commonly used coordinate systems and how to convert between them see the 3D slicer documentation on coordinate systems.

1 Like

Is there any way to get the Oriantation of the image in one of these system?

My task would be to Orient the Image into SPL if its not already that way. I use

sitk.DICOMOrient(image, ‘SPL’)

which swap the first and the last axis in case of every image, however, if my image is already SPL I would like it to stay that way.

Hello @Franciska,

If the image is already in SPL calling the method will not change it, so you can just iterate over all images and call the method.

1 Like

thank you!