Skip to content

1. Prepare

Diana Dima edited this page Mar 19, 2019 · 2 revisions

Functions in the Prepare directory help load and preprocess the MEG data for a decoding analysis, as well as recover spatial information that can be used in feature selection.

To make sure all required subdirectories are added to the path, run mvpa_setup before starting.

Functions

Data preprocessing

  • read_meg_data Reads, epochs and preprocesses MEG data based on a specified trigger. Inputs are the dataset path, the trigger name (or condition) for epoching, and some preprocessing options as name-value pairs (see the Matlab help for the function). The function returns a 3D matrix (channel x time x trial), rather than a Fieldtrip structure.

  • prepare_binary_data Creates a two-class dataset and label vector for classification from two separate condition-specific matrices.

Increasing SNR

Given the noise challenges in analyzing MEG data, some further preprocessing steps can be used to maximize the signal before decoding. These steps are implemented as name-value pairs in the decoding functions described later on, but can also be used independently when scripting the analysis.

  • create_pseudotrials Averages trials within condition in random subgroups of specified size, using a specified number of random permutations. The function takes a dataset of any dimensions and, for multiple classes, a label vector. Note: it's important to run this separately on the training and test sets, to avoid violating the independence of the two by averaging across them.

  • whiten_data Applies multivariate noise normalization (Guggenmos et al., 2018) by calculating the within-condition error covariance on the training set and applying it to the test set. Inputs are the two-class 3D (space x time x trials) training data, training labels and test data. This procedure downweights the contribution of noisy sensors.

Beamforming

Performing a multivariate analysis in source space can help offset some concerns about signal leakage and subject variability at the sensor level. Using an LCMV beamformer in Fieldtrip, we can project the data into source space and reconstruct the single-trial time-courses of each virtual sensor, or source in the brain, either on a template grid or using an atlas parcellation to pick one source for each anatomical region. The Beamforming directory has functions for beamforming MEG data using an LCMV beamformer.

  • get_lcmv_data Gets whole-brain virtual sensor data based on a specified trigger and a template 10 mm sourcemodel.

  • get_lcmv_data_commfilt Gets whole-brain virtual sensor data based on 2 specified triggers using a common filter and a template 10 mm sourcemodel.

  • get_lcmv_data_aal Gets 90 virtual sensor timeseries based on 2 specified triggers using a common filter and a template 10 mm sourcemodel. The 90 virtual sensors correspond to peak sources in the specified frequency range in each of 90 AAL regions.

Spatial information

The choice of sensors/sources entered as features affect both performance (the trade-off between information and noise), and interpretability (depending on the spatial scale at which we expect information to be encoded). To perform spatial source selection, we need to get information about the layout of our sensors / sources and use this in decoding. To do this, we can run one of two functions in the Prepare directory:

  • get_sensor_info Gets a neighbour structure from a MEG dataset using ft_prepare_neighbours. This can be later used for feature selection, searchlight decoding and plotting in sensor-space decoding functions.

  • get_source_info Gets spatial information from a Fieldtrip sourcemodel in a cell array containing source cluster indices. Used for plotting and feature selection in source-space decoding functions. Supported options are:

    • inside - makes cube-shaped clusters of a given resolution (in mm) around each source inside brain.
    • all - as above for all sources in the sourcemodel
    • aal90 - groups sources in 90 ROIs corresponding to the AAL atlas (Tzourio-Mazoyer et al., 2002)

The indices output by these functions are useful as inputs to the decoding functions and for plotting on sensor layouts/brain templates.

Clone this wiki locally