Skip to content

FIX: Restore bads when interpolate_bridged_electrodes raises for bad_limit - #14320

Merged
larsoner merged 3 commits into
mne-tools:mainfrom
CarinaFo:bad_limit_drops_bads
Sep 21, 2026
Merged

larsoner merged 3 commits into
mne-tools:mainfrom
CarinaFo:bad_limit_drops_bads

Conversation

@CarinaFo

Copy link
Copy Markdown
Contributor

While reviewing #14287, I noticed that interpolate_bridged_electrodes clears inst.info["bads"] before checking bad_limit. If too many electrodes are bridged together, the RuntimeError is raised before the original bads are restored. The user's bad-channel list is silently lost.

This PR:

  • Moves the lines that save and clear info["bads"] to after the bad_limit check. Nothing before that point uses info["bads"], so behaviour is otherwise unchanged.
  • Extends the existing bad_limit part of test_interpolate_bridged_electrodes to mark a channel as bad and assert it is still marked bad after the error is raised. The new assertion fails on main and passes with this change.

AI disclosure:
Claude Opus 5 was used to help with formatting this PR and the changelog entry.

@CarinaFo CarinaFo added the BUG label Sep 20, 2026
@CarinaFo
CarinaFo marked this pull request as ready for review September 20, 2026 03:06

@larsoner larsoner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks @CarinaFo !

@larsoner
larsoner merged commit dbb23ed into mne-tools:main Sep 21, 2026
30 checks passed
larsoner added a commit to ttaiv/mne-python that referenced this pull request Sep 21, 2026
* upstream/main:
  FIX: Restore bads when interpolate_bridged_electrodes raises for bad_limit (mne-tools#14320)
  BUG: Fix fNIRS `interpolate_bads` on `Epochs` (mne-tools#14323)
  [dependabot]: Bump the actions group with 3 updates (mne-tools#14324)
  MAINT: Update pre-commit hook versions (mne-tools#14322)
  Fully populate docstrings (mne-tools#14316)
  Add `set_head_sphere` method to store head outline in info (mne-tools#14313)

# Conflicts:
#	mne/minimum_norm/inverse.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants