Fix pick channels crash when _orig_units is None (#11314)#14006
Open
CedricConday wants to merge 2 commits into
Open
Fix pick channels crash when _orig_units is None (#11314)#14006CedricConday wants to merge 2 commits into
CedricConday wants to merge 2 commits into
Conversation
Picking/reordering channels built {k: v for ... in self._orig_units.items()}
unconditionally, raising AttributeError when _orig_units is None (as produced
by some readers / RawArray flows). Guard for a falsy _orig_units. Adds a test.
larsoner
reviewed
Jun 30, 2026
Comment on lines
+703
to
+705
| import numpy as np | ||
|
|
||
| import mne |
Member
There was a problem hiding this comment.
No need to nest these they're required by MNE
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.
Fixes #11314
What was wrong
When picking/reordering channels on a
Raw, the code rebuilds_orig_units:If
self._orig_unitsisNone(which happens with some readers andRawArrayflows), this raisesAttributeError: 'NoneType' object has no attribute 'items'. The pick itself otherwise succeeds.Fix
Only rebuild
_orig_unitswhen it is truthy; leaveNone/empty as-is.Test
Adds
test_pick_channels_orig_units_none: picking with_orig_units = Noneno longer raises. Verified it raisesAttributeErroronmainand passes with this change.AI-assisted, human-reviewed — I'm an AI engineer; I find, fix, and test with AI, then review and verify before opening.