Bug in itk.image_duplicator?

I load an image like

import itk
img = itk.imread("/path/to/image.nii.gz")
print(type(img))
print(img.shape)

The type is a itk.itkImagePython.itkImageF3.
The shape is (310,310,310).

Then I duplicate the image: img_t = image_duplicator(img)
The shape is (310,310) and the type itk.itkPyBufferPython.NDArrayITKBase.

Does this make sense? What am I doing wrong?

I also tried:

import copy
img_t = copy.deepcopy(img)

This leads to following error:

File “i2i\translate_image.py”, line 78, in translate
img_t = copy.deepcopy(img)
File “C:\Python36\lib\copy.py”, line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File “C:\Python36\lib\copy.py”, line 280, in _reconstruct
state = deepcopy(state, memo)
File “C:\Python36\lib\copy.py”, line 150, in deepcopy
y = copier(x, memo)
File “C:\Python36\lib\copy.py”, line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File “C:\Python36\lib\copy.py”, line 169, in deepcopy
rv = reductor(4)
TypeError: can’t pickle SwigPyObject objects

and img_t = itk.image_from_array(itk.array_view_from_image(img)), leading to following error:

File “i2i\translate_image.py”, line 75, in translate
img_t = itk.image_from_array(itk.array_view_from_image(img))
File “E:\Develop\Segmania.venv\lib\site-packages\itk\support\extras.py”, line 325, in GetArrayViewFromImage
image_or_filter, “GetArrayViewFromImage”, keep_axes, update, ttype
File “E:\Develop\Segmania.venv\lib\site-packages\itk\support\extras.py”, line 296, in _GetArrayFromImage
raise RuntimeError(“No suitable template parameter can be found.”)
RuntimeError: No suitable template parameter can be found.

btw: I am using itk 5.2.0.post2, Python 3.6, Windows

sorry. it turned out to be a bug in my code (translate was calling itself recursively …)

I was just about to say I can’t reproduce it:

C:\Users\Dzenan>python
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import itk
>>> itk.__version__
'5.2.1'
>>> img = itk.imread("C:/a/cbct.nrrd")
>>> print(type(img))
<class 'itk.itkImagePython.itkImageSS3'>
>>> print(img.shape)
(433, 667, 667)
>>> img_t = itk.image_duplicator(img)
>>> print(img_t.shape)
(433, 667, 667)