Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] ITK ERROR: ITK only supports orthonormal direction cosines. No orthonormal definition found! (SimpleITK >= 2.1.0) #24

Closed
alexandreroutier opened this issue Aug 18, 2021 · 20 comments

Comments

@alexandreroutier
Copy link

Hello everyone,

Thanks for this great tool :)

💀 Bug

When using nndet_prep [task] --full-check command, the following error occured:

File "<nnDetection>/nndet/utils/check.py", line 213, in _full_check
	img_itk_seq = [load_sitk(cp) for cp in case_paths]
File "<nnDetection>/nndet/utils/check.py", line 213, in <listcomp>
	img_itk_seq = [load_sitk(cp) for cp in case_paths]
File "<nnDetection>/nndet/io/itk.py", line 107, in load_sitk
	return sitk.ReadImage(str(path), **kwargs)
File "<CondaEnv>/lib/python3.9/site-packages/SimpleITK/extra.py", line 346, in ReadImage
	return reader.Execute()
File "<CondaEnv>/lib/python3.9/site-packages/SimpleITK/SimpleITK.py", line 8015, in Execute
	return _SimpleITK.ImageFileReader_Execute(self)
RuntimeError: Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK-build/ITK/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx:1980:
ITK ERROR: ITK only supports orthonormal direction cosines.  No orthonormal definition found!

This was noticed with the nnUNet framework when mixing different versions of SimpleITK an issue was raised (SimpleITK/SimpleITK#1433).

When using SimpleITK 2.0.2, this error does not occur. This seems to be due to recent changes with ITK when handling Nifti headers (see InsightSoftwareConsortium/ITK#2674 for further details and ongoing conversation).

I would think that freezing SimpleITK to SimpleITK < 2.1.0 would temporarily solve the issue.

Best

Environment

Environment Information:

----- PyTorch Information -----
PyTorch Version: 1.9.0
PyTorch Debug: False
PyTorch CUDA: 10.2
PyTorch Backend cudnn: 7605
PyTorch CUDA Arch List: ['sm_37', 'sm_50', 'sm_60', 'sm_61', 'sm_70', 'sm_75', 'compute_37']
PyTorch Current Device Capability: (7, 0)
PyTorch CUDA available: True

 


----- System Information -----
System NVCC: nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

 

System Arch List: None
System OMP_NUM_THREADS: 1
System CUDA_HOME is None: True
System CPU Count: 6
Python Version: 3.9.6 (default, Jul 30 2021, 16:35:19)
[GCC 7.5.0]

 


----- nnDetection Information -----
det_num_threads 12
det_data is set True
det_models is set True```
@mibaumgartner
Copy link
Collaborator

mibaumgartner commented Aug 19, 2021

Hi @alexandreroutier,

thanks for the detailed Issue, I'll fix the version of SimpleITK temporarily.
Did you encounter the error in the official examples or on a private data set?

Best,
Michael

@alexandreroutier
Copy link
Author

Hi @alexandreroutier,

thanks for the detailed Issue with all the background info, I'll fix the version of SimpleITK temporarily.
Did you encounter the error in the official examples or on a private data set?

Best,
Michael

Indeed, I forgot to mention: this error was encounter on a private data set.

Best,
Alexandre

@mibaumgartner
Copy link
Collaborator

Hi @alexandreroutier ,

I updated the sitk version inside the requirements file for now.

I'm planning to rerun the preprocessing of the official data sets sometime in the future and will check if the latest version of sitk creates any Issues there. If it goes well I will probably unlock it / bump to the latest version again.

Best,
Michael

@pedrohbd
Copy link

pedrohbd commented Jan 12, 2022

Hi, same error here. It happens when I use the TorchIO library (that uses SimpleITK 2.1.1 internally). Cant change the SimpleITK version or the TorchIO wont work. Any solutions?

@mibaumgartner
Copy link
Collaborator

Hi @pedrohbd,
Can you use a different TorchIO version? If I remember correctly, the ITK version of TorchIO changes between releases. Otherwise you might need to look deeper into your data to fix it.

@malteekj
Copy link

I know this is old, but it is still a problem in simpleitk 2.2.0. After searching for a while, I realized the problem can stem from the qform_code and sform_code having different codes (qform is for using quaternion and sform is for using the affine matrix). A solution can be to play around with these and ensure that they conform with the definition of the coordinate system for your image.

A good resource to understand this better: https://brainder.org/2012/09/23/the-nifti-file-format/

@kabbas570
Copy link

@alexandreroutier the lower versions are not available, and still getting the same error.

@alexandreroutier
Copy link
Author

Hi @kabbas570,

Which version of Python are you using? On my side, it was Python 3.7 / 3.8 and this workaround is working well so far. Maybe this can help with your specific installation.

In the meantime, it seems by the message of @malteekj on SimpleITK/SimpleITK#1433 that the error may still exist in latest version of SimpleITK.

Best,
Alex

@kabbas570
Copy link

kabbas570 commented Dec 5, 2022

@alexandreroutier thanks for your reply; I am using Python 3.9.7. Yes, it still exists, which limits the usage of SimpleITK for . nii files.

@machur
Copy link
Contributor

machur commented Jan 30, 2023

This error does not occur anymore for SimpleITK version 2.2.1 (tested with Python 3.10). I upgraded from 2.1.1.2 as I described in issue MIC-DKFZ/HD-BET#25

@N1h1l1sT
Copy link

N1h1l1sT commented Feb 17, 2023

I'm actually experiencing the same issue with version 2.2.1 on Python 3.10:

Python version: 3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)]
SimpleITK version: 2.2.1

@machur
Copy link
Contributor

machur commented Feb 17, 2023

I wish I could double-check the versions I specified, but, unfortunately, I don't have the data anymore to reproduce this issue.

@huangs-i2r
Copy link

data1.nii.gz
data2.nii.gz

Hi there, I have the same problem. My environment is python 3.8.11, SimpleITK 2.2.1.
Attached are two nii.gz files, data1 and data2, they are almost the same, but data1.nii.gz is OK to be opened by sitk.ReadImage() while data2.nii.gz will bump into the said error, a bit tricky.

@keesh0
Copy link

keesh0 commented May 28, 2023

This seems to be fixed when I moved from Simple ITK 2.2.0 to 2.2.1 (under Python 3.8.3).
All is well.

@pangyuteng
Copy link

For those locked at py 3.6, you can try downgrading to v2.0 (pip install SimpleITK==2.0.0). I was able to load the nifti i had issue loading in v2.1.1.2.

@Wingseter
Copy link

In Simple ITK version 2.1.1.1 and 2.1.1, the following error occurred.
As mentioned by keesh0 , I changed the version to 2.2.1, and it worked without any issues.

@ThreeStones1029
Copy link

In Simple ITK version 2.1.1.1 , the same error occurred.
I changed the version to 2.2.0, and it worked without any issues.

@sydat2701
Copy link

I'm actually experiencing the same issue with version 2.2.1 on Python 3.10:

Python version: 3.10.8 | packaged by conda-forge | (main, Nov 24 2022, 14:07:00) [MSC v.1916 64 bit (AMD64)]
SimpleITK version: 2.2.1

Hi, I got the same problem. Did you solve it?

@keesh0
Copy link

keesh0 commented Oct 2, 2024

It's been awhile since I last looked at this.
But upgrading from Simple ITK 2.2.0 to 2.2.1 (under Python 3.8.3) worked.

orthonormal direction cosines.

@DsLiuCase
Copy link

I replace my package,and using pip install SimpleITK==2.0.2. It works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests