Layer 4 — Applied Intelligence

Motor Imagery BCI Classification

64-channel EEG decoding for brain-computer interfaces. Three classifiers compared: 1D CNN (83.8%), EEGNet (83.4%), CSP+SVM (81.2%). BCI Competition 2005 Dataset I.

64 chEEG Channels
250 HzSampling Rate
83.8%Best Accuracy (1D CNN)
5-fold CVValidation Strategy
PyTorchFramework

Overview

Motor imagery (MI) BCI is a paradigm where a person imagines performing a movement — without actually moving — and the resulting neural activity in the motor cortex is decoded from EEG signals to produce a control command. MI BCIs are used in rehabilitation robotics, assistive technology for paralysed patients, and neuroscience research. The central challenge is that EEG is low-SNR, non-stationary, and highly individual-specific: patterns that decode well for one subject require re-calibration for another.

This project benchmarks three classification approaches on BCI Competition 2005 Dataset I (a standard, well-characterised benchmark): a classical signal processing pipeline (CSP+SVM), a compact end-to-end deep learning architecture (EEGNet), and a custom 1D CNN. All three use 5-fold stratified cross-validation for fair comparison and to detect overfitting.

Dataset

ParameterValue
DatasetBCI Competition 2005 Dataset I
EEG channels64 (10/20 system)
Sampling rate250 Hz
TaskBinary motor imagery: left hand vs. right hand
Epoch duration3 s per trial (750 samples per channel)
PreprocessingBandpass 8–30 Hz (μ + β bands), common average reference
Cross-validation5-fold stratified (balanced class ratio per fold)

Preprocessing Pipeline

Raw EEG 64 ch, 250 Hz BCI2005 DI Bandpass 8–30 Hz 4th-order Butter. CAR Common Average Reference Epoching 3 s windows 750 samples/ch Feature Extraction / Raw to CNN Classifier CNN / EEGNet / CSP+SVM
Fig. 1. EEG preprocessing pipeline: bandpass → common average reference → epoching → feature extraction → classification.

Classifier 1: Common Spatial Patterns + SVM

Common Spatial Patterns (CSP) is a classical spatial filter algorithm that maximises the variance ratio between two classes in EEG. Given the covariance matrices Σ₁ (class 1) and Σ₂ (class 2), CSP finds the filter matrix W such that:

W^T Σ₁ W = Λ    and    W^T (Σ₁ + Σ₂) W = I

The first and last columns of W correspond to the directions of maximum variance for class 1 and class 2 respectively. Log-variance of the filtered signals (log(var(W^T·x))) forms the feature vector fed to an SVM with RBF kernel. CSP+SVM achieved 81.2% accuracy.

Classifier 2: EEGNet

EEGNet (Lawhern et al. 2018) is a compact CNN designed specifically for EEG classification. Its architecture:

EEGNet has ~2,500 parameters (very compact), which is important for EEG where limited training data makes large models prone to overfitting. Achieved 83.4% accuracy.

Classifier 3: Custom 1D CNN

The custom 1D CNN treats each channel's time series independently through depthwise convolutions, then fuses across channels. Architecture:

Achieved 83.8% accuracy — the best of the three, marginalyl ahead of EEGNet. The channel attention mechanism proved important: ablation without it reduced accuracy by 2.1%.

Results

EEG data overview
Fig. 2. Raw EEG data overview: 64-channel recording showing characteristic μ-band (8–12 Hz) and β-band (13–30 Hz) oscillations in motor cortex channels.
EEG spectrograms
Fig. 3. Time-frequency spectrograms for representative channels (C3, Cz, C4). Event-related desynchronisation (ERD) visible as power decrease during motor imagery.
Results comparison
Fig. 4. Accuracy comparison across the three classifiers. Error bars show std across the 5 cross-validation folds. 1D CNN: 83.8%, EEGNet: 83.4%, CSP+SVM: 81.2%.
Confusion matrices
Fig. 5. Confusion matrices for all three classifiers. All show stronger performance on right-hand imagery — consistent with the literature on this dataset.
Training curves
Fig. 6. Training and validation accuracy curves for the 1D CNN. Convergence within 80 epochs; no visible overfitting with dropout regularisation.
CSP spatial patterns
Fig. 7. CSP spatial filter patterns: topographic maps of the first and last filter columns. Clear lateralisation to left/right motor cortex (C3/C4 areas).
ClassifierMean AccuracyStd (5-fold)Parameters
1D CNN (custom)83.8%±2.1%~45,000
EEGNet83.4%±1.9%~2,500
CSP + SVM (RBF)81.2%±2.8%N/A (classical)