You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Epochs.get_data(picks="eeg") excludes channels marked as bad by default,
but Evoked.get_data(picks="eeg") does not. Same method name, same
library, inconsistent behavior.
Root cause: Evoked.get_data() always calls _picks_to_idx(self.info, picks, "all", exclude=()), unconditionally
passing exclude=(). Epochs._get_data() only does this when picks
is None; when explicit picks are given, it lets _picks_to_idx fall
back to its default of exclude="bads".
This PR mirrors that branching logic in Evoked.get_data():
picks=None : unchanged, bads still included (preserves existing behavior)
explicit picks (e.g. picks="eeg"): bads now excluded by default,
matching Epochs.get_data()
Added a regression test in test_evoked.py::test_get_data that fails
on current main and passes with this fix. Also added a changelog
entry and added myself to the contributor list.
Hi Eva, thank you for your contribution.
Fully agree with you that the inconsistent behaviour between epochs and evokeds should be fixed.
I am not sure if changing the behaviour of evokeds is the way to go, it might break people's code if we don't properly deprecate that.
Additionally, it seems that this is a broader and more complex issue as mentioned here.
Let me discuss that with the other maintainers and get back to you.
Thanks for the context, Carina. That forum thread and the broader consistency question make sense. Happy to keep this PR scoped to the Evoked.get_data() fix + docstring for now, and adjust the approach (deprecation path, etc.) once you've discussed with the other maintainers. If it'd be useful, I'd also be glad to help think through the broader .pick() standardization once there's a direction. That's a discussion I'd been meaning to follow more closely anyway.
This is a complex problem that should be tackled in several steps. I think the correct step to take first is to follow this comment, and this comment i.e.,
add an exclude param to the .get_data() method of any object that has .get_data()
set the default value to whatever preserves current behavior for that object type even if it's inconsistent across different object types
make sure the docstrings are all correct (i.e., add an exclude param description that states the correct default, and make sure to explain somewhere how picks and exclude interact)
everything that involves changes to behavior gets done in a subsequent PR
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
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.
Fixes #12577
Epochs.get_data(picks="eeg")excludes channels marked as bad by default,but
Evoked.get_data(picks="eeg")does not. Same method name, samelibrary, inconsistent behavior.
Root cause:
Evoked.get_data()always calls_picks_to_idx(self.info, picks, "all", exclude=()), unconditionallypassing
exclude=().Epochs._get_data()only does this whenpicksis
None; when explicit picks are given, it lets_picks_to_idxfallback to its default of
exclude="bads".This PR mirrors that branching logic in
Evoked.get_data():picks=None: unchanged, bads still included (preserves existing behavior)picks="eeg"): bads now excluded by default,matching
Epochs.get_data()Added a regression test in
test_evoked.py::test_get_datathat failson current
mainand passes with this fix. Also added a changelogentry and added myself to the contributor list.