Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - MiviaLab/MIRACLE · GitHub
Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - MiviaLab/MIRACLE · GitHub
Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - MiviaLab/MIRACLE · GitHub
Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - MiviaLab/MIRACLE · GitHub
Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - MiviaLab/MIRACLE · GitHub
Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - MiviaLab/MIRACLE · GitHub
Skip to content

Repository files navigation

EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework

Simone Bove, Martino Giaquinto*, Member, IEEE, Gennaro Percannella, Member, IEEE, Alessia Saggese, Member, IEEE, Mario Vento, Member, IEEE

All the authors are with the Department of Information and Electrical Engineering and Applied Mathematics (DIEM), University of Salerno, Fisciano, 84084 Italy.

*Corresponding author: mgiaquinto@unisa.it

All the authors contributed equally to this work.


Official repository for the paper "EEG-based Motor Imagery empowered by Subject Identification in a Multi-task and Multi-scale framework", introducing MIRACLE, a multi-task, multi-scale deep learning architecture for EEG-based Motor Imagery (MI) classification jointly trained with a Subject Identification (SI) auxiliary task.

Note: This repository contains only the code required to test/evaluate the pretrained MIRACLE model. Pretrained model weights and the preprocessed test datasets are not included in this repository and must be downloaded separately (see Download below).


Table of Contents


Overview

MIRACLE is designed to improve Motor Imagery decoding from EEG signals by leveraging subject-specific information through a multi-task learning framework, combined with a multi-scale, frequency-selective feature extraction strategy.

This repository provides the test/inference pipeline used to reproduce the evaluation results reported in the paper on the:

  • BCI Competition IV 2008 Dataset 2a
  • BCI Competition IV 2008 Dataset 2b
  • OpenBMI
  • PhysioNetMI

MIRACLE Architecture

The figure below shows an overview of the proposed MIRACLE architecture, comprising:

  • (a) Normalization block — based on Z-score standardization of the input EEG signals.
  • (b) Frequency-Selective Multi-Scale (FSMS) block — four parallel convolutional branches paired with Squeeze-and-Excitation (SE) modules, designed to capture discriminative patterns across multiple frequency scales.
  • (c) Feature-Selective Global Temporal (FSGT) block — integrates SE-based feature weighting with a Transformer encoder to model long-range temporal dependencies.
  • (d) Multi-Task Classification (MTC) block — two classification heads, one for Motor Imagery (MI) classification and one for Subject Identification (SI), trained jointly to improve generalization and subject-invariant/subject-aware feature learning.

MIRACLE architecture overview

Figure: Overview of the proposed MIRACLE architecture — (a) normalization, (b) FSMS block, (c) FSGT block, (d) MTC block.

Repository Structure

.
├── README.md
├── requirements.txt
├── MIRACLE.py # MIRACLE model definition (FSMS, FSGT, MTC blocks)
├── test_motor_imagery.py # Test / inference entry point
├── preprocess_test_OpenBMI.py # Merges the split OpenBMI test set into a single .npz file
├── utils.py # Data loading, normalization, metrics, losses, network factory
├── Test_Sets/ # >>> downloaded test data goes here (flat .npz files, no subfolders) <<<
│ ├── test_2a.npz
│ ├── test_2b.npz
│ ├── test_OpenBMI.npz # created by preprocess_test_OpenBMI.py after merging the two downloaded parts
│ └── test_PhysioNetMI.npz
└── Weights_Models/ # >>> downloaded model weights archive extracts here, with these subfolders already included <<<
├── Results_2a/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed71_validation_log.txt
│ └── MIRACLE_seed71_best_model_fold{N}.pth
├── Results_2b/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed157_validation_log.txt
│ └── MIRACLE_seed157_best_model_fold{N}.pth
├── Results_OpenBMI/
│ ├── MIRACLE_mean_data.pt
│ ├── MIRACLE_std_data.pt
│ ├── MIRACLE_seed149_validation_log.txt
│ └── MIRACLE_seed149_best_model_fold{N}.pth
└── Results_PhysioNetMI/
├── MIRACLE_mean_data.pt
├── MIRACLE_std_data.pt
├── MIRACLE_seed131_validation_log.txt
└── MIRACLE_seed131_best_model_fold{N}.pth

Requirements

  • Python 3.9
  • PyTorch
  • einops
  • NumPy
  • scikit-learn
  • Matplotlib
  • Seaborn

Install all dependencies with:

pip install -r requirements.txt

Download

Since the pretrained MIRACLE model weights and the preprocessed test datasets are not hosted in this repository, they must be downloaded from the corresponding release before running the test scripts:

  • 🔗 Model weights release

  • 🔗 Test sets release

  • Model weights: distributed as a single archive that already contains the correct subfolder structure (Weights_Models/Results_2a/, Weights_Models/Results_2b/, Weights_Models/Results_OpenBMI/, Weights_Models/Results_PhysioNetMI/). Simply extract it in the repository root — no manual reorganization needed.

  • Test datasets: distributed as individual .npz files. Create a Test_Sets/ folder in the repository root (if not already present) and place all downloaded test files directly inside it (flat, no subfolders):

Test_Sets/test_2a.npz
Test_Sets/test_2b.npz
Test_Sets/test_OpenBMI_first.npz
Test_Sets/test_OpenBMI_last.npz
Test_Sets/test_PhysioNetMI.npz

Note on the OpenBMI test set: since it exceeds 2GB, it is distributed split into two parts, test_OpenBMI_first.npz and test_OpenBMI_last.npz. After placing both inside Test_Sets/, merge them into a single test_OpenBMI.npz file by running:

python preprocess_test_OpenBMI.py

This concatenates the two parts into Test_Sets/test_OpenBMI.npz and automatically deletes the two original split files. All other test sets (2a, 2b, PhysioNetMI) are ready to use as downloaded, with no preprocessing needed.

Once everything is extracted and placed as described, the folder layout should match Repository Structure above.

Datasets

Evaluation is performed on the following public EEG Motor Imagery benchmarks:

  • BCI Competition IV — Dataset 2a: 4-class Motor Imagery (left hand, right hand, feet, tongue), recorded from 9 subjects using 22 EEG channels.
  • BCI Competition IV — Dataset 2b: 2-class Motor Imagery (left hand, right hand), recorded from 9 subjects using 3 EEG channels.
  • OpenBMI: large-scale public EEG Motor Imagery dataset (Lee et al., 2019), 2-class Motor Imagery (left hand, right hand), recorded from 54 subjects using 62 EEG channels.
  • PhysioNetMI: EEG Motor Movement/Imagery dataset (Schalk et al., 2004), 2-class Motor Imagery (left hand, right hand), evaluated here on 106 subjects using 64 EEG channels.

Only the test partitions required to reproduce the paper's results are provided via the download link above; the raw/original datasets are publicly available from the respective official sources for research purposes.

During training, the MI and SI task losses are combined with a weighting coefficient α, set to 0.001 for Dataset 2a, 0.01 for Dataset 2b, 0.001 for OpenBMI, and 0.1 for PhysioNetMI.

Results

The tables below report the per-subject classification accuracy (%) obtained on the test sets, across all the seeds evaluated for each dataset. For simplicity, only the model weights of the best-performing seed per dataset are made available for download (highlighted in bold below): seed 71 for Dataset 2a and seed 157 for Dataset 2b.

Dataset 2a (α = 0.001)

SeedS1S2S3S4S5S6S7S8S9Average
4287.1564.2494.4477.7854.5168.0687.8585.7678.1277.55
71 (best)86.8170.4994.4481.9467.0170.1487.5086.8177.7880.32
10186.4668.7592.7179.1745.4965.9781.9484.7282.6476.43
11385.7666.3294.4477.7861.1167.7190.2886.8184.3879.40
12786.4659.3795.1477.4375.6965.9785.7682.6477.7878.47
13184.0358.3393.7578.1271.8767.3689.2485.0774.3178.01
13985.0758.6893.7578.1257.9964.5889.9386.1177.7876.89
14986.1165.2895.4976.7448.9670.1490.2888.1982.9978.24
15786.4658.3394.7979.1754.5169.4485.4286.8186.1177.89
16384.3861.4694.7973.6154.8667.0189.2482.9979.1776.39
17386.8158.3393.4073.6152.0864.5873.6187.5082.6474.73
18185.7667.3695.4978.8252.4364.9381.6085.0780.9076.93
32285.4264.5895.1481.9448.9667.7186.1187.1580.2177.47
52182.9963.1994.1077.7861.4669.1088.5484.3881.2578.09
Average85.6963.1994.4278.0057.6467.3486.2485.7280.4377.63

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 71) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset 2b (α = 0.01)

SeedS1S2S3S4S5S6S7S8S9Average
4278.7573.2182.1993.4497.5085.0091.8796.5687.1987.30
7178.1272.1482.5094.6999.0682.1991.8796.2589.0687.32
10179.3772.1484.3895.0098.4488.7591.8796.8887.1988.22
11378.1272.5083.4496.2598.4488.1292.8195.6386.5687.99
12779.3771.0782.8194.3897.5085.3192.5095.9488.4487.48
13177.8170.3682.1995.6396.8886.8791.2595.9486.8787.09
13975.0071.4383.7589.6997.8187.5093.7596.2588.1287.03
14978.4469.6484.6995.9498.1283.4491.5695.3187.8187.22
157 (best)79.3774.2986.2593.4497.5089.0692.1997.1989.6988.78
16378.4472.8685.3194.6998.1285.6291.2596.2587.5087.78
17379.0671.0782.1995.6397.8184.0692.5095.9488.1387.38
18177.5071.4384.3893.4498.1288.1392.8195.9487.8187.73
32276.5672.1485.3195.0098.1287.5092.1996.5689.0688.05
52181.2573.5785.0095.6397.8186.2592.8195.3187.8188.38
Average78.3771.9983.8894.4997.9486.2792.2396.1487.9587.70

Values are per-subject classification accuracy (%) on the MI task test set. The bolded row (seed 157) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset OpenBMI (α = 0.001)

Subject4271101113127131139149157163173181322521Average
S187.0084.5085.0087.0083.0085.5086.0083.5085.5084.5081.0085.0086.0082.0084.68
S279.0084.0080.5081.5084.0078.5084.5082.5079.5080.0081.0080.0081.0082.0081.29
S398.5098.0097.0098.5097.0096.0098.5099.0099.5097.5097.0098.0098.0097.5097.86
S487.5086.5080.5083.5088.0087.0086.5090.5084.5088.5086.0089.0091.0090.0087.07
S586.0089.5089.5088.0092.0087.5092.0090.0087.5085.0087.5086.5088.5089.0088.46
S699.0097.5098.0097.5099.5098.0098.0099.0098.0099.0098.0098.5099.5098.5098.43
S783.5085.0080.0085.0086.5083.5086.0085.0084.5086.5086.0088.0084.0087.5085.07
S888.0087.5086.0087.5088.0085.0091.5088.5089.5086.5087.0085.0086.0085.5087.25
S983.5082.5085.5082.5082.5082.5085.0082.0085.5082.5082.5082.0084.0084.5083.36
S1068.0066.5067.0071.5068.5067.0073.5068.0072.0067.0066.0067.5072.5069.0068.86
S1173.0073.0073.0072.5073.0073.0072.0075.5072.5074.0076.0073.0073.0073.5073.36
S1286.0084.0086.0084.5082.0082.0083.0083.0084.0083.0083.0087.0085.0081.5083.86
S1377.0078.5071.5070.5073.5078.5070.5079.5077.0072.0073.0074.5071.0074.5074.39
S1472.0062.0072.0076.0066.5068.5070.0072.5068.0067.5081.0071.5074.0065.5070.50
S1591.0085.0089.0087.5086.0090.0083.5089.5087.0090.0084.5088.0089.0088.5087.75
S1693.0091.5092.0090.5092.5093.5092.5092.0092.5090.0091.5091.5090.5092.0091.82
S1775.0070.0075.5071.5074.0071.0076.0072.5071.0071.5069.0067.0069.5068.5071.57
S1894.5089.0094.5089.5094.0094.0093.5095.5096.0087.5093.5096.0092.0093.0093.04
S1984.5082.5088.5082.0088.0084.5086.0086.0085.0085.0086.0088.5084.5083.5085.32
S2094.5089.5092.0092.0093.0093.5091.5092.0093.0093.0091.5094.0091.5093.0092.43
S2199.0099.50100.0099.00100.00100.00100.00100.0099.5099.5098.5098.50100.00100.0099.54
S2283.5085.5084.5083.0084.5084.0085.5084.5084.5081.0084.0085.5079.5084.0083.82
S2375.5074.0076.0076.0076.0069.5071.5067.5074.0079.0074.5074.0073.0070.0073.61
S2460.5055.0065.0062.5053.5060.5056.5059.5061.0061.5066.0060.5063.0061.0060.43
S2599.0099.0099.5098.5098.0099.5097.5098.0099.0099.0099.5099.0099.0099.0098.82
S2683.0086.0085.5082.0086.0085.5085.5084.0086.5085.5089.0085.0085.5087.0085.43
S2794.5093.5093.5093.0086.5094.0091.0094.5092.5094.0095.0092.5093.5094.0093.00
S2896.5096.0097.0098.5093.5097.5095.0096.0096.0097.5096.0097.5098.0095.5096.46
S2986.5090.5085.0088.0092.0086.0087.5090.0087.0087.5087.5089.5086.5088.5088.00
S3075.0073.0074.5076.5074.0073.5075.0076.5078.5072.0074.0076.5074.0075.0074.86
S3187.0086.0087.0085.0085.5086.5087.0086.0083.0084.5086.5085.5085.0088.0085.89
S3296.0097.5098.0098.0097.0097.0098.5098.0097.5097.5097.5096.5097.5096.5097.36
S3398.5098.5098.0097.5098.5098.0098.0099.0098.0098.0098.0098.5099.0098.5098.29
S3466.0066.0069.5067.0071.5062.5065.5067.5067.0062.5070.0067.0066.0066.5066.75
S3591.5095.0093.0093.5092.0092.5094.5095.5095.0093.5093.5093.5093.0093.5093.54
S3699.0099.0098.50100.0098.5099.5098.5098.5099.0099.00100.0098.5099.50100.0099.11
S3797.0097.0095.5096.5097.0093.0098.0098.0096.5096.0097.5096.0096.5098.5096.64
S3873.5079.0072.5071.0074.5074.0081.5081.0080.0070.5078.0084.5077.0080.5076.96
S3989.0090.0087.5088.5086.5090.0090.0090.0088.5087.0088.0089.0090.0089.5088.82
S4082.5081.5080.5080.5085.0079.0083.5083.0078.5082.5079.5089.0078.5083.5081.93
S4175.0077.5077.5079.0079.0076.0082.5080.5079.0078.0082.5080.5080.5082.5079.29
S4276.5077.5075.5076.5077.0077.0074.0074.0077.0076.0076.5076.0076.0074.5076.00
S4389.5087.5086.5087.0089.5090.0089.0093.5087.5088.0084.0090.0088.5090.5088.64
S4495.5094.0095.5095.5091.5095.5093.0093.5096.0095.5095.0095.5096.0094.0094.71
S4590.0093.0091.0092.5090.5093.5091.5089.5090.0092.0088.5092.0092.5091.5091.29
S4685.5081.5083.5086.5081.0082.5084.0085.5083.0084.5085.0084.0081.0084.5083.71
S4788.0091.0092.5091.0091.5093.0093.0091.5092.0089.5094.0096.5087.0093.5091.71
S4882.0083.0082.5084.5083.0078.5079.0083.0081.0081.5082.0085.5080.5083.0082.07
S4989.5092.5086.5085.5088.5087.5089.5093.5088.5090.0083.5089.5090.0089.0088.82
S5055.5062.0061.5062.5065.5057.0059.0061.0061.5053.0065.5056.5057.5061.0059.93
S5183.5083.5084.0083.0084.0081.0084.5082.5086.0084.5083.5082.0085.0082.5083.54
S5290.0090.5090.0092.0090.5092.0089.5092.0089.5088.5093.0091.0089.5092.0090.71
S5379.5080.5079.0082.0080.0079.5079.5076.0079.0078.5080.5078.0082.0084.0079.86
S5475.5075.0076.0073.0072.0074.5072.0072.5073.0072.5074.0076.0074.5071.0073.68
Average84.9884.7684.9184.8984.9184.4285.1985.5885.1284.2685.2085.5684.9185.2184.99

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 149) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Dataset PhysioNetMI (α = 0.1)

Subject4271101113127131139149157163173181322521Average
S192.8686.6186.6186.6186.6186.6186.6186.6186.6186.6192.8692.8686.6186.6187.95
S286.6180.3685.7185.7186.6185.7193.7585.71100.0085.71100.0079.46100.0086.6188.71
S380.3674.1174.1167.8674.1180.3674.1186.6167.8674.1180.3680.3674.1180.3676.34
S4100.0093.75100.00100.00100.00100.0092.8692.8687.50100.00100.0092.86100.00100.0097.13
S554.4666.9654.4654.4660.7167.8666.9648.2166.9654.4654.4648.2155.3654.4657.71
S692.8692.8692.86100.00100.00100.0092.8685.7192.86100.0092.8692.8685.71100.0094.39
S7100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S887.5087.5093.7587.5093.7593.7593.7593.7593.7587.5087.5093.7586.6187.5090.56
S987.5080.3666.9679.4674.1174.1187.5079.4681.2587.5087.5079.4673.2187.5080.42
S1073.2166.0786.6166.0773.2173.2179.4666.0780.3673.2180.3672.3280.3686.6175.51
S1178.5793.7587.5085.7185.7185.7185.7185.7185.7192.86100.0078.5785.7192.8687.43
S1280.3686.6192.8686.6186.6192.8692.8692.8692.8692.8686.6186.6180.3686.6188.40
S1367.8659.8267.8679.4666.9673.2174.1175.0054.4660.7173.2159.8266.9675.0068.17
S1480.3674.1186.6173.2167.8686.6186.6186.6187.5093.7574.1193.7585.7193.7583.61
S15100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1665.1857.1471.4364.2964.2951.7950.8978.5778.5773.2157.1466.0768.7557.1464.60
S1792.8692.86100.0085.7185.7192.86100.00100.0092.8692.8685.7186.6192.8685.7191.90
S18100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S1986.6186.6180.3679.4679.4686.6181.2586.6187.5080.3679.4679.4686.6173.2182.40
S2092.8692.8692.86100.0092.8692.86100.0092.8692.86100.0092.8685.7192.8692.8693.88
S2161.6162.5055.3655.3662.5061.6168.7562.5062.5062.5068.7555.3681.2562.5063.08
S22100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S2385.7185.7192.8685.7186.6178.5778.5780.3680.3686.6185.7185.7185.7186.6184.63
S2468.7555.3667.8680.3675.0062.5067.8681.2567.8667.8662.5061.6174.1168.7568.69
S2587.5055.3650.0075.0068.7568.7575.0062.5062.5062.5056.2580.3681.2568.7568.18
S2633.0432.1438.3939.2921.4326.7927.6826.7920.5433.0432.1425.8925.8926.7929.27
S2780.3674.1173.2166.9674.1166.9673.2174.1174.1166.9674.1173.2179.4679.4673.60
S2879.4673.2166.9687.5066.9686.6173.2166.9674.1174.1180.3673.2166.9679.4674.93
S2985.7185.7192.8685.7185.7185.7185.7185.7185.7186.6185.7185.7185.7192.8686.80
S3086.6186.6186.6180.3680.3686.6180.3680.3680.3680.3686.6186.6186.6186.6183.93
S3193.7593.7586.6187.5086.6193.7587.5093.7593.7593.7593.7593.7580.3686.6190.37
S32100.00100.0093.75100.00100.0092.8692.8692.86100.0092.86100.00100.0092.8692.8696.49
S3393.7575.0093.7593.7593.75100.0087.50100.00100.00100.00100.00100.0093.7593.7594.64
S3471.4371.4385.7178.5778.5771.4357.1485.7178.5785.7192.8664.29100.0078.5778.57
S3578.5778.5778.5778.5778.5778.5778.5771.4378.5785.7185.7178.5778.5778.5779.08
S3674.1174.1180.3680.3680.3680.3674.1180.3680.3674.1174.1174.1174.1174.1176.79
S3792.8692.8692.8671.4392.8685.7192.8685.7185.7157.1485.7192.8671.4385.7184.69
S3867.8660.7156.2575.0066.9673.2156.2556.2548.2149.1166.0755.3662.5062.5061.16
S3959.8281.2581.2566.9680.3681.2581.2581.2580.3681.2566.9681.2566.9681.2576.53
S40100.00100.00100.00100.0093.75100.0093.75100.00100.00100.00100.00100.0093.75100.0098.66
S41100.00100.00100.0093.7593.7593.7593.7593.7593.75100.0093.75100.00100.00100.0096.88
S4285.7192.8685.7192.8685.7185.7186.6192.8692.8687.5092.8685.7192.8678.5788.46
S4386.6179.4678.5786.6185.7186.6179.4693.7572.3272.3293.7579.4693.7579.4683.42
S4487.5080.3687.5087.5087.5080.3680.3687.5087.5087.5087.5081.2580.3687.5085.01
S4554.4660.7160.7161.6160.7160.7160.7167.8667.8667.8660.7161.6160.7160.7161.92
S4660.7152.6866.0752.6859.8266.9652.6860.7166.9660.7174.1152.6859.8259.8260.46
S4785.7192.8685.7186.6186.6181.2581.2575.0075.0087.5079.4686.6179.4693.7584.06
S4892.86100.00100.0092.86100.00100.00100.00100.00100.00100.00100.00100.00100.0092.8698.47
S4980.3680.3686.61100.0087.5080.3686.61100.0092.8686.6193.7587.5080.36100.0088.78
S5080.3679.4685.7180.3687.5093.7572.3266.0780.3680.3679.4671.4371.4387.5079.72
S5164.2971.4378.5778.5786.6192.8679.46100.0085.7192.8678.5792.8666.9692.8682.97
S52100.00100.00100.00100.00100.00100.0092.86100.00100.00100.00100.00100.0092.86100.0098.98
S5393.75100.00100.00100.0093.75100.00100.00100.0093.7593.75100.00100.00100.0093.7597.77
S54100.0092.86100.0093.75100.00100.00100.00100.0093.75100.00100.0093.7586.61100.0097.19
S5586.6186.6186.6192.8686.6192.8686.6192.8692.8692.8686.6192.8686.6192.8689.73
S56100.0092.8692.86100.0092.86100.00100.00100.00100.0085.71100.0092.8685.71100.0095.92
S5793.7593.7593.7593.7593.75100.0093.7593.75100.0093.7593.7593.7593.7593.7594.64
S5887.5080.3685.7180.3680.3686.6186.6187.5086.6187.5087.5086.6193.7587.5086.03
S5959.8251.7958.9373.2152.6852.6866.0752.6858.9366.0758.9366.0765.1866.0760.65
S6093.7593.7586.61100.0093.7593.7593.75100.0093.7593.7593.75100.0093.75100.0095.03
S61100.00100.00100.0092.86100.0092.8692.8692.8692.86100.0092.86100.0092.86100.0096.43
S62100.00100.00100.0092.86100.00100.00100.00100.0093.75100.00100.00100.00100.00100.0099.04
S6358.9366.9665.1873.2173.2173.2166.0765.1858.9373.2174.1173.2165.1865.1867.98
S6464.2957.1450.0050.0050.0057.1450.0050.0057.1450.0050.0057.1457.1457.1454.08
S6581.2581.2587.5087.5087.5087.5087.5087.5087.5080.3687.5087.5086.6187.5086.03
S6665.1872.3266.0780.3680.3680.3680.3673.2173.2173.2166.0779.4674.1180.3674.62
S6752.6851.7964.2964.2957.1464.2964.2964.2964.2957.1464.2939.2950.8964.2958.80
S6887.5081.2587.5081.2581.2587.5087.5081.2581.2587.5081.2575.0081.2587.5083.48
S6979.4693.75100.0093.7592.8693.7586.6193.7586.6192.8679.4685.7178.5779.4688.33
S70100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S7173.2187.5080.3687.5086.6187.5073.2187.5093.7587.5073.2180.3680.3693.7583.74
S7250.8958.0465.1879.4679.4672.3272.3266.0772.3273.2179.4679.4672.3272.3270.92
S7378.5771.4378.5778.5764.2971.4364.2971.4364.2964.2971.4371.4378.5771.4371.43
S7471.4385.7178.5771.4385.7178.5771.4385.7192.8671.4371.4364.2978.5778.5777.55
S7573.2186.6179.4687.5066.0773.2180.3666.9692.8673.2193.7573.2172.3272.3277.93
S7671.4378.5771.4378.5785.7178.5771.4385.7185.7171.4378.5778.5785.7178.5778.57
S7765.1872.3279.4672.3280.3673.2165.1878.5772.3286.6179.4672.3279.4686.6175.96
S7873.2167.8666.9666.9660.7174.1166.9667.8666.9672.3266.9679.4680.3680.3670.79
S7978.5772.3286.6186.6172.3272.3278.5772.3286.6172.3271.4378.5785.7172.3277.61
S8093.7592.8687.50100.00100.00100.0093.7587.5087.5086.6193.7586.61100.0093.7593.11
S8179.4693.7593.7586.6193.7593.7593.7593.7593.7593.7592.8686.6186.6193.7591.14
S8286.6186.6186.6186.6180.3692.8686.6192.8686.6185.7186.6186.6186.6179.4686.48
S8365.1858.9368.7558.9373.2159.8259.8274.1173.2161.6144.6478.5760.7166.0764.54
S8487.5068.7575.0081.2581.2587.5075.0075.0075.0075.0087.5087.5067.8693.7579.85
S85100.00100.00100.00100.00100.00100.00100.00100.00100.0093.75100.0093.75100.00100.0099.11
S86100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00100.00
S8752.6846.4341.0753.5752.6853.5747.3233.9354.4649.1146.4347.3241.0740.1847.13
S8879.4673.2179.4673.2173.2174.1180.3680.3680.3674.1179.4673.2180.3686.6177.68
S8993.75100.0093.7593.75100.00100.0093.75100.0092.86100.00100.00100.0092.8693.7596.75
S90100.0093.7593.7593.7587.5093.7592.8686.6193.7593.7593.75100.0087.5086.6192.67
S9172.3278.5778.5772.3272.3272.3272.3278.5778.5778.5778.5772.3272.3278.5775.44
S9275.00100.00100.0087.5087.5093.7581.2581.2593.7587.5093.7581.2587.5093.7588.84
S9333.0450.8944.6451.7946.4339.2944.6439.2951.7945.5453.5747.3259.8238.3946.17
S9493.7593.75100.00100.0093.75100.0093.75100.0087.5093.7593.7593.7593.7587.5094.64
S9593.7587.5093.7587.5079.4680.3679.4693.7586.6187.5087.5093.7593.7586.6187.95
S9641.0745.5433.9333.0445.5439.2940.1833.0426.7956.2539.2947.3247.3240.1840.63
S9772.3287.5073.2187.5087.5073.2166.0781.2573.2152.6879.4680.3681.2559.8275.38
S9893.7593.7593.75100.00100.00100.00100.0093.75100.00100.00100.0093.7587.5087.5095.98
S9971.4364.2971.4364.2971.4371.4364.2971.4364.2971.4371.4364.2964.2971.4368.37
S10093.7593.7593.7593.7593.75100.0087.50100.0093.7587.50100.0093.7587.5087.5093.30
S10180.3674.1174.1173.2167.8674.1174.1180.3680.3679.4680.3680.3674.1174.1176.21
S10287.5081.2593.7593.75100.0093.7581.2581.2593.7593.7593.7587.50100.0087.5090.62
S10373.2166.9672.3272.3266.9673.2173.2173.2166.9666.0766.9659.8266.0759.8268.36
S10453.5760.7146.4366.9652.6846.4345.5446.4353.5751.7954.4646.4345.5460.7152.23
S10580.3686.6180.3680.3680.3686.6186.6180.3674.1186.6186.6174.1192.8674.1182.15
S10666.9658.0485.7165.1873.2171.4372.3265.1879.4665.1872.3271.4371.4373.2170.79
Average80.5780.3381.8582.0881.4382.4780.2781.7881.9281.2882.4080.8081.0982.0981.45

Values are per-subject classification accuracy (%) on the MI task test set; subjects are listed as rows and seeds as columns (the opposite orientation of the BCI IV 2a/2b tables above, given the larger number of subjects). The bolded column (seed 131) is the one whose model weights are provided via the Download link and used in the Usage example commands below.

Usage

Once models and datasets have been downloaded and placed in the correct folders (remember to merge the OpenBMI test set first, see Download), run the test script specifying the test set, the saved-results folder, and the seed of the model weights to evaluate:

python test_motor_imagery.py \
--test_set Test_Sets/test_2a.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2a \
--seed 71 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_2b.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_2b \
--seed 157 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_OpenBMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_OpenBMI \
--seed 149 \
--paradigm Cross
python test_motor_imagery.py \
--test_set Test_Sets/test_PhysioNetMI.npz \
--name_model MIRACLE \
--saved_path Weights_Models/Results_PhysioNetMI \
--seed 131 \
--paradigm Cross

Results (F1, accuracy, balanced accuracy, and Cohen's kappa for both the MI and SI tasks) are saved to {saved_path}/Final_results_{name_model}_seed{seed}.json.

Note: This paper is currently under review. Citation details will be added once the work is accepted and published.

Citation

If you find this repository useful in your research, please consider citing our paper (citation will be added after publication).


Contact

For questions or further information, please contact the authors of the paper.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages