Unable to load images with Umlauts in filepath (ITK / SimpleITK)
Bug Description: I encountered an issue while attempting to load images using the ITK / SimpleITK framework in my Python script. The traceback indicates that the problem arises when attempting to create an IO object for reading an image file that contains Umlauts (Γ€, ΓΌ, ΓΆ) in its path. The relevant part of the traceback is as follows:
...
File [...]\utils\prepare_data.py", line 202, in convert_mha_to_nii
img = itk.imread(path_to_image)
File "[...]\packages\lib\site-packages\itk\support\extras.py", line 1293, in imread
reader = template_reader_type.New(**kwargs)
File "[...]\packages\lib\site-packages\itk\support\template_class.py", line 661, in New
return self._NewImageReader(
File "[...]\packages\lib\site-packages\itk\support\template_class.py", line 160, in _NewImageReader
raise RuntimeError(
RuntimeError: Could not create IO object for reading file "[ Path with Umlaut ]"
Steps to Reproduce: Load a image file with the:
- ITK-Framework: itk.imread("[ Path with Umlaut ]")
- SimpleITK-Framework: sitk.ReadImage("[ Path with Umlaut ]")
Expected Behavior: The ITK framework should be able to read images regardless of whether the file path contains Umlauts or not. A successful image loading operation is expected. Alternatively, providing a more descriptive error message indicating that the path cannot be read due to special characters, such as Umlauts, would be helpful for users to understand and address the issue.
Actual Behavior: The execution fails with a RuntimeError indicating that an IO object cannot be created for reading the image file.
Additional Information: Operating System: Windows 11 ITK Version: 5.3.0 Simple-ITK Version: 2.3.1 Python Version: 3.9.0
Note: The issue does not related to an incorrect path, as the error does not indicate a path error. Rather, it suggests that the ITK framework encounters difficulties creating an IO object when the file path contains Umlauts.
Thank you for your attention to this matter.
Thank you for contributing an issue! π
Welcome to the ITK community! π€πβοΈ
We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. π Also, please check existing open issues and consider discussion on the ITK Discourse. π
This is an automatic message. Allow for time for the ITK community to be able to read the issue and comment on it.
This looks like a duplicate of #2693. Possibly also related: #540.
This looks like a duplicate of #2693. Possibly also related: #540.
True. I unfortunately did not find this before. I understand that fully resolving the issue is too complex and probably not worth the effort for the small number of users. However, a simple check could be implemented, examining the path for these special characters. If characters are not included in ASCII-US, a specific error message would be great.. This would allow for a quicker workaround by simply renaming the path manually.
a simple check could be implemented
Contributions are always welcome.
Contributions are always welcome.
I will implement that tomorrow. :)
a simple check could be implemented
Contributions are always welcome.
done. #4390 Improvement suggestions are welcome.