Skip to content
Ryan M. Stolier edited this page Dec 27, 2017 · 7 revisions

PyMVPAw package overview

Here we briefly outline the function available in PyMVPAw. These functions all serve the general purpose of multi-variate pattern analyses of functional neuroimaging data (e.g., machine-learning classification analyses, representational similarity analyses). Please note that a more thorough look through the functions is available in the documentation for each function, in their respective .py files. As well, more functions are available there, not documented here.


Organization

The functions may be generally organized into several categories:

  1. Data management tools (data transformation, exploration, wrangling, etc.)
  2. Analyses (local region-of-interest and whole-brain searchlight):
  • Classification analyses (e.g., support vector machine, between-condition classification)
  • Pattern similarity analyses (e.g., representational similarity analyses, trial-by-trial similarity analyses)
  1. Significance testing (e.g., permutation testing, non-parametric cluster thresholding)

Functions overview

Data management tools

These are organized in (i) data wrangling, (ii) data plotting, and (iii) data writing functions in 'datamanage.py'.

  • load_subj_data(): load subject datasets and attributes (via nifti and sample attribute files, e.g., targets)
  • omit_targets(),select_targets(): slice datasets to focus on specific target conditions
  • mask_dset(): mask PyMVPA dataset with nifti mask
  • plotteRy_Brain(): plot PyMVPA datasets
  • roi2ndm_nSs(): acquire neural dissimilarity matrix of target-pairs (RDM) per subject
  • ds2nifti(), datadict2nifti(): write PyMVPA datasets to NIfTI formation
  • sa2csv(): save sample attributes per sample to output CSV file
  • sxs2dset(): save CSV with sample as rows, with sample attributes, and, neural pattern similarity between that sample and the average neural pattern of another target conditions (e.g., how similar is this 'Male' face trial to the average pattern of 'Male'?)

Analyses

Analysis functions are formatted in an easily accessible way to navigate.

  • Functions are organized by ROI (function prefix 'roi_') and searchlight (function prefix 'sl_') application (roi_wraps.py and searchlight_wraps.py)
  • Most analysis algorithms may be applied to single subject datasets (function suffix '_1Ss') or an entire set of subjects simultaneously (function suffix '_nSs')

NOTE: PyMVPAw has a number of functions that wrap analyses to be run on all subjects in a single command, so that analyses may be left to run to completion. In this setup, we first initialize a python environment with this module imported, but importantly, data is loaded as a dictionary where keys are subject IDs and values subject PyMVPA datasets ('datadicts'). The functions with the '_nSs' suffix execute on these 'datadicts' (data dictionaries).

Classification analyses

  • roiClass_nSs(),slClass_nSs: perform classification (with your specific classifier and permutation scheme) ** see ROI wrappers for permutation testing options
  • roiClass_nSs(),slClass_nSs with NFoldPartitionerBWTargets() partitioner: perform classification with training on certain targets, testing on others. This is especially appealing if you hypothesize certain conditions hold information present in other conditions, for instance, is there similar information held when thinking of close objects in the physical world and close others metaphorically in our social lives (Parkinson, Liu, & Wheatley, 2014 - Journal of Neuroscience)? ** see bwtarg_class_prep() in datamanage.py to prepare data for this analysis

Similarity-based analyses

  • roiRSA_nSs(), slRSA_m_nSs(): representational similarity analysis, along with options to control for additional similarity models (e.g., via multiple regression) ** see ROI wrappers for permutation testing options
  • roi_pairsimRSA_nSs(), sl_pairsimRSA_nSs(): representational similarity analysis, however allowing specification of individual condition-pairs to keep in the model (i.e., if you are not interested in modeling all condition-pairs)
  • roi_pairsim_nSs(), sl_pairsim_1Ss(): this method produces the neural-pattern similarity of any specified condition-pairs. This is useful if your hypothesis is certain pairs to be more similar than others. For instance, are insects represented more similar to objects than humans? Univariate analyses, such ANOVA, may be used on these similarity values to ask these questions
  • roiSxS_nSs(), slSxS_nSs(): sample by sample analyses (e.g., trial-by-trial). This algorithm checks whether a trial-by-trial variable (e.g., reaction time, or univariate activity from an ROI) predicts the similarity of that trial's neural pattern to the average neural pattern of any condition. For instance, you may want to see if reaction time predicts how similar the trial's exemplar (e.g., male face) is to the average pattern of another condition (e.g., typical male face neural pattern; e.g., Stolier & Freeman, 2017 - Journal of Neuroscience)
  • roiBDSM_xSs(), slBDSM_xSs(): the behavioral dissimilarity measure checks whether a between-subjects variable predicts the similarity of any neural pattern pair between subjects. For instance, do individuals who believe tomatoes are a vegetable represent tomatoes as closer to vegetables than fruits?
  • slRSA_xSs(): this correlates the neural similarity matrices (RDMs) between subjects across the brain, technically, assessing where in the brain subjects have a similar representational similarity structure (e.g., see Connolly et al., 2012 - Journal of Neuroscience)

Significance testing

There are several signifiance testing tools readily available in PyMVPAw for multi-variate pattern analyses.

  • roiClass_perm_nSs(), roiRSA_perm_nSs(): RSA and classification permutation testing within ROIs
  • slClassPermTest_1Ss(): estimate null distributions of classification via random shuffling of condition labels
  • Perm_GroupClusterThreshold(): perform non-parametric permutation based cluster thresholding ** see GroupClusterThreshold_prep() in datamanage.py to prep for this analysis