EEG and MEG Analysis with MNE
An introduction to analyzing EEG and MEG data with the MNE-Python package
Authors
This course provides an introduction to EEG and MEG data analysis with Python and the MNE library.
In the first part of the course, you’ll learn how to go from raw EEG and MEG recordings to event-related responses and how to compare those responses between different experimental conditions using statistical tests.
You’ll then learn how to use spatial and temporal filters to extract different sources and frequencies from the recorded signals and to decompose them into multiple frequency bands. The latter will allow you to perform time-frequency analysis and apply phase-based connectivity measures to estimate how the EEG’s frequency content changes across time and how individual sensors are related.
The last part focuses on linear modeling of neural responses. You’ll learn how to use linear regression and regularization and how to introduce time-lags for capturing relationships that are not instantaneous (like the neural responses to stimuli). Finally, you’ll see how these models can be applied to model the EEG responses to continuous naturalistic speech.
Throughout the course you’ll use simulations to test the different methods of analysis against a known ground truth as well as real EEG and MEG data. While the course focuses on the MNE-Python package it places great emphasis on the underlying methods, most of which will translate to other neuroscience modalities.
Credits
Installation
To run the course materials on your own machine:
- Install VSCode as your editor
- Install pixi or alternatively conda to create virtual Python environments (see the lessons on environment and package management)
- Download the materials for a lesson using the "Download Materials" button
- Extract the zip file and open the notebook in VSCode
- In VSCode, open a new terminal and install the environment:
pixi installconda env create -f environment.yml
conda activate mneCourse Contents
From Raw EEG and MEG to Event-Related Potentials and Fields
Working with Raw EEG and MEG data
Learn how to use MNE's Raw class to load, handle and visualize raw EEG and MEG data
Simulate Raw EEG using a Forward Model
Learn how to use generate source activity in the brain sources and project it to the scalp to siimulate realistic EEG data
Epoching Continuous EEG and Computing Event-Related Potentials
Divide raw EEG recording into epochs around events to compute and visualize ERPs
Statistical Analysis of Event-Related Potentials
Apply null-hypothesis tests to identify differences in event-related responses between conditions across space and time
Temporal and Spatial Filters
Spatial Filters: PCA and ICA
Learn how PCA and ICA decompose mixed EEG signals into spatial components, and how ICA can separate independent neural sources and remove artifacts
Preprocessing with Finite Impulse Response (FIR) Filters
Applying and visualizing FIR filters and understanding filtering artifacts
Time-Frequency and Phase-Based Connectivity Analysis
Time-Frequency Analysis with Morlet Wavelets
Creating Morlet wavelets and applying time-frequency decomposition to EEG data to compute event-related desynchronization
Phase-Based Connectivity Analysis
Use phase-locking-value (PLV) and phase-lag index (PLI) to estimate connectivity on simulated EEG data
Linear Modeling of Neural Response
Linear Regression and Regularization
Use ordinary least squares (OLS) regression and ridge regularization to model the relationship between variables
Linear Regression Across Time-Lags
Create time-lagged design matrices and perform regularized regression to model time-varying relationships between stimulus and response
Modeling Cortical Responses to Naturalistic Speech
Use the mTRFpy package to model the relationship between speech features and neural responses