Skip to content

Commit

Permalink
FIX: Unify
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Jan 30, 2024
1 parent bbd5940 commit 0c0e6df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
7 changes: 5 additions & 2 deletions mne_bids_pipeline/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>/mne-bids-pipeline and
# sometimes we write stuff to <path>/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(
Expand Down
21 changes: 8 additions & 13 deletions mne_bids_pipeline/steps/preprocessing/_09_ptp_reject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -204,30 +205,24 @@ 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"<p>Rejection thresholds: <code>{reject}</code></p>"
report.add_html(
html=html,
title=f"Epochs: {kind} thresholds",
section=title,
replace=True,
tags=tags,
html=f"<code>{reject}</code>",
title=f"{kind} thresholds",
**kwargs,
)

report.add_epochs(
epochs=epochs,
title=title,
psd=psd,
drop_log_ignore=(),
tags=tags,
replace=True,
**kwargs,
)
return _prep_out_files(exec_params=exec_params, out_files=out_files)

Expand Down

0 comments on commit 0c0e6df

Please sign in to comment.