[pymvpa] Using masks with different dimensions than the functional volumes

Nick Oosterhof nikolaas.oosterhof at unitn.it
Sun Sep 1 19:11:11 UTC 2013

On Aug 31, 2013, at 11:46 PM, Shane Hoversten wrote:

> I'd like to
> localize the analysis based on the results of various masks, including
> Brodmann masks created with the wfu pickatlas tool
> (http://fmri.wfubmc.edu/software/PickAtlas).  I can use these masks in
> the course of univariate analyses with SPM despite the fact that the
> masks have different numbers of voxels than do our acquired volumes --
> the NIFTI headers apparently contain enough info to match up the mask
> and the volumes in physical space, and SPM just does the right thing,
> which was a pleasant surprise.
> But now I'd like to use these masks with PyMVPA. […]
> ds = fmri_dataset(os.path.join(path, 'bold.nii.gz'),
> mask=os.path.join(path, 'mask_vt.nii.gz'))
> As it happens, the shape of the voxel matrix for this BOLD data, and
> for this mask, are the same.  That's a luxury we don't have in our
> dataset, but I crossed my fingers and tried to load one of our volumes
> with the mask, but to no avail.  I got this error: […]
> ValueError: FlattenMapper has not been trained for data shape '(91,
> 109, 91)' (known only '(96, 96, 37)').
> The (91,109,91) are the dimensions of the masks produced by wfu
> pickatlas; our data is the (96, 96, 37).  So my question is, how does
> one deal with these situations?  

You would have to resample your mask to match the dimensions and orientation of the functional dataset.

If you have access to AFNI, you could use 3dresample to accomplish this.

I'm not an expert in SPM, but it seems that spm_sample_vol (with nearest neighbor interpolation) is the way to go in that program.

PyMVPA has no direct support for such resampling operations. The only way I could think of is using volgeom (in mvpa2/misc/surfing) that allows you to go from voxel indices to world coordinates and back, but the actual resampling would need some additional code.

More information about the Pkg-ExpPsy-PyMVPA mailing list