Skip to content

Commit 1926446

Browse files
fix Maxwell bads filtering (#13280)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4033b3a commit 1926446

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/changes/devel/13280.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed bug where :func:`mne.preprocessing.maxwell_filter_prepare_emptyroom` would not reliably identify meg channel types for matching bads across emptyroom and task, by `Harrison Ritz`_.

mne/preprocessing/maxwell.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ def maxwell_filter_prepare_emptyroom(
172172
elif bads == "keep":
173173
bads = raw_er_prepared.info["bads"]
174174

175-
bads = [ch_name for ch_name in bads if ch_name.startswith("MEG")]
175+
# Filter to only include MEG channels
176+
meg_ch_names = [
177+
raw_er_prepared.ch_names[pick]
178+
for pick in pick_types(raw_er_prepared.info, meg=True, exclude=[])
179+
]
180+
bads = [ch_name for ch_name in bads if ch_name in meg_ch_names]
176181
raw_er_prepared.info["bads"] = bads
177182

178183
# handle dev_head_t

0 commit comments

Comments
 (0)