From fe56c011c8810f5d1acf04b81b147ed08295cd6f Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 7 Feb 2024 09:01:42 -0500 Subject: [PATCH] BUG: Fix bug with Maxwell step when find_noise_channels_meg=False (#847) --- docs/source/v1.6.md.inc | 1 + mne_bids_pipeline/_import_data.py | 3 ++- mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py | 5 +++-- mne_bids_pipeline/tests/configs/config_ds003392.py | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/source/v1.6.md.inc b/docs/source/v1.6.md.inc index 3c87dac23..a38943374 100644 --- a/docs/source/v1.6.md.inc +++ b/docs/source/v1.6.md.inc @@ -23,6 +23,7 @@ - Fix bug where EEG `reject` params were not used for `ch_types = ["meg", "eeg"]` (#839 by @larsoner) - Fix bug where implicit `mf_reference_run` could change across invocations of `mne_bids_pipeline`, breaking caching (#839 by @larsoner) - Fix bug where `--no-cache` had no effect (#839 by @larsoner) +- Fix bug where the Maxwell filtering step would fail if [`find_noisy_channels_meg = False`][mne_bids_pipeline._config.find_noisy_channels_meg]` was used (#847 by @larsoner) - Fix bug where raw, empty-room, and custom noise covariances were errantly calculated on data without ICA or SSP applied (#840 by @larsoner) ### :medical_symbol: Code health diff --git a/mne_bids_pipeline/_import_data.py b/mne_bids_pipeline/_import_data.py index be892576b..c3c319f44 100644 --- a/mne_bids_pipeline/_import_data.py +++ b/mne_bids_pipeline/_import_data.py @@ -683,10 +683,11 @@ def _get_run_rest_noise_path( def _get_mf_reference_run_path( + *, cfg: SimpleNamespace, subject: str, session: Optional[str], - add_bads: bool, + add_bads: Optional[bool] = None, ) -> dict: return _get_run_path( cfg=cfg, diff --git a/mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py b/mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py index c5b58e2b6..5e5e30318 100644 --- a/mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py +++ b/mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py @@ -64,7 +64,7 @@ def get_input_fnames_esss( mf_reference_run=cfg.mf_reference_run, **kwargs, ) - in_files.update(_get_mf_reference_run_path(add_bads=True, **kwargs)) + in_files.update(_get_mf_reference_run_path(**kwargs)) return in_files @@ -241,7 +241,8 @@ def get_input_fnames_maxwell_filter( ) # reference run (used for `destination` and also bad channels for noise) - in_files.update(_get_mf_reference_run_path(add_bads=True, **kwargs)) + # use add_bads=None here to mean "add if autobad is turned on" + in_files.update(_get_mf_reference_run_path(**kwargs)) is_rest_noise = run is None and task in ("noise", "rest") if is_rest_noise: diff --git a/mne_bids_pipeline/tests/configs/config_ds003392.py b/mne_bids_pipeline/tests/configs/config_ds003392.py index 756d36fbc..3f225e50c 100644 --- a/mne_bids_pipeline/tests/configs/config_ds003392.py +++ b/mne_bids_pipeline/tests/configs/config_ds003392.py @@ -6,8 +6,9 @@ subjects = ["01"] task = "localizer" -find_flat_channels_meg = True -find_noisy_channels_meg = True +# usually a good idea to use True, but we know no bads are detected for this dataset +find_flat_channels_meg = False +find_noisy_channels_meg = False use_maxwell_filter = True ch_types = ["meg"]