[pymvpa] ERNiftiDataset

Michael Hanke michael.hanke at gmail.com
Tue Jul 7 07:26:39 UTC 2009


On Mon, Jul 06, 2009 at 12:02:59PM -0500, Matthew Cieslak wrote:
> I have the Event definitions stored in a dict (here ev) and read in through
> a loop like this
>     evt = []
>     for item in ev:
>         #
> {'onset':runnum*runlength+timestamp,'duration':6,'chunk':runnum,'label':cats[c]}
>         evt +=
> [Event(onset=item['onset'],duration=item['duration'],chunk=item['chunk'],label=item['label'])]
> Then define the ERNiftiDataset
> data = ERNiftiDataset(samples=dfile,
>                         events = evt,
>                         mask=mfile,
>                         dtype=N.float32,
>                         evconv=True)
> Then the analysis is run with
>     smap = LinearNuSVMC().getSensitivityAnalyzer(transformer=N.abs)
>     results = smap(data)

This looks all fine to me and it should work -- does it?

> In this case the TR is 2sec so results contains 3 volumes. I also tried
> setting the duration to 12 seconds and got results spanning 6 volumes. I
> assumed that the values in these volumes were just the absolute SVM weights
> mapped back from array form to their locations in space/time. Is this
> correct?

'results' should be a 1D-vector. If you want to have it in original
(fMRI) space you would call:

  origspaceresults = data.map2Nifti(results)

However, in an earlier email you wrote:
> > I just switched from using the transformWithBoxcar function in conjunction
> > with fsl evfiles to make big files of concatenated samples with labels and
> > chunks specified in an outside text file to using the ERNiftiDataset class
> > (which is really nice!) with lists of Event objects and am having trouble
> > running a searchlight on it.  I get the error
> >
> > ValueError: Searchlight only works with MappedDatasets that has metric
> > assigned.
> >
> > Is it not possible to use a searchlight when samples have multiple time
> > points? I had no trouble getting svm weights for the same ERNiftiDatasets,
> > so I am a little confused

With searchlights the situation is a little different. There are several
possibilities to run a searchlight.

1. Pure-spatial searchlight that will run the analysis in a
   sphere-shaped dataset spanning all volumes in time.

2. Spatio-temporal searchlight. In addition to 1. also limiting the
   temporal window of the dataset.

I am afraid that both scenarios are not well tested (probably nobody
used that before), and I suspect that they also involve a bit of coding
in PyMVPA itself. Especially 2. would make the runtime of a searchlight
analysis even more ridiculus than it already is.

But I'd like to drag your attention to another aspect which is hidden
behind the 'storeoffset' argument of ERNiftiDataset. If that is enabled
the temporal offset of the real onset and the descretized or volume
onset is stored as an additional feature in the dataset (same is
possible for arbitrary additional feature via the respective field in
the Event dictionary). Technically this results in ERNiftiDataset
becoming a meta dataset assembled from two basic datasets. One is a
standard nifti dataset with typical metrics and is 'searchlightable'.
The other is a pure Dataset with no metrics assigned -- think of it as
covariates of each sample. Obviously you cannot ask a covariate with no
metric what its neighbors in space are -- hence a searchlight analysis
of such a combined dataset is not really meaningful.

One approach might be to include the covariate dataset in each spherical
subdataset, hence doing some enhanced searchlight. This is quite easy to
implement by enhancing ERNiftiDataset with a proper Mapper/Metric
combination. However, I'm not sure that anyone will implement that
within the next weeks.

But I am sure we can come up with some code to perform your intended
analysis -- but I am not sure what that is exactly. A searchlight of any
of the above scenarios, or something else?


GPG key:  1024D/3144BE0F Michael Hanke
ICQ: 48230050

More information about the Pkg-ExpPsy-PyMVPA mailing list