# Direction loosing negative sign

**URL:** https://discourse.itk.org/t/direction-loosing-negative-sign/6371
**Category:** Beginner Questions
**Tags:** affine, affinematrix, orientation, simpleitk
**Created:** [December 21, 2023, 5:43pm UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371 "2023-12-21T17:43:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Franciska](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.itk.org/u/Franciska)
#### Post date: [December 21, 2023, 5:43pm UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371/1 "2023-12-21T17:43:06Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [December 21, 2023, 5:56pm UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371/2 "2023-12-21T17:56:44Z")

</div>

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](https://slicer.readthedocs.io/en/latest/user_guide/coordinate_systems.html).

---

<div class="post-metadata">

### Author: ![Franciska](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.itk.org/u/Franciska)
#### Post date: [January 16, 2024, 8:05am UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371/3 "2024-01-16T08:05:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [January 16, 2024, 2:25pm UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371/4 "2024-01-16T14:25:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Franciska](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.itk.org/u/Franciska)
#### Post date: [January 16, 2024, 2:29pm UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371/5 "2024-01-16T14:29:18Z")

</div>

thank you!

---

<div class="post-metadata">

### Author: ![Franciska](https://discourse.itk.org/letter_avatar_proxy/v4/letter/f/b38774/32.png) [@Franciska](https://discourse.itk.org/u/Franciska)
#### Post date: [March 13, 2024, 11:53am UTC](https://discourse.itk.org/t/direction-loosing-negative-sign/6371/6 "2024-03-13T11:53:45Z")

</div>

But is there any way to check what orientation its in?
