Welcome to my course project on Event-Related Potential (ERP) analysis, created as part of my EEG signal processing coursework. This repository demonstrates how to preprocess EEG data, extract epochs based on event markers, perform baseline correction, compute ERPs, and visualize brain responses across time and space using MATLAB.
The EEG data used in this project is sourced from eeglab_data.mat, a sample dataset typically provided with the EEGLAB toolbox. The dataset contains multi-channel EEG recordings along with annotated events (event) and channel locations (chanlocs) for topographic plots.
-
Load EEG Data
- Load the
.matfile and generate a time vector from -200 ms to 1000 ms, with 5 ms intervals.
- Load the
-
Average Re-Referencing
- Re-reference EEG signals by subtracting the average of all channels to reduce noise and global artifacts.
-
Event Detection
- Extract event types and latencies.
- Identify time points of interest for four specific event classes.
-
Epoching
- Segment the EEG data from -200 ms to 1000 ms around each event.
- Apply baseline correction using the pre-stimulus interval (-200 to 0 ms).
-
ERP Calculation
- Average all epochs across trials for each event class to extract event-related potentials.
-
Visualization
- ERP waveform per channel
- ERP image (heatmap) for a selected channel and event
- All individual epochs for a specific channel
- Overlayed ERP plots across channels and events
- Global Field Power (GFP) and topographic variance
- Topoplot of brain activity across time
💡 Modify these variables to control the output:
which_stimulus = 1;→ Choose from 111, 112, 121, 122which_channle = 30;→ Choose a channel index (1–32)
Plots the averaged ERP waveform for each EEG channel.
A heatmap showing signal fluctuations across epochs and time for one selected channel.
Line plot showing every single epoch overlaid to evaluate trial-by-trial variability.
Overlayed ERP waveforms of a single channel across different event types.
Calculates and plots Global Field Power (standard deviation across all channels) and variance across time.
Scalp topographies of ERP signals at different post-stimulus time points.