[Neuroimaging] nibabel apply affine and resample

valabregue romain.valabregue at upmc.fr
Thu Aug 17 11:06:50 EDT 2017

Dear all


Sorry for the basic question (this may be just a python question ...)
How do I change the affine associate to the image

img = nibabel.load('file')
img.affine = newaffine    #this give the error can't set attribute

# so I need to do
img.affine[:] = newaffine[:]

is it the correct way to change the affine ?

For what I need this work (: apply coregistration and reslice)


Second question about the resample_from_to

this take a non negligeable time to compute since it is for the all 
volume. If I only need 3 slices, is there a way to gain time by 
reslicing only the request silces ?

Many thanks


More information about the Neuroimaging mailing list