From 0c0e6dfa8a1d19b41468f0d0f9142f2b19ab656b Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Tue, 30 Jan 2024 12:21:33 -0500 Subject: [PATCH] FIX: Unify --- mne_bids_pipeline/_run.py | 7 +++++-- .../steps/preprocessing/_09_ptp_reject.py | 21 +++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/mne_bids_pipeline/_run.py b/mne_bids_pipeline/_run.py index 7e06cb772..5b48137de 100644 --- a/mne_bids_pipeline/_run.py +++ b/mne_bids_pipeline/_run.py @@ -379,12 +379,15 @@ def _prep_out_files( exec_params: SimpleNamespace, out_files: dict[str, BIDSPath], ): + # Don't look at just deriv_root as this ends with /mne-bids-pipeline and + # sometimes we write stuff to /freesurfer + rel_root = exec_params.deriv_root.parent for key, fname in out_files.items(): # Sanity check that we only ever write to the derivatives directory fname = pathlib.Path(fname) - if not fname.is_relative_to(exec_params.deriv_root): + if not fname.is_relative_to(rel_root): raise RuntimeError( - f"Output BIDSPath not relative to deriv_root {exec_params.deriv_root}:" + f"Output BIDSPath not relative to deriv_root parent {rel_root}:" f"\n{fname}" ) out_files[key] = _path_to_str_hash( diff --git a/mne_bids_pipeline/steps/preprocessing/_09_ptp_reject.py b/mne_bids_pipeline/steps/preprocessing/_09_ptp_reject.py index 4a4b3d20e..dc390f80a 100644 --- a/mne_bids_pipeline/steps/preprocessing/_09_ptp_reject.py +++ b/mne_bids_pipeline/steps/preprocessing/_09_ptp_reject.py @@ -188,8 +188,9 @@ def drop_ptp( else: psd = 30 tags = ("epochs", "reject") - kind = cfg.reject if isinstance(cfg.reject, str) else "reject" + kind = cfg.reject if isinstance(cfg.reject, str) else "Rejection" title = "Epochs: after cleaning" + kwargs = dict(section=title, tags=tags, replace=True) with _open_report( cfg=cfg, exec_params=exec_params, subject=subject, session=session ) as report: @@ -204,21 +205,16 @@ def drop_ptp( fig=reject_log.plot( orientation="horizontal", aspect="auto", show=False ), - title=f"Epochs: {kind} cleaning", + title=f"{kind} cleaning", caption=caption, - tags=tags, - section=title, - replace=True, + **kwargs, ) del caption else: - html = f"

Rejection thresholds: {reject}

" report.add_html( - html=html, - title=f"Epochs: {kind} thresholds", - section=title, - replace=True, - tags=tags, + html=f"{reject}", + title=f"{kind} thresholds", + **kwargs, ) report.add_epochs( @@ -226,8 +222,7 @@ def drop_ptp( title=title, psd=psd, drop_log_ignore=(), - tags=tags, - replace=True, + **kwargs, ) return _prep_out_files(exec_params=exec_params, out_files=out_files)