Skip to content

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

@Pfleiderer-Adrian

Description

@Pfleiderer-Adrian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:BugInconsistencies or issues which will cause an incorrect result under some or all circumstances

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions