ITK icon indicating copy to clipboard operation
ITK copied to clipboard

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

Open Pfleiderer-Adrian opened this issue 2 years ago β€’ 6 comments

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 avatar Jan 09 '24 14:01 Pfleiderer-Adrian

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.

github-actions[bot] avatar Jan 09 '24 14:01 github-actions[bot]

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

dzenanz avatar Jan 09 '24 16:01 dzenanz

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.

Pfleiderer-Adrian avatar Jan 09 '24 16:01 Pfleiderer-Adrian

a simple check could be implemented

Contributions are always welcome.

dzenanz avatar Jan 09 '24 18:01 dzenanz

Contributions are always welcome.

I will implement that tomorrow. :)

Pfleiderer-Adrian avatar Jan 09 '24 18:01 Pfleiderer-Adrian

a simple check could be implemented

Contributions are always welcome.

done. #4390 Improvement suggestions are welcome.

Pfleiderer-Adrian avatar Jan 10 '24 12:01 Pfleiderer-Adrian