moabb.paradigms.MotorImagery#
- class moabb.paradigms.MotorImagery(n_classes=None, fmin=8, fmax=32, events=None, tmin=0.0, tmax=None, baseline=None, channels=None, resample=None, scorer=None, overlap=None, reject_by_annotation=True)[source]#
N-class motor imagery.
By default, metric is ‘roc-auc’ if 2 classes and ‘accuracy’ if more
- Parameters:
events (List of str) – event labels used to filter datasets (e.g. if only motor imagery is desired).
n_classes (int,) – number of classes each dataset must have. If events is given, requires all imagery sorts to be within the events list.
fmin (float (default 8)) – cutoff frequency (Hz) for the high pass filter.
fmax (float (default 32)) – cutoff frequency (Hz) for the low pass filter.
Notes
Why 8-32 Hz by default. The default band-pass filter (
fmin=8,fmax=32) keeps the mu (about 8-13 Hz) and beta (about 13-30 Hz) rhythms, whose event-related desynchronization and synchronization carry most of the motor-imagery information. It also removes slow drifts and most ocular activity, and limits the high-frequency muscle activity that a classifier could otherwise exploit instead of brain activity [3]. MOABB applies the same preprocessing to every dataset so that pipelines are compared on equal terms: the MOABB benchmark [1] filters all motor-imagery datasets to 8-32 Hz, following the BCI literature [2]. The filter is an IIR filter with MNE’s default parameters (4th-order Butterworth, applied forward and backward).The default serves comparability; it is not a requirement. If your pipeline needs another band (deep-learning models often use a wider one), change it and report the band you used:
MotorImagery(fmin=4, fmax=40)filters to another band.MotorImagery(fmin=None, fmax=None)disables the filter.fmin=Nonealone gives a low-pass filter atfmax, andfmax=Nonealone a high-pass filter atfmin.FilterBankMotorImageryapplies a bank of bands, set with itsfiltersargument.
To get the signal with no paradigm preprocessing at all, load it from the dataset object (
dataset.get_data()) instead of from the paradigm.References
[1]S. Chevallier, I. Carrara, B. Aristimunha, P. Guetschel, S. Sedlar, B. Lopes, S. Velut, S. Khazem and T. Moreau. The largest EEG-based BCI reproducibility study for open science: the MOABB benchmark. arXiv:2404.15319 (2024). https://arxiv.org/abs/2404.15319
[2]C. S. Nam, A. Nijholt and F. Lotte (eds.). Brain-Computer Interfaces Handbook: Technological and Theoretical Advances. CRC Press (2018).
[3]V. Jayaram and A. Barachant. MOABB: trustworthy algorithm benchmarking for BCIs. Journal of Neural Engineering 15(6), 066011 (2018). https://doi.org/10.1088/1741-2552/aadea0
- property datasets#
Property that define the list of compatible datasets.
- is_valid(dataset)[source]#
Verify the dataset is compatible with the paradigm.
This method is called to verify dataset is compatible with the paradigm.
This method should raise an error if the dataset is not compatible with the paradigm. This is for example the case if the dataset is an ERP dataset for motor imagery paradigm, or if the dataset does not contain any of the required events.
- Parameters:
dataset (
BaseDataset) – The dataset to verify.
- property scoring#
Property that defines scoring metric (e.g. ROC-AUC or accuracy or f-score), given as a sklearn-compatible string or a compatible sklearn scorer.