Skip to content

Add 8 SSVEP dataset adapters (357+ subjects, 9 classes) - #1024

Merged
bruAristimunha merged 24 commits into
developfrom
feature/ssvep-dataset-adapters
Mar 5, 2026
Merged

bruAristimunha merged 24 commits into
developfrom
feature/ssvep-dataset-adapters

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Mar 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add 9 dataset adapters to moabb/datasets/:
    • 8 SSVEP adapters covering 357+ subjects
    • 1 ERP/P300 adapter (Lee2021Mobile_ERP)
Dataset Subjects Classes Paradigm Format
Liu2020BETA 70 40 JFPM keyboard MAT (Tsinghua)
Liu2022EldBETA 100 9 JFPM elderly BIDS/GDF (patched)
Kim2025BetaRange 40 40 Beta-range JFPM MAT (Figshare)
Dong2023 59 40 JFPM MAT (Zenodo)
Lee2021Mobile_SSVEP 24 3 Mobile BCI BrainVision (OSF)
Lee2021Mobile_ERP 24 2 Mobile P300 BrainVision (OSF)
Chen2017SingleFlicker 12 4 Spatial coding MAT (Zenodo)
Wang2021Combined 8 4 Combined SSVEP CNT (Figshare, RAR)
Han2024Fatigue 24 32 Low+high freq fatigue MAT (Zenodo)
  • Add shared utilities to moabb/datasets/utils.py: build_raw_from_epochs(), TSINGHUA_64CH_NAMES, FIGSHARE_DL_URL
  • Liu2022EldBETA now loads BIDS/GDF at 1000 Hz, with GDF header patching + trailing NaN cropping for incomplete records
  • Update summary tables:
    • summary_ssvep.csv: 8 new rows
    • summary_p300.csv: 2 rows (Lee2021Mobile_ERP, ErpCore2021)

Review-Driven Fixes Included

  • ParticipantMetadata.bci_experience corrected to "mixed" for Liu2020BETA
  • build_raw_from_epochs() extended with optional ch_types support
  • Kim2025BetaRange now maps mastoid channels to misc when building Raw objects
  • Chen2017SingleFlicker switched from private mne soft import helper to importlib.import_module("pyxdf") + explicit error messaging

Closes

Closes #883, closes #880, closes #894, closes #887, closes #877, closes #872, closes #890, closes #891

Test Plan

  • python -c "from moabb.datasets import Liu2020BETA, Liu2022EldBETA, Kim2025BetaRange, Dong2023, Lee2021Mobile_SSVEP, Lee2021Mobile_ERP, Chen2017SingleFlicker, Wang2021Combined, Han2024Fatigue"
  • pytest moabb/tests/test_datasets.py -x --timeout=60
  • pytest moabb/tests/test_metadata.py -q
  • pre-commit run --files moabb/datasets/utils.py moabb/datasets/ssvep_kim2025.py moabb/datasets/ssvep_liu2020.py moabb/datasets/ssvep_chen2017.py
  • CI tests on full test suite
  • Download + smoke test for each dataset (requires data access)

New ssvep_moabb_adapters/ package with verified data loaders for:
- Liu2020BETA: 70 subjects, 40-class JFPM benchmark (Tsinghua)
- Liu2022EldBETA: 100 elderly subjects, 9-class JFPM (Figshare)
- Kim2025BetaRange: 40 subjects, 40-class extended-freq JFPM (Figshare)
- Dong2023: 59 subjects, 40-class 8-channel SSVEP (Google Drive)
- Han2024Fatigue: 24 subjects, 32-class low+high freq fatigue (Zenodo)
- Chen2017SingleFlicker: 12 subjects, 4-class spatial single-flicker (Zenodo)
- Wang2021Combined: 20 subjects, 4-class combined SSVEP (Figshare RAR)
- Lee2021Mobile_SSVEP: 24 subjects, 3-class mobile SSVEP (OSF BIDS)

All datasets verified end-to-end through SSVEP paradigm.get_data()
with correct epoch counts, class counts, and channel configurations.
- Delete unused _base.py and _download_helpers.py modules
- Remove dead _FREQS list (kim2025) and _paradigm_suffix (lee2021)
- Fix tarfile.extractall filter="data" for Python <3.12 compat (liu2020, chen2024)
- Fix Kim2025 stim marker placement to stimulus onset (sample 2048)
- Add ERP marker remapping to Lee2021Mobile
- Move numpy import to module level in lee2021_mobile.py
- Remove unreachable isinstance guards (wang2021, lee2021)
- Simplify redundant elif in wang2021 _find_subject_cnt_files
- Fix Chen2017 to use data_path instead of removed helper methods
- Fix Dong2023 set_montage with on_missing="ignore"
- Normalize log levels: warning→info for de-mean messages
- Wang2021: reduce subject_list from 20 to 8 (actual available in archive)
- Dong2023: add Google Drive IDs for S49-S59 (all 59 subjects now downloadable)
- Fix is_abbrev warnings: remove hyphens from dataset codes for 6 datasets
- Chen2017: reduce interval from [0, 4.0] to [0, 3.5] (trials are ~3.5s)
- Rename chen2024_eldbeta.py to liu2022_eldbeta.py to match class name
- Fix remaining log.warning → log.info (han2024, chen2017)
- Update smoke test expected subjects and module path
- Add _utils.py with build_raw_from_epochs helper, TSINGHUA_64CH_NAMES,
  and FIGSHARE_DL_URL to eliminate duplicated epoch-to-raw pipeline
- Refactor 5 epoch-based adapters to use the shared helper
- Use raw.annotations.rename() in lee2021_mobile and wang2021_combined
- Remove unused logging/numpy/mne imports across all refactored files
- Migrate dong2023 download from Google Drive to Zenodo
Benchmark 4 datasets (Liu2020BETA, Dong2023, Liu2022EldBETA, Han2024Fatigue)
with CCA, eCCA, and TRCA classifiers. Uses manual leave-one-block-out CV
for single-session datasets (MOABB WithinSessionEvaluation hardcodes
n_folds=5) and MOABB CrossSessionEvaluation for multi-session datasets.
Dong2023: Changed frequency-to-target mapping from Wang2016's 5x8
column-major order to Dong2023's 4x10 row-major order (Figure 1b).
Only 2/40 labels were correct, causing near-chance CCA accuracy (4.2%).

Han2024Fatigue: Shifted interval from [0, 2] to [0.14, 2.14] to
account for visual latency.

Benchmark: Split Han2024Fatigue into Low (8-15.5 Hz) and High
(25.5-33 Hz) 16-class evaluations with explicit event lists, since
SSVEP paradigm's fmin/fmax only controls bandpass, not event selection.
Add DatasetMetadata class attributes with acquisition, participant,
experiment, documentation, preprocessing, and paradigm-specific
metadata to all 8 SSVEP dataset adapters.

Fix 15 errors verified against original papers:
- Correct author names in 7 datasets (Liu2020BETA, Dong2023,
  Kim2025, Lee2021, Han2024, Wang2021, Chen2017)
- Fix senior/corresponding authors (Dong2023, Wang2021)
- Fix hardware (Lee2021: actiCHamp -> BrainAmp)
- Fix institution (Dong2023: JITRI Brain Machine Fusion Intelligence)
- Add missing license (Dong2023: CC BY-NC 4.0)
- Fix data_url (Kim2025: correct figshare DOI)
- Add missing age_mean (Kim2025: 22.8)
- Add missing repository (Liu2020BETA: Tsinghua BCI Lab)
- Add missing investigators (Liu2020BETA: Xiaoshan Huang, Yijun Wang)
Move 8 SSVEP adapters from ssvep_moabb_adapters/ into the main MOABB
library, adding 9 dataset classes (357+ subjects) covering 40-class
JFPM, beta-range, mobile BCI, spatial coding, fatigue, and elderly
population paradigms.

New dataset files:
- ssvep_liu2020.py (Liu2020BETA, 70 subjects, 40 classes)
- ssvep_liu2022.py (Liu2022EldBETA, 100 subjects, 9 classes)
- ssvep_kim2025.py (Kim2025BetaRange, 40 subjects, 40 classes)
- ssvep_dong2023.py (Dong2023, 59 subjects, 40 classes)
- lee2021_mobile.py (Lee2021Mobile_SSVEP + _ERP, 24 subjects)
- ssvep_chen2017.py (Chen2017SingleFlicker, 12 subjects, 4 classes)
- ssvep_wang2021.py (Wang2021Combined, 8 subjects, 4 classes)
- ssvep_han2024.py (Han2024Fatigue, 24 subjects, 32 classes)

Shared utilities added to utils.py:
- FIGSHARE_DL_URL, TSINGHUA_64CH_NAMES, build_raw_from_epochs()

Summary CSVs updated with all new entries.
- build_raw_from_epochs: use in-place de-mean and scale to avoid
  two full-size temporary array allocations
- ssvep_liu2020: extract only needed subject from tar.gz instead of
  all 10; replace os.walk with Path.rglob for consistency
- ssvep_liu2022: extract only .mat files from tar.gz, skip unused
  BIDS/GDF files
- ssvep_han2024: reshape all blocks at once instead of per-block
  list append + concatenate
- ssvep_wang2021: use shared FIGSHARE_DL_URL from utils instead of
  local constant
- ssvep_chen2017: use ord() for ASCII class codes instead of magic
  numbers
Switch the Liu2022EldBETA adapter from loading pre-epoched .mat files
(250 Hz) to reading the BIDS-formatted GDF files (1000 Hz) included in
each subject's Figshare archive.

The GDF 2.11 files exported by biosig4octave have a known header bug
(extra 256-byte metadata block), so _read_patched_gdf() patches the
header on-the-fly in a temp copy before reading with mne.io.read_raw_gdf.
Trailing NaN from incomplete GDF data records is cropped to prevent
filter artifacts.

Also derives _events from _TARGET_TO_FREQ to eliminate duplication,
hoists montage creation out of the session loop, and uses self.n_sessions
instead of hardcoded 7 in data_path().
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds several new SSVEP (and one ERP) dataset implementations to MOABB, along with shared utilities and dataset summary/documentation updates, to broaden the built-in dataset catalog and enable standardized loading/evaluation.

Changes:

  • Add new MOABB dataset classes for multiple SSVEP datasets plus the Lee2021Mobile SSVEP/ERP tasks.
  • Introduce shared dataset utilities (build_raw_from_epochs, TSINGHUA_64CH_NAMES, FIGSHARE_DL_URL) and update dataset summary CSVs + changelog.
  • Add a separate ssvep_moabb_adapters/ package with smoke tests and a local benchmarking script.

Reviewed changes

Copilot reviewed 26 out of 27 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
ssvep_moabb_adapters/wang2021_combined.py Adapter implementation for Wang2021 combined SSVEP dataset (CNT/RAR).
ssvep_moabb_adapters/tests/test_smoke.py Download-gated multi-stage smoke tests for adapter datasets.
ssvep_moabb_adapters/tests/conftest.py Adds a download marker and env-var-based skip helper.
ssvep_moabb_adapters/tests/init.py Test package init (no substantive changes shown).
ssvep_moabb_adapters/liu2022_eldbeta.py Adapter implementation for eldBETA (MAT-based in adapters package).
ssvep_moabb_adapters/liu2020_beta.py Adapter implementation for Liu2020 BETA dataset (MAT in tar.gz batches).
ssvep_moabb_adapters/lee2021_mobile.py Adapter implementation for Lee2021Mobile SSVEP/ERP tasks (BrainVision via OSF).
ssvep_moabb_adapters/kim2025_beta_range.py Adapter implementation for Kim2025 beta-range SSVEP dataset (Figshare MAT).
ssvep_moabb_adapters/han2024_fatigue.py Adapter implementation for Han2024 fatigue dataset (Zenodo zips).
ssvep_moabb_adapters/dong2023_ssvep.py Adapter implementation for Dong2023 SSVEP dataset (Zenodo MAT).
ssvep_moabb_adapters/chen2017_single_flicker.py Adapter implementation for Chen2017 single-flicker spatial SSVEP dataset (Zenodo zip).
ssvep_moabb_adapters/_utils.py Adapter-local shared helpers/constants for building Raw from epochs.
ssvep_moabb_adapters/init.py Exposes adapter dataset classes for import.
moabb/datasets/utils.py Adds shared constants + build_raw_from_epochs() to core MOABB utilities.
moabb/datasets/summary_ssvep.csv Adds new SSVEP dataset rows to the public dataset summary.
moabb/datasets/summary_p300.csv Adds Lee2021Mobile_ERP row to the P300 dataset summary.
moabb/datasets/ssvep_wang2021.py Adds MOABB-native Wang2021Combined dataset implementation.
moabb/datasets/ssvep_liu2022.py Adds MOABB-native eldBETA loader using patched BIDS/GDF.
moabb/datasets/ssvep_liu2020.py Adds MOABB-native Liu2020BETA dataset implementation.
moabb/datasets/ssvep_kim2025.py Adds MOABB-native Kim2025BetaRange dataset implementation.
moabb/datasets/ssvep_han2024.py Adds MOABB-native Han2024Fatigue dataset implementation.
moabb/datasets/ssvep_dong2023.py Adds MOABB-native Dong2023 dataset implementation.
moabb/datasets/ssvep_chen2017.py Adds MOABB-native Chen2017SingleFlicker dataset implementation.
moabb/datasets/lee2021_mobile.py Adds MOABB-native Lee2021Mobile SSVEP/ERP dataset implementations.
moabb/datasets/init.py Registers new datasets for moabb.datasets imports.
docs/source/whats_new.rst Documents the newly added datasets and shared utilities.
benchmark_ssvep.py Adds a standalone benchmarking script to compare with paper-reported results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread moabb/datasets/ssvep_liu2022.py Resolved
Comment thread ssvep_moabb_adapters/lee2021_mobile.py Resolved
Comment thread moabb/datasets/lee2021_mobile.py Resolved
Comment thread docs/source/whats_new.rst Resolved
Comment thread moabb/datasets/summary_ssvep.csv Resolved
Comment thread moabb/datasets/summary_p300.csv Resolved
Remove the standalone ssvep_moabb_adapters/ package now that all 8
SSVEP adapters are integrated into moabb/datasets/. Add the new
dataset classes to docs/source/api.rst (8 SSVEP + Lee2021Mobile_ERP).
- Replace raw._data with raw.get_data(picks=[0]) in Liu2022EldBETA GDF
  reader to use public MNE API instead of fragile private attribute
- Add separate METADATA for Lee2021Mobile_ERP with correct p300 paradigm,
  2 classes, and trial_duration instead of inheriting SSVEP metadata
- Fix Lee2021Mobile session counts in summary CSVs to reflect that
  session 05 is only available for subjects 1-18
- Update whats_new.rst to say "9 dataset adapters (8 SSVEP and 1 ERP)"
- Fix Wang2021Combined data_url (Figshare DOI was returning 404)
- Populate doi_cache.json with 10 newly resolved DOIs
- Update test_metadata expected counts: 93 datasets, 15 SSVEP, 36 p300
Replace hardcoded sign variables (e.g. "CHEN2017SINGLEFLICKER") with
self.code in data_path methods across all 8 SSVEP adapters and
Lee2021Mobile. The download module already uppercases the sign, so
self.code works directly. For Lee2021Mobile, use
self.code.split("-")[0] to strip the paradigm suffix.
Add acquisition details (reference electrodes, impedance thresholds,
electrode materials, filters), participant demographics (age_std,
BCI experience), experiment fields (task_type, feedback_type,
training/test splits), documentation (ethics approvals, funding
sources, institution departments, keywords), and new metadata
sections (BCIApplicationMetadata, Tags, ParadigmSpecificMetadata)
across all 8 SSVEP dataset adapters and Lee2021Mobile_ERP.

Notable corrections:
- Liu2022EldBETA: mode "offline" -> "online" (paper confirms online task)
- Lee2021Mobile: line_freq 50 -> 60 Hz (Korea power grid)
…xport

Liu2020BETA .mat files contain age and gender in suppl_info. Extract these
during data loading, set sex on raw.info["subject_info"], and store age as
raw._moabb_subject_age (MNE SubjectInfo doesn't support custom keys).

Add raw parameter to _update_participants_tsv with fallback logic to read
age and sex from raw when METADATA lacks per-subject lists (ages/sexes).
Point Wang2021Combined at published Zenodo record 18873228.
Switch from monolithic ZIP to per-subject downloads and update
data_path accordingly.
- Kim2025BetaRange: add sexes (40) and handedness_list (39 + 1 None)
  from questionnaire_en.xlsx on Figshare
- Lee2021Mobile: fix S18 sex to female (per BIDS participants.tsv),
  add age_min/age_max computed from ages list
- Liu2022EldBETA: fix age_min from 52 to 51 (actual min from BIDS data)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread moabb/datasets/lee2021_mobile.py Resolved
Comment thread moabb/datasets/ssvep_chen2017.py Resolved
Comment thread moabb/datasets/ssvep_wang2021.py Resolved
Comment thread moabb/datasets/ssvep_wang2021.py Resolved
Comment thread moabb/datasets/ssvep_liu2022.py Resolved
Comment thread moabb/datasets/ssvep_han2024.py Resolved
@bruAristimunha
bruAristimunha requested a review from Copilot March 5, 2026 15:16
@byneuro
byneuro force-pushed the feature/ssvep-dataset-adapters branch 2 times, most recently from 5d41f5f to 803ef01 Compare March 5, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread moabb/datasets/ssvep_liu2020.py Resolved
Comment thread moabb/datasets/ssvep_kim2025.py Resolved
Comment thread moabb/datasets/utils.py Resolved
Comment thread moabb/datasets/summary_p300.csv Resolved
Comment thread moabb/datasets/ssvep_chen2017.py Resolved
@bruAristimunha
bruAristimunha merged commit 22bfb8a into develop Mar 5, 2026
13 checks passed
@bruAristimunha
bruAristimunha deleted the feature/ssvep-dataset-adapters branch March 5, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants