# Using CoSMoMVPA *neighborhoods* for regions of interest¶

## Rationale¶

A previous exercise showed how to use a measure to both simplify and generalize across different common MVPA techniques (split-half correlations (split-half correlations and classification with cross-validation).

It is often useful to apply the *same measure* to *different subsets of the features*, for example:

Analysis of multiple ROIs.

Searchlight analysis, which is essentially repeated ROI analysis where each feature of the dataset is associated with a set of features around it.

CoSMoMVPA uses a neighborhood to define *which* subsets of features are used.

## Exercises¶

Before starting this exercise, please read the following:

As a preparation for a whole-brain spherical searchlight, this exercise will make a very simple neighborhood that contains indices for only two ROIs (whole-brain searchlights have thousands of (partially overlapping) regions). In each ROI classification analysis with cross-validation and split-half correlation analysisis performed.

Part 1 requires the *manual* application of a measure to features indexed by the neighborhood; Parts 2, 3 and 4 show how a cosmo searchlight can be used to achieve the same.

Notes:

this exercise requires familiarity with the measure concept (exercise).

understanding the concept of a neighborhood is important for another exercise about whole-brain searchlights.

### Part 1¶

Load the dataset with subject `s01`

’s t-statistic for every run (`glm_T_stats_perrun.nii`

), but do not apply a mask.
Then load each of the two masks (`vt`

, `ev`

), and define a neighborhood where the `.neighbors`

is a cell with two elements, each containing the features indices of the respective masks. Use cosmo slice to slice the dataset along features (once for each mask), then apply the cosmo crossvalidation measure measure with the cosmo classify lda classifier and partitions from cosmo nfold partitioner to compute classification accuracies for each of the masks.

### Part 2¶

Using the neighborhood structure defined in Part 1, use the cosmo searchlight function to perform the same analysis as in Part 1.

### Part 3¶

Using the same neighborhood structure, compute the split-half correlation measure (difference between Fisher-transformed on-diagonal versus off-diagonal elements) using cosmo correlation measure.

### Part 4 (advanced)¶

Use the same neighborhood and measure as in Part 2, but now let the measure return the predictions of each sample in each ROI. Run the searchlight, compute the confusion matrices, and visualize these.

Template: run roi neighborhood skl

Check your answers here: run roi neighborhood / Matlab output: run_roi_neighborhood