diff --git a/doc/changes/devel/13280.bugfix.rst b/doc/changes/devel/13280.bugfix.rst new file mode 100644 index 00000000000..6d03da603f2 --- /dev/null +++ b/doc/changes/devel/13280.bugfix.rst @@ -0,0 +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`_. diff --git a/mne/preprocessing/maxwell.py b/mne/preprocessing/maxwell.py index 47c5b52e0c6..7d247ab137d 100644 --- a/mne/preprocessing/maxwell.py +++ b/mne/preprocessing/maxwell.py @@ -167,7 +167,12 @@ def maxwell_filter_prepare_emptyroom( elif bads == "keep": bads = raw_er_prepared.info["bads"] - bads = [ch_name for ch_name in bads if ch_name.startswith("MEG")] + # Filter to only include MEG channels + meg_ch_names = [ + raw_er_prepared.ch_names[pick] + for pick in pick_types(raw_er_prepared.info, meg=True, exclude=[]) + ] + bads = [ch_name for ch_name in bads if ch_name in meg_ch_names] raw_er_prepared.info["bads"] = bads # handle dev_head_t