Skip to content

Commit

Permalink
don't fail if emptyroom is missing cHPI channels (#977)
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
  • Loading branch information
drammock and larsoner authored Jul 31, 2024
1 parent fac657a commit ea5545d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
7 changes: 5 additions & 2 deletions docs/source/v1.10.md.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

[//]: # (- Whatever (#000 by @whoever))

[//]: # (### :bug: Bug fixes)
### :bug: Bug fixes

[//]: # (- Whatever (#000 by @whoever))
- When running the pipeline with [`mf_filter_chpi`][mne_bids_pipeline._config.mf_filter_chpi] enabled (#977 by @drammock and @larsoner):

1. Emptyroom files that lack cHPI channels will now be processed (for line noise only) instead of raising an error.
2. cHPI filtering is now performed before movement compensation.

### :books: Documentation

Expand Down
2 changes: 1 addition & 1 deletion docs/source/v1.9.md.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
### :bug: Bug fixes
- When running the pipeline with [`find_bad_channels_meg`][mne_bids_pipeline._config. find_bad_channels_meg] enabled,
- When running the pipeline with [`find_noisy_channels_meg`][mne_bids_pipeline._config.find_noisy_channels_meg] enabled,
then disabling it and running the pipeline again, the pipeline would incorrectly still use automatically detected
bad channels from the first pipeline run. Now, we ensure that the original bad channels would be used and the
related section is removed from the report in this case. (#902 by @larsoner)
Expand Down
16 changes: 9 additions & 7 deletions mne_bids_pipeline/steps/preprocessing/_03_maxfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@ def run_maxwell_filter(
)
logger.warning(**gen_log_kwargs(message=msg))

if filter_chpi:
logger.info(**gen_log_kwargs(message="Filtering cHPI"))
mne.chpi.filter_chpi(
raw,
t_window=cfg.mf_mc_t_window,
allow_line_only=(task == "noise"),
)

logger.info(**gen_log_kwargs(message="Maxwell filtering"))
raw_sss = mne.preprocessing.maxwell_filter(raw, **mf_kws)
del raw
gc.collect()
Expand Down Expand Up @@ -456,13 +465,6 @@ def run_maxwell_filter(
)
raise RuntimeError(msg)

if filter_chpi:
logger.info(**gen_log_kwargs(message="Filtering cHPI"))
mne.chpi.filter_chpi(
raw_sss,
t_window=cfg.mf_mc_t_window,
)

if cfg.mf_mc and (
cfg.mf_mc_rotation_velocity_limit is not None
or cfg.mf_mc_translation_velocity_limit is not None
Expand Down
2 changes: 1 addition & 1 deletion mne_bids_pipeline/tests/configs/config_ds004229.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
mf_int_order = 6 # lower for smaller heads
mf_mc_t_step_min = 0.5 # just for speed!
mf_mc_t_window = 0.2 # cleaner cHPI filtering on this dataset
mf_filter_chpi = False # for speed, not needed as we low-pass anyway
mf_filter_chpi = True # even though we lowpass, set to True for test coverage
mf_mc_rotation_velocity_limit = 30.0 # deg/s for annotations
mf_mc_translation_velocity_limit = 20e-3 # m/s
mf_esss = 8
Expand Down

0 comments on commit ea5545d

Please sign in to comment.