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

Gauging interest on spatial transforms #654

Closed
oesteban opened this issue Jul 31, 2018 · 4 comments
Closed

Gauging interest on spatial transforms #654

oesteban opened this issue Jul 31, 2018 · 4 comments

Comments

@oesteban
Copy link
Contributor

I'm about to start working on python (mostly numpy) based geometric transformation of 3D images. I feel nibabel could be the best host to a new module nibabel.transforms.

I would start by implementing affine transforms (which is almost there already with resample_from_to) and free-deformation fields (e.g. generated by ANTs registration).

Next steps would include taking in collapsed transforms (hdf5), and also parametric transforms (e.g. BSpline).

WDYT?

@oesteban
Copy link
Contributor Author

oesteban commented Aug 1, 2018

Here there is an example: master...oesteban:enh/transforms. This code makes it easy to apply an affine transform on images:

import nibabel as nb
ref = nb.load('image.nii.gz')
xfm = nb.transform.Affine([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
xfm.reference = ref  # Set a reference image
moved = xfm.resample(ref)  # Resample ref into reference space through xfm
moved.to_filename('moved_4mm_image.nii.gz')

The purpose of the module would also include reading linear and nonlinear transforms from different formats (mainly FSL, ITK/ANTs, SPM, FreeSurfer, etc.).

cc @effigies

@effigies
Copy link
Member

effigies commented Aug 1, 2018

This looks useful. I've done some work already with FreeSurfer's LTA format in #565.

So a Transform is defined to be RAS-RAS?

@oesteban
Copy link
Contributor Author

oesteban commented Aug 1, 2018

#565 is definitely related to this.

In principle, Transforms are Voxel-to-voxel. However, they must have an internal parameterization of the transform. That internal model should be defined to be RAS-RAS and accessible through the map_point method.

@oesteban
Copy link
Contributor Author

oesteban commented Aug 1, 2018

Sorry for the second post. For RAS-RAS transforms with the xfm object of my example would be:

>>> xfm.map_point([10.0, -10.0, 20.0])
array([14.0, -10.0, 20.0])

However, the xfm.resample method needs to work voxel-to-voxel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants