[pymvpa] searchlight on ER data

Anna Manelis anna.manelis at gmail.com
Tue Dec 21 18:37:38 UTC 2010


Hi all,

I am trying to use searchlight on event-related fMRI data. I combined two
scripts provided with
pymvpa (version 0.4.5): eventrelated.py and searchlight_2d.py. The script
looks like that

=====================================================
from mvpa.suite import *

fmri_src = os.path.join(pymvpa_dataroot, 'bold.nii.gz')
mask = NiftiImage(os.path.join(pymvpa_dataroot, 'mask.nii.gz'))
attr = SampleAttributes(
                os.path.join(pymvpa_dataroot,
                             'attributes_literal.txt'),
                        literallabels=True)
verbose(1, "Load data for preprocessing")
pre_ds = NiftiImage(fmri_src)
pre_ds = NiftiDataset(samples=fmri_src, labels=attr.labels,
                      chunks=attr.chunks, mask=mask)
pre_ds.setSamplesDType('float')
detrend(pre_ds, perchunk=True, model='linear')
evs = [ev for ev in attr.toEvents()
            if ev['label'] in ['face', 'house']]
for ev in evs:
    ev['onset'] -= 1
    ev['duration'] = 4
ds = ERNiftiDataset(samples=pre_ds.map2Nifti(),
                    events=evs,
                    mask=mask,
                    labels_map={'face': 1,
                                'house': 2})
zscore(ds, perchunk=True)

# Run Searchlight
clf = LinearNuSVMC()
cv = CrossValidatedTransferError(TransferError(clf),
                                 NFoldSplitter())
for radius in [1,5,10]:

    print "Running searchlight with radius: %i ..." % (radius)
    sl = Searchlight(cv, radius=radius)
    sl_map = sl(ds)

=====================================================

The code fails with the following message:

Traceback (most recent call last):
  File "eventrelated_original_SL.py", line 158, in <module>
    sl_map = sl(ds)
  File "/usr/lib/pymodules/python2.6/mvpa/measures/base.py", line 105, in
__call__
    result = self._call(dataset)
  File "/usr/lib/pymodules/python2.6/mvpa/measures/searchlight.py", line 77,
in _call
    raise ValueError, "Searchlight only works with MappedDatasets " \
ValueError: Searchlight only works with MappedDatasets that has metric
assigned.



Could you please advise on how to make the code work by assigning metric to
MappedDatasets or in any other way.

Thank you,
Anna.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-exppsy-pymvpa/attachments/20101221/a63f62a0/attachment.htm>


More information about the Pkg-ExpPsy-PyMVPA mailing list