This repository accompanies the MSNE Python Workshop on offline EEG analysis, focusing on motor imagery data from the BCICIV dataset. The aim is to explore preprocessing, visualization, and classification techniques using the MNE library.
- Understand EEG Data: Learn how motor imagery affects brain waves (mu rhythm) and observe Event-Related Desynchronization (ERD) and Synchronization (ERS).
- Preprocessing: Apply band-pass filters, visualize Power Spectral Density (PSD), and use ICA to remove artifacts.
- Feature Extraction: Use Common Spatial Patterns (CSP) to enhance class separability.
- Classification: Train a classifier (LDA) to distinguish motor imagery tasks.
- Load and Explore EEG Data: Analyze EEG recordings from one participant.
- Visualize ERD/ERS: Calculate and plot ERD/ERS curves to observe motor imagery effects.
- Spatial Filtering: Compare results with and without spatial filtering to understand its impact.
- Train a Classifier: Use CSP and LDA to achieve accurate classification of left and right hand motor imagery.
- Clone the repository by running:
git clone [email protected]:karahanyilmazer/msne-python-workshop.git
-
Follow the setup tutorial to set up your Python environment and install required libraries.
-
Read the EEG motor imagery tutorial for background information on EEG, motor imagery, CSP and ERD/ERS curves.
-
Open the
berlin_mi_analysis-problem.py
script:- Follow guided steps to preprocess, visualize, and classify EEG data.
- Complete the
calc_erds()
andplot_erds()
functions.
-
Refer to
berlin_mi_analysis-solution.py
for the complete implementation.
- ERD/ERS Analysis: Spatial filtering highlights key features in the data, making ERD/ERS patterns clearer.
- Classification Performance: CSP and LDA yield high accuracy in distinguishing left and right hand motor imagery.
Through this workshop, you’ll see how spatial filtering and preprocessing transform raw EEG data into meaningful insights, paving the way for high-performing classifiers.
Happy coding!
msne-python-workshop
├─ .gitignore
├─ MSNE_Python_Workshop-EEG_Analysis.pdf
├─ README.md
├─ berlin_mi_analysis-problem.py
├─ berlin_mi_analysis-solution.py
├─ data
│ └─ BCICIV_calib_ds1e.mat
├─ img
│ ├─ erds_base.png
│ └─ erds_car.png
└─ utils.py