Skip to content

Commit f0606af

Browse files
committed
enh: adapt the call to Report to its nireports implementation
1 parent 363b9f3 commit f0606af

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

fmriprep/reports/core.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
from pathlib import Path
2424

25-
from nireports.reports.core import Report as _Report
25+
from nireports.assembler.report import Report as _Report
2626

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

55-
def generate_reports(
56-
subject_list, output_dir, run_uuid, config=None, work_dir=None, packagename=None
57-
):
55+
56+
def generate_reports(subject_list, output_dir, run_uuid, config=None, work_dir=None):
5857
"""Generate reports for a list of subjects."""
5958
reportlets_dir = None
6059
if work_dir is not None:
6160
reportlets_dir = Path(work_dir) / "reportlets"
6261

6362
report_errors = []
6463
for subject_label in subject_list:
65-
66-
# Problem subject_label is not a path to a file, I think
67-
entities = config.execution.layout.get_file(subject_label).get_entities()
68-
entities.pop("extension", None)
69-
entities.pop("echo", None)
70-
entities.pop("part", None)
64+
entities = {}
65+
entities["sub"] = subject_label
7166

7267
robj = Report(
7368
output_dir,
@@ -77,14 +72,16 @@ def generate_reports(
7772
plugins=None,
7873
plugin_meta=None,
7974
metadata=None,
80-
**entities
75+
**entities,
8176
)
8277

83-
# Problem: this does not make sense anymore because generate_report in nireports always returns 0
84-
report_errors.append(robj.generate_report())
85-
78+
# Count nbr of subject for which report generation failed
79+
errno = 0
80+
try:
81+
robj.generate_report()
82+
except:
83+
errno += 1
8684

87-
errno = sum(report_errors)
8885
if errno:
8986
import logging
9087

0 commit comments

Comments
 (0)