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

Unable to load images with Umlauts in filepath (ITK / SimpleITK) #4388

Open
Pfleiderer-Adrian opened this issue Jan 9, 2024 · 6 comments
Open
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Comments

@Pfleiderer-Adrian
Copy link

Pfleiderer-Adrian commented Jan 9, 2024

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.

@Pfleiderer-Adrian Pfleiderer-Adrian added the type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances label Jan 9, 2024
Copy link

github-actions bot commented Jan 9, 2024

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.

@Pfleiderer-Adrian Pfleiderer-Adrian changed the title Unable to Load Images with Umlauts in the Filepath (ITK / SimpleITK) Unable to load images with Umlauts in filepath (ITK / SimpleITK) Jan 9, 2024
@dzenanz
Copy link
Member

dzenanz commented Jan 9, 2024

This looks like a duplicate of #2693. Possibly also related: #540.

@Pfleiderer-Adrian
Copy link
Author

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.

@dzenanz
Copy link
Member

dzenanz commented Jan 9, 2024

a simple check could be implemented

Contributions are always welcome.

@Pfleiderer-Adrian
Copy link
Author

Contributions are always welcome.

I will implement that tomorrow. :)

@Pfleiderer-Adrian
Copy link
Author

a simple check could be implemented

Contributions are always welcome.

done. #4390
Improvement suggestions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances
Projects
None yet
Development

No branches or pull requests

2 participants