Skip to content

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

Open
CarinaFo wants to merge 3 commits into
mne-tools:mainfrom
CarinaFo:bad_limit_drops_bads
Open

CarinaFo wants to merge 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
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.

1 participant