Skip to content

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

Description

@phcerdan

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> >

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:Python wrappingPython bindings for a classstatus:Use_Milestone_BacklogUse "Backlog" milestone instead of label for issues without a fixed deadline

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions