19 - Machine learning for cognitive neuroscience
Tutorials from the Cutting Gardens 2023 conference - Ghent edition
Welcome to The EEG Newsletter!
Every two weeks or so I share news from our community of EEG researchers, vacancies, events and other interesting EEG-related stuff. Subscription is free.
In this edition
Machine learning for cognitive neuroscience
Events
Vacancies
Machine learning for cognitive neuroscience
From the 16th to the 19th of October we hosted one “garden” of the global multi-hub Cutting Gardens EEG Methods conference here in Ghent. The conference was organized by the Cutting EEG Organization and we had a blast. The main theme in our hub was machine learning (and more specifically, decoding or MVPA) for cognitive neuroscience. You can find the tutorials from the conference below. First I’ll give a short intro.
Machine Learning
Machine learning is a subset of artificial intelligence. It allows computers to learn from data and make predictions or decisions without explicit programming. Such data-driven techniques can be useful in cognitive neuroscience to discover patterns in complex neural data.
Broadly, we can define machine learning models along 3 dimensions (see King et al., 2018). Discriminative vs. generative: Discriminative models learn the decision boundary between classes (categories). Generative models learn the underlying distribution of each class and how the data is generated. Encoding vs decoding: Encoding models predict the neuronal responses from mental representations. Decoding models predict the mental representations from neuronal responses. Supervised vs. unsupervised: Supervised algorithms are trained on labeled data and map input features (EEG) to output labels (trial condition). Unsupervised learning algorithms find inherent structures in unlabeled data (for example ICA).
During the workshops we focused on discriminative decoding using supervised learning (also called MVPA). If we compare MVPA to ERP analyses we can spot some commonalities and differences. MVPA and ERP’s are both great for studying the temporal dynamics of cognition. They look for differences between experimental conditions and work on segmented data (epoched time-locked to a stimulus). MVPA is often more sensitive, because it uses spatially distributed (multivariate) activity. ERP’s, in contrast, use a univariate approach by testing for differences in a single electrode or an average across multiple electrodes. Another important difference is that MVPA is more data-driven which makes researcher bias less of an issue, because there are less “researcher degrees-of-freedom”.
To decode a mental representation from EEG data, a pattern classifier is trained to distinguish between two experimental conditions (e.g. classes of stimuli). The classifier's ability to distinguish these conditions from new data is then assessed using cross-validation. If this performance is significantly above chance, that means the data contain class-specific information.
Time-resolved decoding analysis for M/EEG: some basics.
In time-resolved decoding analyses, this process is repeated at each time point. That can tell us, for example, when the peak in decoding performance occurs, or what the earliest moment is that information about the stimuli (or response) can be found in the data. These measures can then be compared across experimental conditions.
To illustrate time-resolved MVPA here is figure 1 from Carlson, Grootswagers & Robinson (2019).
Figure 1. Time-resolved decoding analysis for M/EEG. (A) Top down view of a 64-channel layout. (B) Sample data from an EEG experiment. (C) Scatterplot showing hypothetical EEG data from a single time point. The two axes are the measured voltage from two EEG electrodes. The points are individual trials for the ‘X' and ‘O' conditions. The line denotes the optimal classification boundary for classifying ‘X's and ‘O's. (D) Four iterations of cross-validation using 75% of the data to train the classifier and 25% to test the classifier. The top row of plots show the training data along with the classification boundary for each iteration. The plots below show the test data for each iteration with the decision boundary computed from the training data. (E) An example of a time-resolved decoding analysis showing classifier accuracy averaged over participants (data from Grootswagers et al., 2017a).[caption edited by me, for full caption go to original paper]
In figure 1C you can see how a linear classifier (the classification boundary) can successfully discriminate between the conditions “X” and “O”. This plot is a simplification; in reality there are as many dimensions to the data as there are channels and the classifier is a vector with a dimensionality of N (channels) - 1. Unfortunately humanity hasn’t mastered the art of 63-D drawing yet, hence the 2-D plot, but the principle is the same.
This classifier now has to be tested on new data. Learning the model parameters and testing them on the same data would lead to overfitting. The classifier would get a perfect score, but might not generalize. To avoid overfitting you could separate part of the available data as a test set, but then you lose a lot of data to train the classifier on. One solution is cross-validation. In k-fold cross-validation (see figure 1D) the training set is split into k smaller sets. The classifier is trained and tested iteratively: on each iteration a classifier is trained using k−1 of the folds as training data and the remaining fold as testing data. Then the scores for each fold are averaged to get the final accuracy score. By fitting and cross-validating a classifier at each timepoint, we get an accuracy score at each timepoint such as in 1E.
In the next newsletter I will write about a few applications of decoding analyses in cognitive neuroscience. Below you can find some introductory papers and tutorials if you want to try it out in Python!
The HMP toolbox in action (see below for tutorial).
Papers
Carlson, T. A., Grootswagers, T., & Robinson, A. K. (2019). An introduction to time-resolved decoding analysis for M/EEG. arXiv preprint arXiv:1905.04820.
Grootswagers, T., Wardle, S. G., & Carlson, T. A. (2017). Decoding dynamic brain patterns from evoked responses: a tutorial on multivariate pattern analysis applied to time series neuroimaging data. Journal of cognitive neuroscience, 29(4), 677-697.
Tutorials
This is the code and data we used for our MNE tutorials during the Cutting Gardens 2023 conference. The tutorial for Day 1 will give you a gentle introduction into MNE. Day 2 goes over the basics of MVPA discussed above plus a bit more (such as temporal generalization analysis and spatial patterns). Day 3 is an in depth tutorial to use the HMP Toolbox, which decodes cognitive stages from EEG data (its awesome, give it a try!).
Instructions for preparing the Python environment
Day 1.- MNE Tutorial preprocessing (by Josh Eayrs)
Data and code
Day 2.- MNE Tutorial decoding (by Mengqiao Chai and me based on this material by Britta Westner and these tutorials on the MNE website).
Data
Code
Day 3.- Hidden semi-Markov modeling with the HMP toolbox
The tutorial (Data and code) was taught by Gabriel Weindel and Jelmer Borst, the creators of the HMP Toolbox. This python-based toolbox estimates the onset of cognitive stages on a single-trial basis. See Borst & Anderson, 2021, for an accessible introduction. These trial-by-trial estimates allow you to for example:
describe an experiment or a clinical sample in terms of stages detected in the EEG signal
describe experimental effects based on stage duration
time-lock EEG signal to the onset of a given stage and perform classical ERPs or time-frequency analysis based on the onset of a new stage
And many more (e.g. evidence accumulation models on decision stage, classification based on the number of transition events in the signal,...)
Events
Nov 24th (7pm) – Nov 25th, 2023, Brussels
Waveform Oddysey Signal Processing Challenge
Vacancies
PhD
University of Zurich, CH - The role of neurally active representations for cognition (10-nov).
University of Missouri, US - Attentional capture and distraction.
Maastricht University, NL - Anticipatory mechanisms during interarea brain communication.
Rice University, Houston, US - Neural bases of attention and working memory.
University of Lübeck, DE - Capture and suppression in auditory attention.
Post-Doc
University of Birmingham, UK - Developing a pediatric OPM system (20-nov).
Florida State University, US - The neural oscillatory basis of higher order cognition (Dec 1st).
Washington University, St Louis, US - Cognitive neuroscience of attentional control.
La Timone Hospital & INSERM, Marseille, FR - Helium OPM MEG/iEEG.
Maastricht University, NL - Anticipatory mechanisms during interarea brain communication.
University of Tübingen, DE - Neural and computational bases of decision making and mental illness.
University of Southern California & McGill University, Montréal - Join the Brainstorm research & development teams.
University of Birmingham, UK - Elderly patients, frailty, cognition and EEG (19-Nov).
Donders Institute, Nijmegen, NL - Neural correlates of cane sensing in the sighted and blind.
Heinrich Heine University Düsseldorf, DE - Decision making and learning.
RA’s
Neurospin CEA - RA acquisition and analysis of neuroimaging data.
University of Birmingham, UK - Associate professor in Psychology.
Research engineer (Ingenieur d’étude) - CNRS, Brain and Cognition Research Centre, Toulouse, FR.