Skip to content
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

Closed
phcerdan opened this issue Jan 11, 2019 · 2 comments
Closed
Labels
area:Python wrapping Python bindings for a class status:Backlog Postponed without a fixed deadline
Milestone

Comments

@phcerdan
Copy link
Contributor

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

try:
    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 = 'https://data.kitware.com/api/v1/file/564a5b078d777f7522dbfaa6/download'
    urlretrieve(url, file_name)
image = itk.imread(file_name)
print(image.GetDirection())

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> >
@thewtex
Copy link
Member

thewtex commented Jan 11, 2019

+10

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

@thewtex thewtex added the area:Python wrapping Python bindings for a class label Jan 11, 2019
@stale
Copy link

stale bot commented May 21, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status:Backlog Postponed without a fixed deadline label May 21, 2019
@stale stale bot closed this as completed Jun 20, 2019
@thewtex thewtex added this to the ITK v5.1.0 milestone Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Python wrapping Python bindings for a class status:Backlog Postponed without a fixed deadline
Projects
None yet
Development

No branches or pull requests

2 participants