Hi! I found that doing this:
DisplacementFieldNumpy = np.ones(
(3, 4, 100, 100))
PyBuffer = itk.PyBuffer[VectorImageType]
DisplacementField = PyBuffer.GetImageFromArray(DisplacementFieldNumpy)
yields
RuntimeError: Size mismatch of image and Buffer.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 17, in __PYTHON_EL_eval
File "/home/edgar/.local/lib/python3.10/site-packages/itk/itkPyBufferPython.py", line 11790, in GetImageFromArray
imageView = itkPyBufferIVF33.GetImageViewFromArray(ndarr, is_vector, need_contiguous=False)
File "/home/edgar/.local/lib/python3.10/site-packages/itk/itkPyBufferPython.py", line 11760, in GetImageViewFromArray
imgview = itkPyBufferIVF33._GetImageViewFromArray(ndarr, ndarr.shape[::-1], 1)
SystemError: <built-in function itkPyBufferIVF33__GetImageViewFromArray> returned a result with an exception set
If the first line is changed to
DisplacementFieldNumpy = np.ones(
(len(vti.dimensions), nz, 100, 100), dtype=np.float32)
the rest works.
The message should probably be one of those which tell people that their data type is wrong.
Python 3.10.10
Numpy 1.24.2
From pip:
itk 5.3.0
itk-core 5.3.0
itk-elastix 0.15.0
itk-filtering 5.3.0
itk-io 5.3.0
itk-meshtopolydata 0.10.0
itk-minimalpathextraction 1.2.4
itk-numerics 5.3.0
itk-registration 5.3.0
itk-segmentation 5.3.0
itk-strain 0.3.6
itk-tubetk 1.3.4
itkwidgets 0.32.5
numpy 1.24.2
Thank you for ITK!