ITK
ITK copied to clipboard
Bug: itk.orient_image_filter breaks in 6.0
Description
In 5.4, the code
import itk
import numpy as np
itk.orient_image_filter(
itk.GetImageFromArray(np.zeros((20, 20, 20))),
desired_coordinate_orientation=itk.ITKCommonBasePython.itkSpatialOrientationEnums.ValidCoordinateOrientations_ITK_COORDINATE_ORIENTATION_RAS,
use_image_direction=True)
works to normalize image orientation.
In 6.0, it throws
Python 3.13.3 (main, Apr 8 2025, 13:54:08) [Clang 17.0.0 (clang-1700.0.13.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from itk.ITKCommonBasePython import itkSpatialOrientationAdapter
... import itk
... import numpy as np
... itk.orient_image_filter(
... itk.GetImageFromArray(np.zeros((20, 20, 20))),
... desired_coordinate_orientation=itk.ITKCommonBasePython.itkSpatialOrientationEnums.ValidCoordinateOrientations_ITK_COORDINATE_ORIENTATION_RAS,
... use_image_direction=True)
...
Traceback (most recent call last):
File "<python-input-0>", line 4, in <module>
itk.orient_image_filter(
~~~~~~~~~~~~~~~~~~~~~~~^
itk.GetImageFromArray(np.zeros((20, 20, 20))),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
desired_coordinate_orientation=itk.ITKCommonBasePython.itkSpatialOrientationEnums.ValidCoordinateOrientations_ITK_COORDINATE_ORIENTATION_RAS,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
use_image_direction=True)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/support/helpers.py", line 194, in image_filter_wrapper
return image_filter(*args, **kwargs)
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/itkOrientImageFilterPython.py", line 2674, in orient_image_filter
instance = itk.OrientImageFilter.New(*args, **kwargs)
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/support/template_class.py", line 750, in New
return self[list(keys)[0]].New(*args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/itkOrientImageFilterPython.py", line 1122, in New
template_class.New(obj, *args, **kargs)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/support/template_class.py", line 815, in New
itk.set_inputs(self, args, kargs)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/support/extras.py", line 1667, in set_inputs
attrib(itk.output(value))
~~~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/thomasgreer/icon_games/venv3/lib/python3.13/site-packages/itk/itkOrientImageFilterPython.py", line 1020, in SetDesiredCoordinateOrientation
return _itkOrientImageFilterPython.itkOrientImageFilterID3ID3_SetDesiredCoordinateOrientation(self, newCode)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
TypeError: in method 'itkOrientImageFilterID3ID3_SetDesiredCoordinateOrientation', argument 2 of type 'itkAnatomicalOrientation'
Reproducibility
This reproduces 100% of the time
Versions
Regression specific to 6.0a1
Environment
python3.13, 3.12, 3.11 itk 6.0a1