Repository navigation
FIX load_concat_dataset ignoring target_name and turning description strings into numbers - #1480
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1480 +/- ##
==========================================
+ Coverage 91.04% 91.07% +0.02%
==========================================
Files 167 167
Lines 21646 21663 +17
==========================================
+ Hits 19708 19729 +21
+ Misses 1938 1934 -4 🚀 New features to boost your workflow:
|
bruAristimunha
approved these changes
Oct 21, 2026
bruAristimunha
left a comment
Collaborator
There was a problem hiding this comment.
Super approved this one!
# Conflicts: # docs/whats_new.rst
# Conflicts: # docs/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.
Two problems with
load_concat_dataseton datasets saved with the currentBaseConcatDataset.saveformat (braindecode/datautil/serialization.py).1.
target_nameis silently ignoredThe docstring says
target_nameloads that description column as the target. It is only passed to the outdated-format loader. For the current format,_load_parallelalways takes the savedtarget_name.json, so the argument does nothing.Repro: a
RawDatasetwith description{"age": 30, "sex": "F"}andtarget_name="age", saved, thenload_concat_dataset(path, preload=False, target_name="sex")givestarget_name == "age"andy == 30.Fix: for datasets of raws, set
target_nameon every loaded dataset (throughRawDataset._target_name, so a missing key warns as in the constructor). For windowed datasets the targets live in the window metadata, so raise aValueErrorthat points toBaseConcatDataset.set_target, as the outdated loader already refused it (assert).2. Numeric-looking description strings come back as numbers
description.jsonis read withpd.read_json(typ="series"), which infers dtypes. When all values of a description look numeric, they are converted:{"subject": "01", "session": "02", "run": "0"}comes back as{"subject": 1, "session": 2, "run": 0}. This happens for windowed datasets of BIDS-style data, whose description often only holds such entities. With a mixed description the strings are kept, so the result depends on the other fields.Fix: read with
dtype=False, so JSON strings stay strings and numbers stay numbers. JSONnull(saved NaN) is still read back as NaN, as before.Tests
3 new tests in
test_serialization.py(description strings kept,target_nameapplied on raws,target_nameon windows raises). All 3 fail onmaster.test_serialization.py: 37 passed.test_tuh.py,test_preprocess.py,test_mne_preprocessor.py: 238 passed, 14 skipped.Full test files
Run on a Linux CPU node, on this branch rebased on current
masterand onmasteritself, with-m "not network and not huggingface":test/unit_tests/datautil/ test/unit_tests/datasets/test_dataset.py test/unit_tests/preprocessing/test_preprocess.py.Branch: 270 passed, 1 skipped.
master: 267 passed, 1 skipped. No test fails only on this branch.