Skip to content

Commit

Permalink
Generate session-wise executive summaries (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo authored Jul 17, 2024
1 parent 80d384e commit 5f937df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ doc = [
"pydotplus",
"recommonmark",
"sphinx >= 4.2.0",
"sphinx-argparse",
"sphinx-argparse != 0.5.0",
"sphinx-markdown-tables",
"sphinx_rtd_theme",
"sphinxcontrib-apidoc",
Expand Down
29 changes: 12 additions & 17 deletions xcp_d/reports/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
This is adapted from fMRIPost-AROMA.
"""

import glob
import os
from pathlib import Path

from nireports.assembler.report import Report

from xcp_d import config, data
from xcp_d.interfaces.execsummary import ExecutiveSummary
from xcp_d.utils.bids import get_entity


def run_reports(
Expand Down Expand Up @@ -146,24 +143,22 @@ def generate_reports(
)
else:
config.loggers.cli.info("Generating executive summary.")
for subject_label in subject_list:
brainplotfiles = glob.glob(
os.path.join(output_dir, f"sub-{subject_label}/figures/*_bold.svg"),
)
if not brainplotfiles:
config.loggers.cli.warning(
"No postprocessing BOLD figures found for subject %s.",
subject_label,
)
session_id = None
else:
brainplotfile = brainplotfiles[0]
session_id = get_entity(brainplotfile, "ses")

if session_list is None:
all_filters = config.execution.bids_filters or {}
filters = all_filters.get("bold", {})
session_list = config.execution.layout.get_sessions(subject=subject_label, **filters)

# Drop ses- prefixes
session_list = [ses[4:] if ses.startswith("ses-") else ses for ses in session_list]
if not session_list:
session_list = [None]

for session_label in session_list:
exsumm = ExecutiveSummary(
xcpd_path=output_dir,
subject_id=subject_label,
session_id=session_id,
session_id=session_label,
)
exsumm.collect_inputs()
exsumm.generate_report()
Expand Down

0 comments on commit 5f937df

Please sign in to comment.