Skip to content

Commit

Permalink
enh: adapt the call to Report to its nireports implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
celprov committed Dec 13, 2023
1 parent 363b9f3 commit f0606af
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions fmriprep/reports/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
from pathlib import Path

from nireports.reports.core import Report as _Report
from nireports.assembler.report import Report as _Report

# This patch is intended to permit fMRIPrep 20.2.0 LTS to use the YODA-style
# derivatives directory. Ideally, we will remove this in 20.3.x and use an
Expand Down Expand Up @@ -52,22 +52,17 @@ def _load_config(self, config):
# The following are the interface used directly by fMRIPrep
#

def generate_reports(
subject_list, output_dir, run_uuid, config=None, work_dir=None, packagename=None
):

def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=None):
"""Generate reports for a list of subjects."""
reportlets_dir = None
if work_dir is not None:
reportlets_dir = Path(work_dir) / "reportlets"

report_errors = []
for subject_label in subject_list:

# Problem subject_label is not a path to a file, I think
entities = config.execution.layout.get_file(subject_label).get_entities()
entities.pop("extension", None)
entities.pop("echo", None)
entities.pop("part", None)
entities = {}
entities["sub"] = subject_label

robj = Report(
output_dir,
Expand All @@ -77,14 +72,16 @@ def generate_reports(
plugins=None,
plugin_meta=None,
metadata=None,
**entities
**entities,
)

# Problem: this does not make sense anymore because generate_report in nireports always returns 0
report_errors.append(robj.generate_report())

# Count nbr of subject for which report generation failed
errno = 0
try:
robj.generate_report()
except:
errno += 1

errno = sum(report_errors)
if errno:
import logging

Expand Down

0 comments on commit f0606af

Please sign in to comment.