Table Of Contents

Previous topic

Miscellaneous

Next topic

Visualization of Data Projection Methods

This content refers to the previous stable release of PyMVPA. Please visit www.pymvpa.org for the most recent version of PyMVPA and its documentation.

Full Examples

Each of the examples in this section is a stand-alone script containing all necessary code to run some analysis. All examples are shipped with PyMVPA and can be found in the doc/examples/ directory in the source package. This directory might include some more special-interest examples which are not listed here.

Some examples need to access a sample dataset available in the data/ directory within the root of the PyMVPA hierarchy, and thus have to be invoked directly from PyMVPA root (e.g. doc/examples/searchlight_2d.py). Alternatively, one can download a full example dataset, which is explained in the next section.

Example fMRI Dataset

For an easy start with PyMVPA an example fMRI dataset is provided. This is a single subject from a study published by Haxby et al. (2001). This dataset has already been repeatedly reanalyzed since its first publication (e.g. Hanson et al (2004) and O’Toole et al. (2005) < OJA+05).

Note

The orginal authors of Haxby et al. (2001) hold the copyright of this dataset and made it available under the terms of the Creative Commons Attribution-Share Alike 3.0 license.

The subset of the dataset that is available here has been converted into the NIfTI dataformat and is preprocessed to a degree that should allow people without prior fMRI experience to perform meaningful analyses. Moreover, it should not require further preprocessing with external tools.

All preprocessing has been performed using tools from FSL. Specifically, the 4D fMRI timeseries has been skull-stripped and thresholded to zero-out non-brain voxels (using a brain outline estimate significantly larger than the brain, to prevent removal of edge voxels actually covering brain tissue). The corresponding commandline call to BET was:

bet bold bold_brain -F -f 0.5 -g 0

Afterwards the timeseries has been motion-corrected using MCFLIRT:

mcflirt -in bold_brain -out bold_mc -plots

The following files are available in the example fMRI dataset download (approx. 100 MB):

bold.nii.gz
The motion-corrected and skull-stripped 4D timeseries (1452 volumes with 40 x 64 x 64 voxels, corresponding to a voxel size of 3.5 x 3.75 x 3.75 mm and a volume repetition time of 2.5 seconds). The timeseries contains all 12 runs of the original experiment, concatenated in a single file. Please note, that the timeseries signal is not detrended.
bold_mc.par
The motion correction parameter output. This is a 6-column textfile with three rotation and three translation parameters respectively. This information can be used e.g. as additional regressors for motion-aware timeseries detrending.
mask.nii.gz
A binary mask with a conservative brain outline estimate, i.e. including some non-brain voxels to prevent the exclusion of brain tissue.
attributes_literal.txt
A two-column text file with the stimulation condition and the corresponding experimental run for each volume in the timeseries image. The labels are given in literal form (e.g. ‘face’).
attributes.txt
Similar to attributes_literal.txt, but with the condition labels encoded as integers. This file is only provided for earlier PyMVPA version, that could not handle literal labels.

Once downloaded and extracted (e.g. into a folder data/), the dataset can be easily loaded like this:

>>> from mvpa.misc.io.base import SampleAttributes
>>> from mvpa.datasets.nifti import NiftiDataset
>>> attrs = SampleAttributes('data/attributes_literal.txt',
...                          literallabels=True)
>>> ds = NiftiDataset(samples='data/bold.nii.gz',
...                   labels=attrs.labels,
...                   chunks=attrs.chunks,
...                   labels_map=True,
...                   mask='data/mask.nii.gz')

Note, that instead of specific import statements, it is usually more convinient, but slower, to import all functionality from PyMVPA at once with from mvpa.suite import * statement.

Note

The dataset used in the examples shipped with PyMVPA is actually a minimal version (posterior half of a single brain slice) of this full dataset. After appropriately adjusting the path, it is possible to run several of the examples on this full dataset.