From 87007f94cb3e0e82e8075463ca91af3284dd07d9 Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Sun, 11 May 2025 14:19:30 -0400 Subject: [PATCH 1/8] init --- mne/preprocessing/maxwell.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mne/preprocessing/maxwell.py b/mne/preprocessing/maxwell.py index 47c5b52e0c6..0b00ecd0970 100644 --- a/mne/preprocessing/maxwell.py +++ b/mne/preprocessing/maxwell.py @@ -167,7 +167,8 @@ 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")] + # bads = [ch_name for ch_name in bads if ch_name.startswith("MEG")] + print('----- MNE: include bads: ', bads) raw_er_prepared.info["bads"] = bads # handle dev_head_t From 2e0e1cd530bb7a5e6f5e9198e7602d674557d3e3 Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Sun, 11 May 2025 16:02:38 -0400 Subject: [PATCH 2/8] remove 'include bads' --- mne/preprocessing/maxwell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mne/preprocessing/maxwell.py b/mne/preprocessing/maxwell.py index 0b00ecd0970..9c3eae766b7 100644 --- a/mne/preprocessing/maxwell.py +++ b/mne/preprocessing/maxwell.py @@ -168,7 +168,7 @@ def maxwell_filter_prepare_emptyroom( bads = raw_er_prepared.info["bads"] # bads = [ch_name for ch_name in bads if ch_name.startswith("MEG")] - print('----- MNE: include bads: ', bads) + # print('----- MNE: include bads: ', bads) raw_er_prepared.info["bads"] = bads # handle dev_head_t From 92bf20ceec9567559d5a35e0064915fecee1bea4 Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Fri, 6 Jun 2025 17:19:54 -0400 Subject: [PATCH 3/8] improved filtering by channel type --- mne/preprocessing/maxwell.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mne/preprocessing/maxwell.py b/mne/preprocessing/maxwell.py index 9c3eae766b7..797d8e76029 100644 --- a/mne/preprocessing/maxwell.py +++ b/mne/preprocessing/maxwell.py @@ -167,8 +167,9 @@ 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")] - # print('----- MNE: include bads: ', bads) + # 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 From 23ef302bdf5880897660986be70d760f7b9c084d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Jun 2025 21:27:26 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mne/preprocessing/maxwell.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mne/preprocessing/maxwell.py b/mne/preprocessing/maxwell.py index 797d8e76029..7d247ab137d 100644 --- a/mne/preprocessing/maxwell.py +++ b/mne/preprocessing/maxwell.py @@ -168,7 +168,10 @@ def maxwell_filter_prepare_emptyroom( bads = raw_er_prepared.info["bads"] # 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=[])] + 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 From 27692fae868782df8505123beb740e8ab9feeadb Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Fri, 6 Jun 2025 17:34:05 -0400 Subject: [PATCH 5/8] add changelog --- doc/changes/devel/13280.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changes/devel/13280.bugfix.rst diff --git a/doc/changes/devel/13280.bugfix.rst b/doc/changes/devel/13280.bugfix.rst new file mode 100644 index 00000000000..f704f86d962 --- /dev/null +++ b/doc/changes/devel/13280.bugfix.rst @@ -0,0 +1 @@ +Fix bug where :func:`mne.preprocessing.maxwell.maxwell_filter_prepare_emptyroom` would not properly identify bad OPM channels by their `meg` type, by `Harrison Ritz`_. From ff0145f7e78ff8c3f8f98187b564057233aa5ae5 Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Sat, 7 Jun 2025 13:13:59 -0400 Subject: [PATCH 6/8] fix changelog --- doc/changes/devel/13280.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/devel/13280.bugfix.rst b/doc/changes/devel/13280.bugfix.rst index f704f86d962..39955e3afcc 100644 --- a/doc/changes/devel/13280.bugfix.rst +++ b/doc/changes/devel/13280.bugfix.rst @@ -1 +1 @@ -Fix bug where :func:`mne.preprocessing.maxwell.maxwell_filter_prepare_emptyroom` would not properly identify bad OPM channels by their `meg` type, by `Harrison Ritz`_. +Fix bug where `mne.preprocessing.maxwell.maxwell_filter_prepare_emptyroom` would not properly identify bad OPM channels by their `meg` type, by `Harrison Ritz`_. From fbd7fe09c52e00cc8ac0a52a8ae69832c6ad5df3 Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Sat, 7 Jun 2025 15:35:10 -0400 Subject: [PATCH 7/8] fix function reference --- doc/changes/devel/13280.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/devel/13280.bugfix.rst b/doc/changes/devel/13280.bugfix.rst index 39955e3afcc..541e32cc38f 100644 --- a/doc/changes/devel/13280.bugfix.rst +++ b/doc/changes/devel/13280.bugfix.rst @@ -1 +1 @@ -Fix bug where `mne.preprocessing.maxwell.maxwell_filter_prepare_emptyroom` would not properly identify bad OPM channels by their `meg` type, by `Harrison Ritz`_. +Fixed bug where :func:`mne.preprocessing.maxwell_filter_prepare_emptyroom` would not reliably identify bad channels by their `meg` type, by `Harrison Ritz`_. From 20a2b19322c6a06595a74f11706ce216b755fc6e Mon Sep 17 00:00:00 2001 From: Harrison Ritz Date: Sun, 8 Jun 2025 11:35:44 -0400 Subject: [PATCH 8/8] remove `meg` from changelog --- doc/changes/devel/13280.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/devel/13280.bugfix.rst b/doc/changes/devel/13280.bugfix.rst index 541e32cc38f..6d03da603f2 100644 --- a/doc/changes/devel/13280.bugfix.rst +++ b/doc/changes/devel/13280.bugfix.rst @@ -1 +1 @@ -Fixed bug where :func:`mne.preprocessing.maxwell_filter_prepare_emptyroom` would not reliably identify bad channels by their `meg` type, by `Harrison Ritz`_. +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`_.