New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better wrapping utilities for itk.Matrix and itk.VariableSizeMatrix in Python #399

phcerdan opened this Issue Jan 11, 2019 · 1 comment


None yet
2 participants
Copy link

phcerdan commented Jan 11, 2019

Add utility wrapped functions to itk.Matrix (and itk.VariableSizeMatrix). And a str function to print them.

This would also ease the manipulation of itk matrices.
instead of having to GetVnlMatrix().set_ to set/get the data. Something like itkmatrix[0][1] = 12 would be helpful as well.

Here I show an example image.GetDirection()

Steps to Reproduce

    from urllib.request import urlretrieve
except ImportError:
    from urllib import urlretrieve
import os
import itk

# Download data (3D)
file_name = '005_32months_T2_RegT1_Reg2Atlas_ManualBrainMask_Stripped.nrrd'
if not os.path.exists(file_name):
    url = ''
    urlretrieve(url, file_name)
image = itk.imread(file_name)

Expected and actual behavior

Expected that: print(image.GetDirection()) shows the content of the matrix, instead of:

<itkMatrixPython.itkMatrixD33; proxy of <Swig Object of type 'itkMatrixD33 *' at 0x7fb35d6c5c60> >

This comment has been minimized.

Copy link

thewtex commented Jan 11, 2019


We should extend the wrapping so we can convert the native direction back and forth with a NumPy Array and call image.SetDirection(a_numpy_array).

CC: @fbudin69500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment