Skip to content

FIX TUH recording_ids select by chronological position - #1412

Merged
bruAristimunha merged 3 commits into
masterfrom
fix/tuh-recording-ids-order
Oct 16, 2026
Merged

bruAristimunha merged 3 commits into
masterfrom
fix/tuh-recording-ids-order

Conversation

@adammounir

Copy link
Copy Markdown
Collaborator

TUH.__init__ sorts the description table chronologically (_sort_chronologically), but the columns keep the labels they had in glob order. descriptions[recording_ids] then selects by label. So recording_ids=[0] (or an int n) returns recordings in filesystem-listing order, not the chronological order the docstring promises, and which recordings you get depends on the filesystem.

On the v1.1.0 mock, the full set in date order is 2003, 2014-09, 2014-12, 2015, but recording_ids=[0, 1] returned 2014-09 and 2015.

Fix

Select by position: descriptions.iloc[:, list(recording_ids)]. TUHAbnormal, TUHEvents and the mocks all go through TUH.__init__, so they get the fix too.

Tests

  • New test_tuh_recording_ids_follow_chronological_order ([0], [0, 1], [1, 0], [3, 1], 2): checks the selected rows against the full chronologically sorted description. 5 of these fail on master.
  • test_tuh[v1.1.0] asserted y == "F" for recording_ids=[0]. That value came from the first file in listing order (2014, subject 9932), so it only passed because of the bug. The chronologically first recording (2003, subject 58) is "M". v1.2.0 has one recording and is unchanged.

Copilot AI balanced review requested due to automatic review settings October 15, 2026 07:33

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.

🟢 Approval recommended

The focused fix matches the documented ordering contract and includes regression coverage for the affected selection patterns.

0 open findings

What changed in this PR

Fixes TUH recording selection to use chronological positions rather than filesystem-listing labels.

Changes:

  • Uses positional indexing for recording_ids.
  • Adds regression coverage for individual, reordered, and integer-count selections.
  • Corrects the affected test expectation and documents the fix.
File Description
test/​unit_tests/​datasets/​test_tuh.py Tests chronological selection and corrects the expected target.
docs/​whats_new.rst Documents the corrected recording selection behavior.
braindecode/​datasets/​tuh.py Selects recordings by chronological position.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.14%. Comparing base (baec1ae) to head (9864546).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1412   +/-   ##
=======================================
  Coverage   90.13%   90.14%           
=======================================
  Files         167      167           
  Lines       21815    21817    +2     
=======================================
+ Hits        19663    19666    +3     
+ Misses       2152     2151    -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha
bruAristimunha merged commit 641eedf into master Oct 16, 2026
7 checks passed
@bruAristimunha
bruAristimunha deleted the fix/tuh-recording-ids-order branch November 22, 2026 23:02
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.

3 participants