Anisotropic to isotropic voxel conversion
Resample data from anisotropic to isotropic voxel size
Parameters : | data : array, shape (I,J,K) or (I,J,K,N)
affine : array, shape (4,4)
zooms : tuple, shape (3,)
new_zooms : tuple, shape (3,)
order : int, from 0 to 5
|
---|---|
Returns : | data2 : array, shape (I,J,K) or (I,J,K,N)
|
Notes
It is also possible with this function to resample/reslice from isotropic voxel size to anisotropic or from isotropic to isotropic or even from anisotropic to anisotropic, as long as you provide the correct zooms (voxel sizes) and new_zooms (new voxel sizes). It is fairly easy to get the correct zooms using nibabel as show in the example below.
Examples
>>> import nibabel as nib
>>> from dipy.align.aniso2iso import resample
>>> from dipy.data import get_data
>>> fimg=get_data('aniso_vox')
>>> img=nib.load(fimg)
>>> data=img.get_data()
>>> data.shape
(58, 58, 24)
>>> affine=img.get_affine()
>>> zooms=img.get_header().get_zooms()[:3]
>>> zooms
(4.0, 4.0, 5.0)
>>> new_zooms=(3.,3.,3.)
>>> new_zooms
(3.0, 3.0, 3.0)
>>> data2,affine2=resample(data,affine,zooms,new_zooms)
>>> data2.shape
(77, 77, 40)