# Geometry all messed up in latest 5.7.0 pre-release?

**URL:** <https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072>\
**Category:** Support\
**Created:** [May 10, 2024, 7:17pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072 "2024-05-10T19:17:18Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peng\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/peng_wang/32/65535_2.png) [@Peng\_Wang](https://discourse.slicer.org/u/Peng_Wang)\
**Post date:** [May 10, 2024, 7:17pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/1 "2024-05-10T19:17:18Z")

</div>

Previously aligned volumes no longer aligned in the pre-release version. It’s kind of obvious and since it’s “pre-release” I wonder if it is a known issue.

Steps to expose the bug: load a volume and place a fiducial. Using the Orient Scalar Volume module and perform some random orientation a couple of times and you will find the volume shifted.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [May 10, 2024, 7:20pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/2 "2024-05-10T19:20:06Z")

</div>

which specific version of the preview release are you using?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 10, 2024, 7:24pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/3 "2024-05-10T19:24:53Z")

</div>

What is your reason for using the Orient Scalar Volume?  
What do you mean by “perform some random orientation”?  
What is your overall goal?

---

<div class="post-metadata">

**Author:** ![Peng\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/peng_wang/32/65535_2.png) [@Peng\_Wang](https://discourse.slicer.org/u/Peng_Wang)\
**Post date:** [May 10, 2024, 8:23pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/4 "2024-05-10T20:23:12Z")

</div>

I am using the latest Linux pre-release download from the website (2024-05-03).

I am not using Orient Scalar Volume for any particular purpose I just found out the bug can be easily observed this way. Just choose some different orientation and hit apply and sometimes the volume shifted.

I compared to load a same volume in v5.6.2 and v5.7.0 and they show different transformation matrix and scan order between these 2 versions. Sometimes after I transformed a volume and when I saved and reload the scene the volume also shifted.

I found there is a new Center of transformation option under Transform module and there is possibly some rework to the transformation and this bug could be resulting from that.

Trust me I have used Slicer for a long time. There is definitely something fundamentally wrong with current developmental release.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [May 10, 2024, 8:48pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/5 "2024-05-10T20:48:21Z")

</div>

> [@Peng\_Wang](#):
>
> Trust me I have used Slicer for a long time. There is definitely something fundamentally wrong with current developmental release.

We trust you, but you need to more concretely describe the steps, and provide screenshots of it for us to undertand and reproduce the issue. If we can’t reproduce, it is hard to fix.

---

<div class="post-metadata">

**Author:** ![Peng\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/peng_wang/32/65535_2.png) [@Peng\_Wang](https://discourse.slicer.org/u/Peng_Wang)\
**Post date:** [May 10, 2024, 8:55pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/6 "2024-05-10T20:55:47Z")

</div>

I am providing two volumes. You will find them aligned together in v5.6.2 but not in v5.7.0.

> **[SlicerTest](https://www.dropbox.com/scl/fo/ov5uhfi6n91ctfmmkkh1k/AGq11Ea5RIfPVo5WQhjSp8Q?rlkey=i81lf60sprg0v2g7wr5pn9wcy&dl=0)**
>
> Shared with Dropbox

Also I tested them in MRView from MRTrix and they also aligned.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 12, 2024, 11:53am UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/7 "2024-05-12T11:53:22Z")

</div>

If you use NIFTI format then all bets are off. In this format the image oroentation can be defined in redundant and inconsistent ways, which is interpreted differently in each software. It is really a shame that we need to deal with such basic issues, but many people in the neuroimaging community just uses a few software, so they are not aware of these serious issues around NIFTI; and many newcomers to the medical imaging field don’t know just how bad NIFTI is, so it remains widely used and it wastes everyone’s time.

Slicer uses ITK toolkit to read NIFTI images and so it will load such images the same way as every other ITK-based software. It seems that you would expect ITK to load your images differently, so the best would be to post it to the [ITK forum](https://discourse.itk.org). They will explain why ITK loads your images differently compared to MRTrix. Maybe invite MRTrix developers to the discussion, too, and let them come to an agreement. If major imaging libraries resolved inconsistencies in NIFTI images the same way then NIFTI users would suffer less.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [May 12, 2024, 2:27pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/8 "2024-05-12T14:27:08Z")

</div>

Thanks for reporting @Peng_Wang - I can reproduce this by comparing 5.6.1 to recent preview build. In this case I don’t think nifti is to blame, but something has changed in Slicer, presumably with the latest version of ITK.

It’s a serious regression, so we should get to the bottom of this asap.  
I’ve filed an issue here:

> <https://github.com/Slicer/Slicer/issues/7742>
>
> \## Summary
> 
> Running the CLI module cases the result volume to be in the wrong …place.
> 
> \## Steps to reproduce
> 
> 1) Download Sample data (MRHead)
> 2) Run OrientScalarVolume with default LPS output into new volume
> 3) Put put one volume in foreground and one in background and see the shift
> 
> \## Environment
> \- Slicer version: Slicer-5.7.0-2024-05-10, does not happen in 5.6.1
> \- Operating system: tested on mac

It’s easy to reproduce and the CLI uses nrrd, so there’s something else going on.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/8/e8813621ea170e1ac4fc446f1c9020b1e3020b7b.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 12, 2024, 2:32pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/9 "2024-05-12T14:32:52Z")

</div>

> [@Peng\_Wang](#):
>
> I am providing two volumes. You will find them aligned together in v5.6.2 but not in v5.7.0.

While all the problems with NIFTI format still holds, I agree that in this case something else is going on with `IntraOp2T1_Warped`. The file uses a left-handed image coordinate system, which is uncommon, but it is still valid. It gets normalized to a right-handed coordinate, which would be good, but this normalization seems to be computed incorrectly.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 12, 2024, 2:37pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/10 "2024-05-12T14:37:42Z")

</div>

The culprit is probably this change:

> <https://github.com/Slicer/Slicer/pull/7627/files>
>
> \* Automatically flip left handed volumes when loading into 3D Slicer to make the…m compatible with all algorithms. Fixes flipped normals in segmentation node for left handed volumes.
> 
> See related discussion here : 
> https://discourse.slicer.org/t/slicer-segmentation-inverted-normals-for-closed-surface-representation/34762

I should have suspected that it was wrong, because images should only be ever transformed with homogeneous transformation matrices, never with just flipping.

---

<div class="post-metadata">

**Author:** ![Peng\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/peng_wang/32/65535_2.png) [@Peng\_Wang](https://discourse.slicer.org/u/Peng_Wang)\
**Post date:** [May 12, 2024, 10:15pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/11 "2024-05-12T22:15:35Z")

</div>

The problem is not only with the volume `IntraOp2T1_Warped`. Sometimes when I load back the volume saved by Slicer itself it also shifted. Also as shown by Pieper above you can reproduce the bug using Orient Scalar Volume not dealing with any on-disk files.

PS. Also I tried with the latest ITK-SNAP 4.2 (Apr 22, 2024) it also displayed the volumes correctly.

PPS. I remember this problem only showed in recent build. Using the download page url offset parameter I am trying to pinpoint the problematic build:

it’s somewhere in between [revision 32753 built 2024-03-15] and [revision 32789 built 2024-04-02].

As I suspected it’s also when the “Center of Transformation” started to show up in the Transform module.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 13, 2024, 11:58am UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/12 "2024-05-13T11:58:37Z")

</div>

The problem is the change that I pointed out [above](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/10). When an image with left-handed IJK coordinate system is encountered then the K axis is automatically flipped to turn it into a right-handed coordinate system. However, the computation of the new image origin was incorrect. I’ll submit a pull request with the fix today.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 13, 2024, 12:52pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/13 "2024-05-13T12:52:25Z")

</div>

The fix is available in this pull request:

> <https://github.com/Slicer/Slicer/pull/7746>
>
> Fix regression introduced in https://github.com/Slicer/Slicer/pull/7627 that ima…ge origin is not computed correctly when flipping K axis of an image to make it right-handed.
> 
> Fixes issue discussed in https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/12

Probably it will be available in the Slicer Preview Release within a few days.

---

<div class="post-metadata">

**Author:** ![Peng\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/peng_wang/32/65535_2.png) [@Peng\_Wang](https://discourse.slicer.org/u/Peng_Wang)\
**Post date:** [May 13, 2024, 5:52pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/14 "2024-05-13T17:52:47Z")

</div>

When I looked at my other problematic volumes they are indeed left-handed too. And when Slicer save them they remained left-handed. So thank you, this should fix it.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 13, 2024, 6:17pm UTC](https://discourse.slicer.org/t/geometry-all-messed-up-in-latest-5-7-0-pre-release/36072/15 "2024-05-13T18:17:14Z")

</div>

The fix has been merged, so Slicer Preview Release that is downloaded tomorrow or later will include it.
