Created
December 1, 2015 19:48
-
-
Save arokem/0aab282a7287245a7e78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dipy.align.imaffine import AffineMap | |
def resample_volume(moving, static): | |
""" | |
Resample a nifti image into the space of another nifti image | |
Parameters | |
---------- | |
moving : Nifti1Image | |
The 'source' image. | |
static : Nifti1Image | |
The 'target' image. | |
Returns | |
------- | |
resampled_img : Nifti1Image | |
The source data in the target space, with the target affine | |
""" | |
affine_map = AffineMap(np.eye(4), | |
static.shape, static.affine, | |
moving.shape, moving.affine) | |
resampled = affine_map.transform(moving.get_data()) | |
return nib.Nifti1Image(resampled, static.get_affine()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment