Skip to content
Abstracts due Jan 1512th International BCI MeetingŠibenik, Croatia • Jun 7–10, 2027
← Learn neurotechnology

15 minutes · Real public data · Optional Python

Motor imagery and benchmarking with MOABB

See mu and beta rhythms drop when a person imagines moving a hand, then train a classifier on real EEG and compare its accuracy with chance.

At rest, sensorimotor cortex produces rhythms called mu (about 8 to 13 Hz) and beta (about 13 to 30 Hz). When a person moves a hand or imagines the movement, the power of these rhythms drops over the cortex preparing the movement. This drop is called event-related desynchronization, or ERD (Pfurtscheller and Lopes da Silva, 1999).

Each hand is controlled mainly by the opposite hemisphere. Electrode C3 sits over left sensorimotor cortex, which mainly controls the right hand. Electrode C4 sits over right cortex, which mainly controls the left hand. So we expect a larger drop at C3 when the person imagines moving the right hand, and at C4 for the left hand. Cz, at the top of the head, is a reference point.

A motor imagery brain-computer interface (BCI) uses this asymmetry. The effect varies a lot between people, and some people show little of it.

  1. Keep the 10-participant average and the mu band. For each imagined hand, which channel drops more, C3 or C4?
  2. Step through the participants. Where is the expected asymmetry clear? Where is it missing?
  3. Train the classifier within each participant. How many participants beat the chance threshold? Then run the shuffled-label control.
  4. Switch to cross-participant evaluation. Compare the mean accuracy with the within-participant result.

1. See the desynchronization

Imagined left handC3C4Cz

Mean change from 0.5 to 2.5 s

C3 -19%Cz -11%C4 -20%

Larger drop: C4

Imagined right handC3C4Cz

Mean change from 0.5 to 2.5 s

C3 -21%Cz -15%C4 -6%

Larger drop: C3

A negative value means power dropped compared with the second before the cue. Curves use 250 ms bins.

2. Train and evaluate a classifier

The classifier receives each trial’s covariance matrix, filtered from 8 to 30 Hz, from 0.5 to 2.5 s after the cue. It has to guess which hand the person imagined. Linear discriminant analysis (LDA) draws a straight boundary between the two classes.

S007 · Accuracy on test trials

87%

39 of 45 trials classified correctly

Above the chance threshold

With 45 trials, random guessing exceeds 62% only 5% of the time (binomial distribution).

Each dot is one trial (S007)

● Imagined left hand■ Imagined right hand

↑ log C4log C3 →

Horizontal axis: log power at C3. Vertical axis: log power at C4.

All 10 participants, same settings

  • S00162%
  • S00269%
  • S00342%
  • S00462%
  • S00553%
  • S00649%
  • S00787%
  • S00860%
  • S00956%
  • S01073%
  • Mean61%

Green bar: above the chance threshold. Gray line: 50%. Colored line: binomial threshold for 45 trials.

How the browser calculation works

The browser loads a 160 KB excerpt. For each trial it holds the covariance matrix of 9 channels: FC3, FCz, FC4, C3, Cz, C4, CP3, CPz and CP4. Log power is the log of the variance at C3 and at C4. CSP solves a generalized eigenvalue problem on each class’s mean covariance and keeps 3 filters from each end. LDA uses a covariance pooled across both classes. In cross-validation, each class’s trials are randomly dealt (fixed seed) into 5 folds, and both CSP and LDA are refit on every training fold. The cross-participant results match scikit-learn on the same data.

EEG recordings by Schalk and colleagues (Wadsworth Center, BCI2000), distributed by PhysioNet. Cite Schalk et al. (2004) and Goldberger et al. (2000). Excerpt: participants 1 to 10, runs 4, 8 and 12 (imagined left or right fist), common average reference. Script: scripts/build-learn-motor-imagery.py. Dataset and citations ↗ · ODC-By 1.0 license ↗

3. Evaluate properly

  • Cross-validation: never score a model on the trials it was trained on. Split the trials into folds, train on all folds but one, and test on the one left out. Any step that learns from the data, such as CSP, must be refit inside each fold. Otherwise information about the test trials leaks into training and the score is too optimistic.
  • Within or across participants: a model trained and tested on the same person answers “can we calibrate a BCI for this person?” A model tested on someone left out of training answers “does it work without calibration?” The second task is harder, because head shape, electrode placement and mental strategy vary.
  • Chance level: with two balanced classes, guessing gives 50% on average. With few trials, chance can land well above 50%. Compare with a statistical threshold (binomial distribution) or with shuffled labels (Combrisson and Jerbi, 2015).
  • Many comparisons: trying many bands or time windows and reporting only the best inflates the score. Fix settings in advance, or choose them inside the training folds.

4. Go further in Python with MOABB

The notebook repeats this analysis with MNE-Python on the same 10 participants, using CSP + LDA and a Riemannian method (pyRiemann tangent space followed by logistic regression). It then compares both methods with MOABB’s WithinSessionEvaluation on the BNCI 2014-001 dataset for 2 participants.

MOABB (Mother of All BCI Benchmarks) is a NeuroTechX project. It downloads public datasets, applies the same preprocessing, and evaluates every method the same way, which makes comparisons reproducible (Jayaram and Barachant, 2018).

Download the Jupyter notebook

Open it in Jupyter or Colab after installing mne, scikit-learn, pyriemann and moabb. The first run downloads about 250 MB of public data.

What we got when we ran the notebook

  • PhysioNet, 10 participants, 5-fold cross-validation: mean accuracy 62% with CSP + LDA (2 of 10 participants above the 62% threshold) and 61% with tangent space (3 of 10). Participant S007 reaches 98% with CSP + LDA, against a 50% mean with shuffled labels.
  • PhysioNet, across participants (leave one participant out): 56% with CSP + LDA and 57% with tangent space.
  • MOABB, BNCI 2014-001, ROC AUC per session: 0.94 to 0.97 for participant 1 and 0.61 to 0.70 for participant 2. Tangent space is equal or better in every session.

Your numbers may differ slightly with other library versions.

What you can conclude

Imagining a hand movement reduces mu and beta rhythms, often more on the side opposite the hand. This signal is enough to classify trials above chance for some people, not for everyone. A score only means something alongside its evaluation method and its chance level.