# Inconsistency between Slicer 3.6 and Slicer 4.10.2 in mhd header

**URL:** <https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980>\
**Category:** Support\
**Created:** [August 11, 2019, 10:40am UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980 "2019-08-11T10:40:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 11, 2019, 10:40am UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/1 "2019-08-11T10:40:44Z")

</div>

Dear all,

When **open** exactly the same image (hdr + img format), and **save** into **mhd** format using Slicer 3.6 and Slicer 4.10.2 gives different . **mhd** file regarding RAI VS RPI and transformation Matrix as below and attached pic.

Slicer 3: RPI, 1,-1,1 matrix  
Slicer 4: RAI, 1,1,1 matrix

 ![41](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/2/c283282c1f24da957614439300fa77eec5849159.png)

The **paired info above becomes consistent** indeed for the raw data reading order.

But **my confusion** is, when viewing the image, **Slicer 3.6 shows differently than Slicer 4.10.2**.

So my questions are:

- Why Slicer 3 and Slicer 4 has this difference when saving .mhd? any motivation for the update?
- Why exactly the same image shows differently in Slicer 3 and 4?

Any advices are highly appreciated! Thank you very much.

Best regards, Xiaogai

---

<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:** [August 11, 2019, 12:20pm UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/2 "2019-08-11T12:20:06Z")

</div>

Slicer4 header is compliant to the metaIO standard. Both files encode the same information. Maybe Slicer3 did not read AnatomicalOrientation tag but assumed to be RAI.

We tried to provide backward compatibility (you can read old scene files with new Slicer versions), but no forward compatibility (read scene files saved with older version of Slicer). Since Slicer3 is about 10 years old, it is a wonder that it can still run on a current computer.

---

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 11, 2019, 1:15pm UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/3 "2019-08-11T13:15:50Z")

</div>

Thank you very much for your answer! I understand Slicer 3 is a bit too old, the reason still use it is due to some earlier work done years ago used Slicer 3, and now when using Slicer 4 found the difference.

Have done further test, seems to me that Slicer 4 always save mhd to **AnatomicalOrientation** RAI plus TransformationMatrix Identity, no matter what orientation was. But Slicer 3.6 indeed distinguish. Seems to me Slicer 3.6 is doing more correct things than Slicer 4. I also saved to nhdr format and compared Slicer 3.6 and Slicer 4.10, also seems Slicer 3.6 is more correct. See following capture tested with a image oriented not RAI.

Please correct me if I am wrong. Thanks a lot for your help.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/f/8f5a20b83542c6c5416aee6fd8932d1027e3b6fc.png)

---

<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:** [August 11, 2019, 2:43pm UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/4 "2019-08-11T14:43:25Z")

</div>

Those nhdr files are describing different geometry (the AP directions are flipped). I see from your original post that you loaded these from Analyze format (.img and .hdr). Unfortunately Analyze format has well documented ambiguity about orientation and has mostly fallen out of use in favor of NIfTI or NRRD.

Probably the ITK code Slicer uses to read Analyze has been debugged over the years to better match the most common conventions, but realistically there no “correct” answer given that different packages have used the format differently.

You probably need to manually correct this flipping based on some extra knowledge about the source of the image files in question.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 11, 2019, 7:44pm UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/5 "2019-08-11T19:44:02Z")

</div>

Thanks indeed very helpful!

Yes the image was loaded from Analyze format (.img and .hdr). What you said seems a good explanation why Slicer4 and Slicer4 saved to flipped image: Due to ITK Analyze reader Slicer uses are different.

Then back to the mhd format which I am most interested in. As mentioned earlier no matter what orientation the original source of image is (RAI, LPS or others), when saved into mhd using Slicer4, the mhd header always write: RAI+TransformMatrix as Identity matrix. I would guess then the .zraw image order is adjusted accordingly to its original image. I will test more to confirm. At least now it is clear Slicer3 and Slicer4 behaves differently when save to mhd file for a good reason.

Thanks again for all the valuable discussions.

---

<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:** [August 12, 2019, 1:19am UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/6 "2019-08-12T01:19:57Z")

</div>

A couple of years ago we asked Kitware (developer and maintainer of metaimage file format) about Anatomical Orientation tag and they responded that it is informational only and it [should not be used for updating direction cosines](https://issues.slicer.org/view.php?id=2173#c5796). We updated Slicer accordingly.

Interestingly, recently Kitware has revised this decision and now considering using AnatomicalOrientation tag to update axis directions after all. If Kitware ends up updating MetaIO library and mha reader/writer in ITK then Slicer’s behavior maybe become more similar to the Slicer3.

All these of course for your information only. To make your scenes usable in current Slicer, you need to follow @pieper’s recommendation above and fix up the header or apply a transform to your images as needed.

---

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 12, 2019, 8:15am UTC](https://discourse.slicer.org/t/inconsistency-between-slicer-3-6-and-slicer-4-10-2-in-mhd-header/7980/7 "2019-08-12T08:15:03Z")

</div>

Thanks a lot for all the info! Now all seems clear to me.
