Running rMVPA algorithms from the command line

rMVPA offers two main command-line executable R scripts that can be used to run most basic MVPA analyses. The goal of these scripts is to get users up and running without requiring them to write full-blown R programs. Instead, rMVPA can be controlled via a configuration file that specifies the data, design information, block structure, model parameters, etc. that are necessary to run an MVPA analysis.

There are currently two main scripts: MVPA_Searchlight.R and MVPA_Regional.R. These two scripts are very similar in their inputs and capabilities--the difference is really only that the former runs a "searchlight" analysis and the latter runs an MVPA over a set of one or more regions of interest (ROI). For example, if one wished to run MVPA using a single large mask covering visual cortex, or over a set of Freesrufer-defined ROIs, one would opt for MVPA_Regional.R.


Installing the command-line scripts

MVPA_Searchlight.R and MVPA_Regional.R are stored in the scripts sub-directory of the R project located here:

https://github.com/bbuchsbaum/rMVPA

Of course, before you can the scripts, you need to have rMVPA installed. Easiest way is to open an R console and type following command, assuming devtools is alreeady installed. If not, first install the devtools package.

## devtools::install_github("bbuuchsbaum/rMVPA")
library(rMVPA")

Installing the rMVPA package, however, will not install the command line scripts. Instead, you have to do this manually.

Using wget to fetch scripts from Github

An easy way to do this is with the wget command.

wget https://raw.githubusercontent.com/bbuchsbaum/rMVPA/master/scripts/MVPA_Searchlight.R

wget https://raw.githubusercontent.com/bbuchsbaum/rMVPA/master/scripts/MVPA_Regional.R

Adding scripts to your bin folder and making them executable

Then, you generally want to move these to a bin directory either locally (e.g. /home/username/bin or at the system level /usr/local/bin).

e.g. cp MVPA_*R /home/username/bin where username is the name of your login id.

Finally, you need to make the script executable:

cd /home/username/bin chmod +x MVPA_Searchlight.R chmod +x MVPA_Regional.R

Now you can test whether the script is working (assuming that the files are on your PATH):

MVPA_Searchlight.R --help

MVPA_Regional.R --help

Searchlight analyses with MVPA_Searchlight.R

Setting up a configuration file

To run a searchlight analysis we need a minimum of five pieces of information.

This information is included in a configuration file which can be a simple R source code file (e.g. "config.R") or a YAML formatted file (e.g. config.yaml).

The following additional information can also be specified:

An example configuation file.

Assume we have a training dataset consisting a set of 100 single trial "betas" collected over five runs and concatenated together into a single file called "betas.nii".

Further assume our classiification goal is to predict whether a presented stimulus is one of four possible categories: face, scene, object, or word.

This information is included in a design file called "train_design.txt" that looks like this (first 5 rows only):

g <- expand.grid(label=c("face", "scene", "object", "word"), repnum=1:5, run=1:5)
knitr::kable(g[1:5,])

Here is a minimal config.R file.

train_design = "train_design.txt"
train_data = "betas.nii"
label_column = "label"
block_column="run"
radius=6
mask = "brain_mask.nii"
mode = "sda_notune"
output = "searchlight_analysis"

Now to run, we type the following command (assuming that MVPA_Searchlight.R in on you PATH):

MVPA_Searchlight.R --config config.R



bbuchsbaum/rMVPA documentation built on April 23, 2024, 7:35 a.m.