Repository navigation
FIX TUH recording_ids select by chronological position - #1412
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 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 Report✅ All modified and coverable lines are covered by tests. 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:
|
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.
TUH.__init__sorts the description table chronologically (_sort_chronologically), but the columns keep the labels they had ingloborder.descriptions[recording_ids]then selects by label. Sorecording_ids=[0](or an intn) 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,TUHEventsand the mocks all go throughTUH.__init__, so they get the fix too.Tests
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 onmaster.test_tuh[v1.1.0]assertedy == "F"forrecording_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.