Skip to content

Commit

Permalink
FIX: More
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Feb 24, 2024
1 parent 686aa8b commit 7410306
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
11 changes: 7 additions & 4 deletions mne_bids_pipeline/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,18 @@ def _prep_out_files(
exec_params: SimpleNamespace,
out_files: dict[str, BIDSPath],
check_relative: Optional[pathlib.Path] = None,
bids_only: bool = True,
):
if check_relative is None:
check_relative = exec_params.deriv_root
for key, fname in out_files.items():
# Sanity check that we only ever write to the derivatives directory
assert isinstance(fname, BIDSPath), type(fname) # only write BIDSPath
if fname.suffix not in ("raw", "epochs"):
# raw and epochs can split on write, and .save should check for us
assert fname.split is None, fname.split
if bids_only:
assert isinstance(fname, BIDSPath), (type(fname), fname)
if isinstance(fname, BIDSPath):
if fname.suffix not in ("raw", "epochs"):
# raw and epochs can split on write, and .save should check for us
assert fname.split is None, fname.split
fname = pathlib.Path(fname)
if not fname.is_relative_to(check_relative):
raise RuntimeError(
Expand Down
5 changes: 4 additions & 1 deletion mne_bids_pipeline/steps/freesurfer/_02_coreg_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def make_coreg_surfaces(
)
out_files = get_output_fnames_coreg_surfaces(cfg=cfg, subject=subject)
return _prep_out_files(
exec_params=exec_params, out_files=out_files, check_relative=cfg.fs_subjects_dir
exec_params=exec_params,
out_files=out_files,
check_relative=cfg.fs_subjects_dir,
bids_only=False,
)


Expand Down
5 changes: 4 additions & 1 deletion mne_bids_pipeline/steps/preprocessing/_07_make_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def run_epochs(
logger.info(**gen_log_kwargs(message=msg))
out_files = dict()
out_files["epochs"] = bids_path_in.copy().update(
suffix="epo", processing=None, check=False
suffix="epo",
processing=None,
check=False,
split=None,
)
epochs.save(
out_files["epochs"],
Expand Down
5 changes: 4 additions & 1 deletion mne_bids_pipeline/steps/source/_01_make_bem_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def make_bem_surfaces(
session=session,
)
return _prep_out_files(
exec_params=exec_params, out_files=out_files, check_relative=cfg.fs_subjects_dir
exec_params=exec_params,
out_files=out_files,
check_relative=cfg.fs_subjects_dir,
bids_only=False,
)


Expand Down
5 changes: 4 additions & 1 deletion mne_bids_pipeline/steps/source/_03_setup_source_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def run_setup_source_space(
out_files = get_output_fnames_setup_source_space(cfg=cfg, subject=subject)
mne.write_source_spaces(out_files["src"], src, overwrite=True)
return _prep_out_files(
exec_params=exec_params, out_files=out_files, check_relative=cfg.fs_subjects_dir
exec_params=exec_params,
out_files=out_files,
check_relative=cfg.fs_subjects_dir,
bids_only=False,
)


Expand Down

0 comments on commit 7410306

Please sign in to comment.