Repository navigation
Fix MotorImagery.used_events ignoring n_classes when events=None - #1361
Merged
bruAristimunha merged 3 commits intoNov 18, 2026
Merged
bruAristimunha merged 3 commits into
bruAristimunha merged 3 commits into
Conversation
With events=None, the loop collected every dataset event with no limit, so a dataset with more events than n_classes silently used all of them instead of the requested n_classes. FilterBankMotorImagery already breaks once len(out) == n_classes in the same branch; applied the same guard here, keeping the auto-detect path (n_classes=None) unchanged.
SID-6921
force-pushed
the
fix/motor-imagery-used-events-n-classes
branch
from
November 18, 2026 05:15
7e2b4eb to
35f86c0
Compare
bruAristimunha
approved these changes
Nov 18, 2026
…n neural signatures - MotorImagery fills n_classes in from the first dataset when it is None (scoring reads it); the new early stop then cut later datasets down to that count. Stop only on an n_classes given to the constructor. - neural_signatures built MotorImagery(n_classes=2), which now kept two classes; drop it so the figures keep every class, as before. - Changelog entry.
Collaborator
|
Thanks @SID-6921, the fix is right. I pushed e8d4afc on top to cover two side effects found while reviewing:
|
# Conflicts: # docs/source/whats_new.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MotorImagery.used_eventsand its siblingFilterBankMotorImagery.used_eventsboth have anevents is Nonebranch meant to collect dataset events up ton_classes.FilterBankMotorImagerybreaks oncelen(out) == n_classes;MotorImagerydoesn't, so it collects every event in the dataset regardless ofn_classes.Since
used_events's result is used directly as theevent_idpassed toEventsToLabelswith no truncation downstream, this means a user who setsn_classesonMotorImagerywithout an expliciteventslist silently gets however many classes the dataset actually has, not the number they asked for.Added the same
len(out) == n_classesbreak toMotorImagery.used_events, guarded so then_classes is Noneauto-detect path (which should keep collecting everything, then setn_classes = len(out)) is unchanged.Added a regression test comparing both siblings' output on the same dataset; it fails on the pre-fix code (
{'fake1': 1, 'fake2': 2, 'fake3': 3}instead of 2 entries) and passes after. Ran the fulltest_paradigms.py(120 passed) andruff check/ruff format --checkon both changed files.