-
Notifications
You must be signed in to change notification settings - Fork 264
Open
Description
Currently (after merge of #255):
In [1]: from os.path import dirname, join
In [2]: import nibabel as nib
In [4]: data_dir = join(dirname(nib.__file__), 'tests', 'data')
In [6]: anat = nib.load(join(data_dir, 'anatomical.nii'))
In [7]: anat.shape
Out[7]: (33, 41, 25)
In [8]: func = nib.load(join(data_dir, 'functional.nii'))
In [9]: func.shape
Out[9]: (17, 21, 3, 20)
In [10]: from nibabel.processing import resample_from_to
In [11]: resample_from_to(func, anat)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-11-0be28b6142bd> in <module>()
----> 1 resample_from_to(func, anat)
/Users/mb312/dev_trees/nibabel/nibabel/processing.py in resample_from_to(from_img, to_vox_map, order, mode, cval, out_class)
165 raise AffineError('from_img must be at least 3D')
166 a_from_affine = adapt_affine(from_img.affine, from_n_dim)
--> 167 to_vox2from_vox = npl.inv(a_from_affine).dot(a_to_affine)
168 rzs, trans = to_matvec(to_vox2from_vox)
169 data = spnd.affine_transform(from_img.dataobj,
ValueError: shapes (5,5) and (4,4) not aligned: 5 (dim 1) != 4 (dim 0)
It's quite common to resample a functional 4D series to the space defined by another image.
I guess we could support this by specifically allowing the from
image to have more dimensions than the to
image, or be less general, and special-case the from
4D, to
3D case.
Any thoughts?
Metadata
Metadata
Assignees
Labels
No labels