MultiTalent icon indicating copy to clipboard operation
MultiTalent copied to clipboard

RuntimeError: ITK only supports orthonormal direction cosines

Open Kirscher opened this issue 1 year ago • 4 comments

Description: I encountered a RuntimeError while running the prepare_MT_training script. The error occurs when reading NIFTI files with non-orthonormal direction cosines using SimpleITK.

Error Traceback:

multiprocessing.pool.RemoteTraceback: 
"""
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK-build/ITK/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx:2124:
ITK ERROR: ITK only supports orthonormal direction cosines.  No orthonormal definition found!
"""

Steps to Reproduce: Run the prepare_MT_training script with a dataset in the nnUNet format containing NIFTI files with non-orthonormal direction cosines. Observe the error traceback. Expected Behavior: The script should handle NIFTI files with non-orthonormal direction cosines ?

Environment: OS: Ubuntu 24.04 LTS Python version: 3.10 SimpleITK version: 2.2.1 MultiTalent version: 2.0

Additional Context: The error occurs in the read_images method of the SimpleITKIO class in the simpleitk_reader_writer.py file. A potential fix could involve catching the exception and reorienting the image to have orthonormal direction cosines.

Kirscher avatar Dec 31 '24 09:12 Kirscher

Hi, thats a really annoying one... TotalSegmentator dataset? One possibillity is to use the Nibable reader instead or to downgrade SimpleITK as suggested here

constantinulrich avatar Jan 08 '25 09:01 constantinulrich

@constantinulrich Why do you have to downgrade MITK? But if you mean realy mean MITK this problem is fixed since last release (https://git.dkfz.de/mic/mitk/-/issues/117).

From SimpleITK 2.4 on you should also be able to make it load again. SimpleITK 2.4 is based on ITK 5.4 which introduced a SetSFORM_Permissive function for the NIFTI IO class in order to allow to work arround the very strict new checking of NIFTI IO. If you set it to true and use the IO in your reader the data should be readable again. (That is what MITK does now)

rfloca avatar Jan 08 '25 10:01 rfloca

Sorry Ralf. Of course i do not mean MITK but SimpleITK. It's great to hear that the latest version resolves the issue!

constantinulrich avatar Jan 08 '25 10:01 constantinulrich

Hi! I have an issue with MRI T1 data from AGI dataset (https://openneuro.org/datasets/ds004054/versions/1.0.0): only viewer and MATLAB currently open them, but not SimpleITK or ANTsPy (ReadImage, image_read). Both are ruined with the same error (as was mentioned above): "ITK ERROR: ITK only supports orthonormal direction cosines. No orthonormal definition found!"

SimpleITK version: 2.4.0 ANTs: 0.5.3 Python: 3.10

Thanks to @dyollb from another topic https://github.com/MIC-DKFZ/nnDetection/issues/24 ! His func really helped, but with warning (idk if it important and ruin anyting later or I can just ignore). "WARNING: In /tmp/SimpleITK-build/ITK/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx, line 1997", "NiftiImageIO ...: path/name.nii has unexpected scales in sform". So, it doesn't seem to be solved in this version, or there any problem with data / environment?

more-karameli avatar Feb 28 '25 09:02 more-karameli