Skip to content

Add Jia2019, MIBMPI2024, Ortiz2023 and Wang2025 motor-imagery datasets - #1190

Merged
bruAristimunha merged 21 commits into
NeuroTechX:developfrom
bruAristimunha:datasets/mi-figshare
Oct 4, 2026
Merged

bruAristimunha merged 21 commits into
NeuroTechX:developfrom
bruAristimunha:datasets/mi-figshare

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Port four existing MATLAB/EEGLAB motor-imagery loaders from the MI expansion/corrected branches onto current develop: Jia2019, MIBMPI2024 (was Yilmaz2024), Ortiz2023, Wang2025 (was ZjuMI2025). This is the planned MAT batch, not a claim all four use Figshare: MIBMPI2024 downloads its Zenodo release and Wang2025 uses Hugging Face. No new dataset was implemented from scratch.

  • Register metadata, API docs, imagery summary and cached DOIs.
  • Derive channel totals from channel types and forward download path/force/verbosity. update_path remains the deprecated compatibility argument.
  • Reject mismatched/invalid labels rather than silently truncating; validate shape and stored windows.
  • Correct inclusive Yilmaz/ZJU endpoints so final epochs contain no padding/next-trial sample; preserve zero-duration EDGE boundary annotations through the common annotation pipeline so filtering does not cross stored epochs.
  • Reject absent, incomplete or duplicated Ortiz EXPERIENCE task sessions; retain 27 EEG + 4 EOG. Ortiz counts are unbalanced: 32 relaxation / 16 imagery / 16 counting segments per session, with two subjects having a second session.

Deliberate exclusion: Patel2025

Compared both source variants. Expansion uses an amplitude-based 1e-9 correction; corrected source explicitly says its 1e-6 is only nominal storage in undocumented, uncalibrated native units. Neither establishes physical SI calibration. The corrected source also accepts 256-sample trials for an inclusive [0,1] interval requiring 257 samples, so one padding sample still enters the epoch. The old source additionally retains short trials by padding. Patel is not registered or ported in this PR: resolve source calibration and valid trial boundaries before upstream scientific use. This finding may affect prior paper-branch results; no reruns are launched here.

Draft / merge blockers

  • No real-data validation in this work. Only synthetic/mocked local tests; no laptop dataset downloads, no experiments. Existing source scientific claims (including units, channel ordering, retained inventory and inferred metadata) still require direct source/real-data confirmation on the authorized remote machine.
  • No verified public NEMAR mirrors for these four additions. No IDs invented, no exemption or pending-deposit registry modified, no rehosting/publication attempted. The existing test_all_datasets_have_valid_nemar_id remains intentionally failing for these four until genuine IDs and public mirror evidence are available. This is not merge-ready.
  • Summary trial counts are design/source estimates, not a newly verified retained census. Yilmaz ~110/class/subject (both sessions); Ortiz mean 25.6/class/subject (unbalanced); Jia 40/class/subject.

Local validation

Run with explicit PYTHONPATH pointing to this worktree (verified moabb.__file__), an isolated fake MNE home, existing temporary MNE_DATA, and MOABB_DOWNLOAD_PROVIDER=auto.

  • Synthetic first/last epochs, SI scaling according to source assumptions, label/shape errors, download flags, missing/duplicate sessions, session mapping and discontinuity preservation/filter isolation.
  • Metadata, offline DOI, preprocessing and explicitly selected offline registration checks.
  • Touched-file pre-commit.
  • Excluded network DOI resolution and broad dataset suite (contains unmarked real-download paths, including test_dataset_accept and TestData::test_epochs); no real-data checks represented as passed.

Results: 1083 passed, 221 skipped, 302 deselected in the bounded offline suite; 15 synthetic batch tests passed. All applicable touched-file pre-commit hooks passed. Separate NEMAR policy check: 4 expected failures, one per added dataset. DOI cache entries were preserved from the existing source branch, not newly verified by network resolution.

Simplification (2026-09-29, head f1c261b9b)

Depends on #1200. Merge #1200 (mne>=1.13, shared download/marker helpers, OpenNeuro mirror mixin) first. This branch merges it (git merge --no-ff, no rebase).

Pass 4 (ponytail): reuse existing code, no nested functions (head 2fd36dea6)

  • Merges refactor(datasets): require mne>=1.13, spell colin27 montages, share loader code #1200 at 058ae05e6, which now requires mne>=1.13 and drops the pass-3 helpers that re-implemented existing code.
  • Ortiz2023 downloads through develop's download_and_extract_subject_zip, behind the same extracted-folder check its ten develop callers use. It keeps its one warned re-download of a corrupted archive (redownload_corrupted=True). The Figshare URL has no .zip suffix, and the develop function renames the download to .zip before extracting. The archive now extracts into MNE-ortiz2023-data/MI_walking_figshare21185362/, not next to the cached archive.
  • Jia2019, Yilmaz2024 and ZjuMI2025 build their trial-join markers with mne.Annotations(onsets, 0.0, "EDGE boundary") directly, replacing edge_boundary_annotations.
  • Montage names are spelled colin27_1005/colin27_1020 directly.
  • The tests replace the nested data_dl fake and every monkeypatched lambda with Mock, and assert on call_args_list.
  • Nested functions/lambdas added by this PR: 8 → 0.
  • LOC added vs refactor(datasets): require mne>=1.13, spell colin27 montages, share loader code #1200: moabb/datasets/*.py 1030 → 1030; moabb/tests/*.py (net) 139 → 140.
  • Behaviour:
    • The class fingerprint (metadata/summary/DOI) is identical.
    • The loader fingerprint (synthetic .mat/.set files and a corrupted-then-valid archive through the real loaders) is identical apart from the recorded data_dl calls. Ortiz2023 now makes fewer calls, because it no longer looks up an archive that is already extracted (cached_calls 1 → 0).
  • Coverage (pass 3 → pass 4): jia2019 83→82, ortiz2023 86→86, yilmaz2024 92→92, zju_mi2025 97→97.
  • Proof: the offline suite (PR tests, test_loader_utils.py, test_preprocessing.py, test_datasets.py, test_metadata.py, test_doi_validation.py) had 2547 passed and 0 failed. ruff 0.15.20 and git diff --check are clean.

Pass 3: shared helpers, NEMAR skip, new montage names (head da3015ad8)

  • Ortiz2023 now calls download_and_extract_zip(..., redownload_corrupted=True). An offline probe confirmed the same behaviour as before: a corrupt archive warns, is downloaded again with force_update=True and extracted, and a second corruption raises.
  • Jia2019, Yilmaz2024 and ZjuMI2025 use edge_boundary_annotations.
  • The preprocessing.py EDGE-boundary change is now owned by refactor(datasets): require mne>=1.13, spell colin27 montages, share loader code #1200. Four PRs had each edited it differently.
  • The montage calls in Ortiz, Yilmaz and Zju use resolve_montage_name.
  • NEMAR: added to NEMAR_ID_EXEMPT (# no public NEMAR mirror yet; tracked in #1190): Jia2019, Ortiz2023, Yilmaz2024, ZjuMI2025. No ids were invented, NEMAR_ID_PENDING is untouched, and test_all_datasets_have_valid_nemar_id passes locally.
  • LOC added, measured against refactor(datasets): require mne>=1.13, spell colin27 montages, share loader code #1200 (i.e. after it merges): moabb/datasets/*.py 1038 → 1030 (-1%); moabb/tests/*.py (net) 136 → 139 (+2%; includes the NEMAR-exempt lines).
  • Coverage (pass 2 → pass 3, offline suite + test_loader_utils.py): jia2019 82→83, ortiz2023 83→86, yilmaz2024 92→92, zju_mi2025 97→97. No touched file dropped by more than 2 pp.
  • Behaviour: Fingerprints (class metadata/summary/DOI + fake data through the real loaders) identical to pass 2.
  • Proof: offline pytest <PR tests> test_loader_utils.py test_preprocessing.py test_datasets.py test_metadata.py test_doi_validation.py --cov=moabb/datasets (isolated MNE home, empty MNE_DATA, no downloads; test_dataset_accept and TestData::test_epochs deselected): 0 failed. Also ruff 0.15.20 and git diff --check.
added LOC vs develop before after pass 1 after pass 2
moabb/datasets/*.py 1385 1385 1038 (-25%)
moabb/tests/*.py (net) 155 144 136 (-12%)

PR tests collected (pass 2): 15 → 11. Coverage of touched dataset files (pass-1 before → now, offline suite): jia2019 80→82, ortiz2023 78→83, yilmaz2024 93→92, zju_mi2025 97→97, preprocessing 40→40.

Pass 2 — loaders and tests

  • 4 hand-written summary tables removed; channel/subject lists as .split(); Parameters boilerplate in private-method docstrings cut
  • unused constants and unreachable branches removed; Jia _trials inlined; simpler run detection/trial concatenation in Ortiz and Zju; Ortiz corrupted-zip retry shortened (same warning, same re-download, second corruption still raises)
  • 4 invalid-subject tests folded into the matching download-flag tests (assertion kept)
  • Kept on purpose: Jia Figshare file ids, Jia's two set_annotations calls (MNE ordering at equal onsets), all validation messages, EDGE-boundary test (only functional test of the preprocessing.py change).
  • Proof: offline pytest <PR tests> test_datasets.py test_metadata.py test_doi_validation.py --cov=moabb/datasets (isolated MNE home, no downloads; test_dataset_accept/TestData::test_epochs deselected); behaviour fingerprint before/after on fake source data (per-run data hash, channels/types, sfreq, annotations, events, montage) and class fingerprint (subjects, sessions, event_id, interval, code, DOI, METADATA hash, summary-CSV row, docstring DOIs) identical except Dataset summary rendered once instead of twice; ruff 0.15.20, git diff --check.
  • Unchanged and expected: Test_Datasets::test_all_datasets_have_valid_nemar_id[<new classes>] fails (no nemar_id, not in NEMAR_ID_PENDING) — NEMAR-ID decision still open.

Pass 1 — test audit

  • _check_epochs: removed the band-pass |x| < 1e-10 probe — all synthetic trials share one constant amplitude, so it passes with or without EDGE boundaries (tautological); the EDGE-boundary count assertion stays as the functional test of the preprocessing.py change.
  • test_download_flags: simplified to a transport stub recording (path, force_update, verbose) with one equality assert (module via sys.modules).
  • Retained on purpose: per-class invalid-subject and transport tests (every class overrides data_path), test_session_mapping (only proof of file→session/run ordering), units/first-last/missing-duplicate-session tests.
  • Tests collected 15 → 15; test LOC 155 → 144 (−7%). Coverage: jia2019 80→80%, ortiz2023 78→78%, yilmaz2024 93→93%, zju_mi2025 97→97%, preprocessing 40→40%. Proof: offline pytest <PR tests> moabb/tests/test_datasets.py moabb/tests/test_metadata.py moabb/tests/test_doi_validation.py --cov=moabb/datasets --cov-report=term-missing -p no:cacheprovider (isolated MNE home, no downloads; test_dataset_accept/TestData::test_epochs deselected). Pre-existing on this branch, untouched: Test_Datasets::test_all_datasets_have_valid_nemar_id[<new classes>] fails (no nemar_id, not in NEMAR_ID_PENDING).

…>77.6%)

Drop the tautological post-filter assertion in _check_epochs (all synthetic trials share one amplitude, so a band-pass yields ~0 regardless of EDGE boundaries) and replace the positional/keyword call-arg juggling in test_download_flags with a transport stub that records (path, force_update, verbose); module lookup now uses cls.__module__ instead of a parametrised name + importlib.

Per-file coverage unchanged: jia2019 80%, ortiz2023 78%, yilmaz2024 93%, zju_mi2025 97%, preprocessing 40%. Test LOC 155 -> 144. 14 tests collected before/after.
- resolve_montage_name (moabb.datasets._montage, re-exported by utils): MNE 1.13
  renamed standard_1005/1020 (and the other standard_* templates) to colin27_*,
  warns on the old names and 1.14 removes them. Returns the spelling the installed
  MNE knows; electrode files are byte-identical (dig positions checked equal on
  MNE 1.10.2, 1.12.1 and 1.13.2). Every make_standard_montage/set_montage call in
  moabb now goes through it; METADATA montage labels are descriptive and unchanged.
- download_and_extract_zip: download once, extract unless a marker exists,
  optional warn + forced re-download of a corrupted archive.
- read_raw_brainvision_repaired: repair stale DataFile/MarkerFile references in a
  temporary header (strict mode raises on missing entries/siblings).
- rename_stimulus_codes, edge_boundary_annotations; SetRawAnnotations keeps
  'EDGE boundary' markers.
- moabb.datasets._openneuro_mirror moved here verbatim (byte-identical copies in
  NeuroTechX#1186 and NeuroTechX#1189), with dataset-agnostic tests.
# Conflicts:
#	docs/source/whats_new.rst
#	moabb/datasets/preprocessing.py
…tage names

Merges NeuroTechX#1200 (datasets/shared-loader-helpers): local zip/BrainVision/EDGE-boundary
code replaced by moabb.datasets.utils helpers, montage calls spelled with the
MNE 1.13 colin27_* names via resolve_montage_name, new classes without a public
NEMAR mirror listed in NEMAR_ID_EXEMPT. Behaviour fingerprints unchanged.
MNE 1.13 renamed the standard_* templates to colin27_* (identical .elc
files). With the floor at 1.13 the resolve_montage_name shim and the
_montage module are not needed: every call site spells the new name.
- download_and_extract_zip -> extend download_and_extract_subject_zip with
  keyword-only fname and redownload_corrupted (defaults keep the 10
  develop callers unchanged)
- read_raw_brainvision_repaired -> mne.io.read_raw_brainvision(overrides=)
  at the call sites (MNE >= 1.13)
- edge_boundary_annotations -> mne.Annotations(onsets, 0.0, 'EDGE boundary')
- drop_native_stim / relabel_annotations / write_dataset_description ->
  drop_channels / annotations.rename / mne_bids.make_dataset_description
- tests: no nested functions, Mock data_dl
- download_and_extract_zip (Ortiz2023) -> develop's download_and_extract_subject_zip
  behind the usual extracted-folder check (keeps redownload_corrupted=True)
- edge_boundary_annotations -> mne.Annotations(onsets, 0.0, "EDGE boundary")
  in Jia2019, Yilmaz2024 and ZjuMI2025
- colin27_* montage names spelled directly (mne>=1.13)
- tests: Mock instead of monkeypatched lambdas and the nested data_dl fake
…audit)

- The secondary paper describing this release (arXiv:2604.16554, "2019-Stroke:
  ... 15 stroke patients ... 63 channels under the international 10-10 system
  at 512 Hz", 80 trials = 40 per class) is by Xiangkai Wang, not "Wang, K.";
  fix the citation and track its DOI in related_paper_dois.
- doi_cache.json: add 10.48550/arXiv.2604.16554 and 10.21203/rs.3.rs-4268007/v1
  (Yilmaz2024 open-access preprint, next commit), resolved through
  test_dois_resolve.

Evidence: ~/Projects/moabb/.paper-audit/reports/mi-figshare/Jia2019/report.md,
~/Projects/moabb/.paper-audit/Jia2019/paper-10_48550_arxiv_2604_16554.txt
…r audit)

Sources: Crossref record (published-online 2024-12-24, print 2025 vol. 37
pp. 4679-4696), the open-access Research Square preprint
10.21203/rs.3.rs-4268007/v1 (also the DOI registered on Zenodo record
13626922) and the Zenodo record description.

- investigators: "Beyda H. Yilmaz" -> "Bahar Hatipoglu Yilmaz" (Crossref).
- reference: the headset CMS/DRL sit at P9/P10 and "DC offset was removed by
  subtracting the average of the channels from each channel"; filters from
  the preprint (0.2-45 Hz bandwidth, 5th-order Sinc, 50/60 Hz notch, 0.16 Hz
  high-pass).
- participants: ages 25-35, two female, one left-handed (preprint).
- docstring: D01 recorded with 13 positions, D02-D08 with four extra sensors
  (FC1, CP1, FC2, CP2); the loader reads the same 13 channels for everyone.
- publication_year stays 2024 (online-first date and data release year).

Evidence: ~/Projects/moabb/.paper-audit/reports/mi-figshare/Yilmaz2024/report.md
… audit)

- reference/ground: "Ground and reference electrodes were located in the
  right (A2) and left (A1) ear lobes respectively" (Methods); the per-trial
  .json example lists the opposite sides, noted in the docstring.
- institution: "Miguel Hernandez University of Elche" (affiliation line).
- docstring: paper-vs-release note. The paper reports fourteen subjects over
  both scenarios; Table 1 lists nine Experience M-codes (M05-M11, M20, M21)
  with two Experience weeks for M05, M08 and M11, and M17 as the Slopes code
  of S4, whereas the loader follows the released archive (ten Experience
  M-codes incl. M17; two dates for M05 and M11 only). n_subjects stays 10
  (loader-exposed); flagged needs_real_data_check.

Evidence: ~/Projects/moabb/.paper-audit/reports/mi-figshare/Ortiz2023/report.md
… audit)

Sources: the CC-BY open-access IEEE TNSRE paper and the Hugging Face
ZJU-MI-EEG/MI4 dataset card.

- hardware/filters: "EEG signals are acquired with a 62-channel g.USBamp
  amplifier (g.Tec medical engineering, Schiedelberg, Austria) in an extended
  10-20 system sampled at 256 Hz and highpass filtered above 0.1 Hz"; the
  release ships a 62channels_gNautilus.ced file, noted as a conflict.
- participants: "Fifteen healthy subjects (average age: 24+-5.1, twelve
  males)", "Ten of them are fully naive to BCIs".
- docstring: six calibration + four feedback runs of 40 trials per session
  (paper) are merged into the two released files per day; feedback trials
  last up to 10 s online but are stored as -1..4 s windows.

Evidence: ~/Projects/moabb/.paper-audit/reports/mi-figshare/ZjuMI2025/report.md
No source presents "ZJU-MI" or "MI4" as the dataset's name in prose: the
primary paper is titled "Enhanced Online Continuous Brain-Control by Deep
Learning-Based EEG Decoding" (Jiaheng Wang, Lin Yao, Yueming Wang; IEEE
TNSRE vol. 33, 2025, 10.1109/TNSRE.2025.3591254) and never mentions "MI4";
"# MI4 Dataset" is only the Hugging Face card heading of the MI4 sub-folder
and `ZJU-MI-EEG` the repository slug. Rule 2 gives FirstAuthorYear of the
primary paper: Wang2025. Renamed class, module, code, registry, api.rst,
whats_new, summary CSV, tests and the NEMAR exemption list; no deprecated
alias (the name was never released).
The authors present MI-BMPI as the dataset's name: the Zenodo record 13626922
is titled "MI-BMPI: Motor Imagery Brain--Mobil Phone Interface Dataset" and
the paper is titled "MI-BMPI motor imagery brain-mobile phone dataset and
performance evaluation of voting ensembles utilizing QPDM" (Cagatay Murat
Yilmaz, Bahar Hatipoglu Yilmaz, Cemal Kose; Neural Computing and
Applications, published online 24 December 2024, 10.1007/s00521-024-10917-5;
Research Square preprint posted 16 April 2024). Rule 1 gives the official
name with the primary-paper year: MIBMPI2024. Renamed class, module, code,
registry, api.rst, whats_new, summary CSV, tests and the NEMAR exemption
list; no deprecated alias (the name was never released).
@bruAristimunha bruAristimunha changed the title Add Jia2019, Ortiz2023, Yilmaz2024 and ZjuMI2025 motor-imagery datasets Add Jia2019, MIBMPI2024, Ortiz2023 and Wang2025 motor-imagery datasets Sep 30, 2026
@bruAristimunha
bruAristimunha marked this pull request as ready for review October 4, 2026 17:08
@bruAristimunha
bruAristimunha merged commit 1fe3c74 into NeuroTechX:develop Oct 4, 2026
9 of 11 checks passed
@bruAristimunha
bruAristimunha deleted the datasets/mi-figshare branch October 6, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant