InsightSoftwareConsortium / InsightSoftwareConsortium/ITK
Raise error instead of warning when writing image with non-orthogonal direction matrix to nifti.
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 748
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 64
Description
### Description
When saving an sitk.Image to NIFTI, the direction matrix get coerced to an orthogonal matrix. A warning is raised, but in my opinion this behavior is rather unexpected. This can lead to subtle and hard-to-trace bugs if the direction matrix was not orthogonal. Therefore, I suggest to raise an error in this case. This backwards-incompatible change could be introduced in `itk 6.0`.
### Expected behavior
An error should be raised, e.g.:
```
Direction matrix is not orthogonal. Writing to NIfTI not supported.
```
If the user want to save the image as NIfTI, the user should also explicitly modify the direction matrix such that [itk can work with it](https://discourse.itk.org/t/saving-non-orthogonal-volume-in-nifti-format/2760/22).
### Actual behavior
Currently, only a warning is being raised, see https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx#L2335.
```
Non-orthogonal direction matrix coerced to orthogonal.
```
### Additional Information
- see https://github.com/SimpleITK/SimpleITK/issues/2360 for a code example in SimpleITK
- itk version 5.4.4.
Contributor guide
Assessment
This issue has not been assessed yet.