[pymvpa] Recovering original image dimensions after remove_invariant_features

Shane Hoversten shanusmagnus at gmail.com
Tue Oct 21 15:20:00 UTC 2014


Hi -

When I run the spotlight using SVM I get complaints about C not being able
to be normalized. This seems to be because the group mask includes voxels
that are not live for all subjects.  I can make these warnings go away with
more aggressive masking for each subject, but what I'd really like to do is
tell the classifier to just ignore constant features.

I found the remove_invariant_features function, which seems just the
thing.  However, when writing the searchlight results produced on a dataset
filtered through this function, the original image dimensions are lost.  Is
there a way to have the invariant features removed in a similar way as when
you specify a mask with the dataset, which allows the original image
dimensions to be preserved in the mapper chain s.t. searchlight results
written to disk Just Work?

Here's a code snippet that shows what I mean.  If I don't remove the
invariant features (indicated with a comment)

###

# Using just this, the written image would be of the original image
dimensions (73 * 87 * 73)
# sub_ds_inv = s.sub_datasets[contrast]

# Removing inv features pleases the SVM but messes up dimensions.
sub_ds_inv = mfx.remove_invariant_features(s.sub_datasets[contrast])

clf  = LinearCSVMC()
cv   = CrossValidation(clf, NFoldPartitioner(attr="scrambled_runs"), \
         errorfx=lambda p,t: np.mean(p == t), enable_ca=['stats'])
sl    = sphere_searchlight(cv, radius=radius_size, postproc=mean_sample(),
nproc=NPROC)
res  = sl(sub_ds_inv)

# With inv features removed, this writes the results in one giant array
(26880 x 1 x 1).
nimg = map2nifti(sub_ds_inv, res.samples[0])
nimg.to_filename("spotlight_101")

###

Thanks for any help,

Shane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20141021/d99ebd42/attachment.html>


More information about the Pkg-ExpPsy-PyMVPA mailing list