Missing exception handling

Slicer is not able to load a malformed nii.gz file in 5.6.1, which is possible with version 4.8. Missing error message: only visible in logging window and cryptic. A meaningful error message or more tolerant loading would be welcome (malformed files will occur again and again).

“Slicer has caught an application error, please save your work and restart.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at https://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: /work/Stable/Slicer-0-build/ITK/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx:2100:\nITK ERROR: ITK only supports orthonormal direction cosines. No orthonormal definition found!”

Thanks for reporting this. It’s probably good that newer versions of ITK are more careful about interpreting nifti variants, as this has been an ongoing source of confusion. I don’t think we should push back in that, but instead offer a more robust nifti loader that as you suggest is more user-friendly in pointing out bad data and offering loading solutions. This would be a chance to handle other variants nifti types, like time series.

I did a prototype of a python-based reader for diffusion MRI that could be used as a starting point. It would be great if people who rely on nifti in their workflows could pick up and generalize this to support their needs. Perhaps even a dedicated module like RawImageGuess or ImageStacks would help people deal with some not-uncommon issues like left-right flip, qform/sform disagreement, or making use of intent types.