I have a very basic question about affine transformation and nibabel. It seems to me that you do not need to resample data when applying an affine transformation to a dataset (of course you can but you do not need to if you want to preserve the original resolution). This problem occurs when aligning epi to anat. Typically epi data have a lower resolution and I do not want to upsample epi data to match anat data.
The most straightfoward thing to do is as follows:
# give we have an affine transformation <affine> import nibabel as nib moving = nib.load('epi.nii.gz') # load moving_vox2mm = moving.affine new_vox2mm = affine.dot(moving_vox2mm) # apply affine transform here nib.save(moving.__class__(moving.get_data(), new_vox2mm, moving.header), 'epi_al2anat.nii.gz')
In this regime, it seems you do not need to even touch the data at all. But almost all software ask you to specify a base grid to resample the data. Did I miss something here?