Skip to content

Commit

Permalink
Raise interpretable error when no BOLD runs survive minimum-time thre…
Browse files Browse the repository at this point in the history
…shold (PennLINC#1048)
  • Loading branch information
tsalo authored Feb 16, 2024
1 parent 1d7bce2 commit a23910d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 13 additions & 3 deletions xcp_d/interfaces/report_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,27 @@ def generate_reports(
else:
LOGGER.info("Generating executive summary.")
for subject_label in subject_list:
brainplotfile = glob.glob(
brainplotfiles = glob.glob(
os.path.join(
output_dir,
f"xcp_d/sub-{subject_label}",
"figures/*_bold.svg",
),
)[0]
)
if not brainplotfiles:
LOGGER.warning(
"No postprocessing BOLD figures found for subject %s.",
subject_label,
)
session_id = None
else:
brainplotfile = brainplotfiles[0]
session_id = get_entity(brainplotfile, "ses")

exsumm = ExecutiveSummary(
xcpd_path=os.path.join(output_dir, "xcp_d"),
subject_id=subject_label,
session_id=get_entity(brainplotfile, "ses"),
session_id=session_id,
)
exsumm.collect_inputs()
exsumm.generate_report()
Expand Down
6 changes: 6 additions & 0 deletions xcp_d/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,12 @@ def init_subject_wf(
for io_name, node in merge_dict.items():
workflow.connect([(node, concatenate_data_wf, [("out", f"inputnode.{io_name}")])])

if run_counter == 0:
raise RuntimeError(
f"No runs survived high-motion outlier scrubbing for subject {subject_id}. "
"Quitting workflow."
)

workflow.connect([
(summary, ds_report_summary, [("out_report", "in_file")]),
(about, ds_report_about, [("out_report", "in_file")]),
Expand Down

0 comments on commit a23910d

Please sign in to comment.