Exporting file to .nii and .nii.gz changes the transform in the header

I have an .mrb with multiple files, from which I export one to .nii.gz

When I load the file again, it doesn’t match the original file because it’s affine is changed (I loaded both files in Python with SimpleITK and saw that the voxel values were identical, only the origin and direction have changed)

This does not happen when I export this file to .nrrd.

I tried this with multiple versions of Slicer and it always kept happening.

Unfortunately I’m not allowed to share the file.

There are also no errors or warnings when exporting this file. Is there a way to debug this?

We’ve noticed this with other data too. The nifti1 headers that are used by default use 32bit floats for orientation and there can be rounding error. Avoid nifti if you can.

Here’s a related discussion:

1 Like

ok. I have three follow-up questions

  1. Is there a way of determining when the mismatch might occur?
  2. Would it make sense to export to nifti2?
  3. Could you elaborate on ‘Avoid nifti if you can?’

PR 6454 should fix this. Give it a try and report whether the problem still occurs.

PR 6454 is now part of preview release.