[pymvpa] NiftiDatatset bug?

Scott Gorlin gorlins at MIT.EDU
Thu Jan 8 18:02:20 UTC 2009


Think this is a bug...

If I load a NiftiImage with 1 timepoint, the resulting data.shape is a 
tuple of 3 for X,Y,Z.  I'm guessing there's a squeeze() call somewhere 
in NiftiImage as the first dimension should be 1 (n,X,Y,Z).

This isn't terrible in and of itself (though it can cause errors if not 
handled correctly), but if I use NiftiDataset, it doesn't use 
NiftiImage.timepoints and NiftiImage.nvox to set the number of samples 
and features, it just uses the first dimension in NiftiImage.data.shape, 
as it's passed through to MaskedDataset.__init__().

So, for example, I load a 33x64x64 functional volume (which correctly 
gets 1 timepoint in NiftiImage) and it results in a 33 x 4096 dataset, 
instead of a 1x135168.  I get the same results loading the nii manually 
and passing the NiftiImage to NiftiDataset, or just sending the filename 
in directly to NiftiDataset.

The behavior is even stranger if I try to apply a mask, since the mask 
is assumed to have 1 timepoint and is treated differently.  Calling 
NiftiDataset with the nii image used above and a mask, with the exact 
same geometry, yields:

ValueError: The mask dataspace shape [(33, 64, 64)] is not compatible 
with the shape of the provided data samples [(64, 64)].

A cludgy workaround:
im = NiftiImage(imname, load=True)
nim = NiftiImage(numpy.asarray([im.data]), header=im.header)
d = NiftiDataset(samples=nim, labels=labels)  (also works with a mask 
now, as expected)

Possibly related to 
http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/2008q4/000272.html 
?

Scott



More information about the Pkg-ExpPsy-PyMVPA mailing list