Skip to content

Add dataset and device columns to the paradigm metadata (leave-one-device-out with groups="device") - #1328

Merged
bruAristimunha merged 4 commits into
NeuroTechX:developfrom
bruAristimunha:feat/dataset-metadata-column
Oct 25, 2026
Merged

bruAristimunha merged 4 commits into
NeuroTechX:developfrom
bruAristimunha:feat/dataset-metadata-column

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Second of three steps from the review of #1305 (first: #1327, merged). Makes the grouping used for transfer evaluation explicit in the metadata, keeping dataset (provenance) and device (recording system) apart: one dataset can use several devices, and several datasets can share one.

Problem. get_data's metadata carried only subject, session and run. Leave-one-dataset-out over a CompoundDataset needed a hand-written subject→dataset lookup, CrossDatasetSplitter (which groups by a "dataset" column) could not run on paradigm output, and there was no way to group by device at all: METADATA.acquisition.hardware is free text (107 distinct strings, e.g. seven spellings of the g.tec g.USBamp; 25 datasets give none).

Change

  • get_data metadata gets two columns:
    • dataset: the dataset code; inside a CompoundDataset, the dataset the subject comes from (BaseDataset._source_code);
    • device: the recording device of the session (BaseDataset._device(subject, session)), by default canonical_device(METADATA.acquisition.hardware).
  • moabb.datasets.metadata.devices.canonical_device: a short ordered pattern table mapping the 107 strings to 30 devices. A manufacturer-only entry becomes "<maker> (model not given)" rather than being merged into a specific model; unmatched text is kept as is; no entry gives "unknown" (curation of the 25 missing entries is left to a separate PR).
  • CompoundDataset delegates _device to the source dataset; Peters2026 overrides it per visit (DSI-24 or DSI-Flex).
  • The groups docs list the metadata columns.

Usage:

CrossSubjectEvaluation(datasets=[compound], cv_class=LeaveOneGroupOut, groups="device")   # leave-one-device-out
CrossSubjectEvaluation(datasets=[compound], cv_class=LeaveOneGroupOut, groups="dataset")  # leave-one-dataset-out

Behaviour change: two more default metadata columns; one test pinning the column list is updated.

Tests: canonical_device on real hardware strings; dataset/device columns for plain and compound datasets, including a device change between sessions and a device shared by two datasets; leave-one-dataset-out and leave-one-device-out evaluations (a device spanning two datasets is held out as one group). test_paradigms.py, test_evaluations.py, test_splits.py and test_metadata.py pass locally.

Not changed: cv_class=CrossDatasetSplitter passed directly to CrossSubjectEvaluation is still refused (top-level splitters must hold out one subject per test fold); the groups= form covers it.

Leave-one-dataset-out needed a hand-written subject->dataset lookup:
get_data's metadata only had subject/session/run, so CrossDatasetSplitter
(which groups by a 'dataset' column) could not run on paradigm output.
Paradigms now record each trial's dataset code (for a CompoundDataset, the
dataset the subject comes from), so CrossSubjectEvaluation(cv_class=
LeaveOneGroupOut, groups='dataset') holds out one dataset at a time.
…ata-column

# Conflicts:
#	docs/source/whats_new.rst
#	moabb/tests/test_evaluations.py
#	moabb/tests/test_paradigms.py
Group by recording device, not by dataset: one dataset can use several
devices (Peters2026: DSI-24 or DSI-Flex per visit) and several datasets
share one. canonical_device maps the 107 free-text
METADATA.acquisition.hardware strings to 30 devices ('unknown' when none
is given); BaseDataset._device returns it per session, CompoundDataset
delegates to the source dataset, Peters2026 overrides it per visit.
groups='device' is leave-one-device-out.
@bruAristimunha bruAristimunha changed the title Add a dataset column to the paradigm metadata (leave-one-dataset-out with groups="dataset") Add dataset and device columns to the paradigm metadata (leave-one-device-out with groups="device") Oct 25, 2026
@bruAristimunha
bruAristimunha merged commit f394189 into NeuroTechX:develop Oct 25, 2026
13 of 15 checks passed
bruAristimunha added a commit to qbarthelemy/moabb that referenced this pull request Oct 25, 2026
Review of NeuroTechX#1305 (Bruno): no new evaluation. The example now pools the
devices in a CompoundDataset and holds out one device at a time with
CrossSubjectEvaluation(cv_class=LeaveOneGroupOut, groups='device'), on the
nested trials of NeuroTechX#1327 and the device column of NeuroTechX#1328.

- remove CrossSystemEvaluation, its tests and extra_fit_params;
- _evaluate_fold routes any metadata column of the training trials to the
  steps requesting it (set_fit_request(device=True)), replacing the
  cross-system-only 'systems' routing;
- FakeDataset takes a device;
- the example's ChannelUnion and MDMM read the device of each training
  trial and infer the held-out device, so every device can be the target;
- keep the duplicated-results fix of process() and its test.
bruAristimunha added a commit that referenced this pull request Oct 26, 2026
…(route metadata columns to pipelines) (#1305)

* Add CrossSystemEvaluation

* CrossSystemEvaluation: load the systems once, reject unknown targets and epoch pipelines

Review follow-ups: the systems were reloaded in full for every target (k^2
loads), a target_datasets entry outside datasets gave an empty result, and
pipelines needing mne.Epochs silently received arrays.

* Turn CrossSystemEvaluation into a tutorial on the existing API

Review of #1305 (Bruno): no new evaluation. The example now pools the
devices in a CompoundDataset and holds out one device at a time with
CrossSubjectEvaluation(cv_class=LeaveOneGroupOut, groups='device'), on the
nested trials of #1327 and the device column of #1328.

- remove CrossSystemEvaluation, its tests and extra_fit_params;
- _evaluate_fold routes any metadata column of the training trials to the
  steps requesting it (set_fit_request(device=True)), replacing the
  cross-system-only 'systems' routing;
- FakeDataset takes a device;
- the example's ChannelUnion and MDMM read the device of each training
  trial and infer the held-out device, so every device can be the target;
- keep the duplicated-results fix of process() and its test.

---------

Co-authored-by: Bru <[email protected]>
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