Skip to content

34 of 147 datasets have self-contradictory channel metadata, and the validator that would catch it is never called #1163

Closed

Description

@bruAristimunha

What

AcquisitionMetadata carries three descriptions of the same fact — n_channels, channel_types and sensors — and nothing checks they agree. Measured across the catalogue:

  • 34 of 147 datasets have n_channels != sum(channel_types.values())
  • 34 of 147 have n_channels != len(sensors)

Examples:

dataset n_channels sum(channel_types) len(sensors)
BNCI2014_004 3 6 6
BNCI2016_002 59 69 69
BNCI2019_001 61 64 64
BNCI2020_001 58 64 64
BNCI2015_009 60 62 —

Why it matters

This is the metadata that hid the BNCI2025_001 label leak fixed in #1161: it declared n_channels=67 with channel_types={"eeg": 67, "eog": 4} — internally contradictory, and contradicted again by its own 60-electrode montage. The 7 extra channels were hand kinematics and the reaching target, typed eeg and picked as features.

A one-line invariant would have surfaced it offline, with no data download.

There is already a validator, and nothing calls it

moabb/datasets/metadata/schema.py:725 defines validate_metadata_against_dataset(dataset, metadata). It is exported from moabb/datasets/metadata/__init__.py and listed in __all__ — and grep -rn validate_metadata_against_dataset moabb/ finds only its own definition, the re-exports, and its docstring example. It has no callers and no test.

Suggested fix

  1. Add to validate_metadata_against_dataset (or a new offline test) the assertion n_channels == sum(channel_types.values()) == len(sensors), skipping the fields a dataset legitimately leaves unset.
  2. Call it from a test that runs without --dl-data, so it covers all ~147 datasets on every PR.
  3. Fix the 34 offenders. Most look like n_channels counting EEG only while channel_types/sensors include EOG/EMG/misc — worth settling which convention is intended and writing it down. moabb/tests/test_metadata.py:43 implies n_channels == sum(channel_types), and test_n_channels_matches_raw_data counts every non-stim channel, which agrees.

Note this is offline-checkable, so it is not affected by #1162 — but #1162 is why the data-backed version of this check (test_metadata_matches_raw_data) has also never run.

Verification

from moabb.datasets.utils import dataset_list
# 147 metadata blocks checked; 34 mismatch on both comparisons

Activity

  1. bruAristimunha commented on Aug 26, 2026

    @bruAristimunha
    CollaboratorAuthor

    Fixed in #1161 (7c10845).

  2. added a commit that references this issue on Sep 3, 2026
    8d3c12d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions