Multivariate Pattern Analysis in Python |
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.
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):
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.