@@ -188,13 +188,13 @@ class Report(object):
188
188
.. doctest::
189
189
190
190
>>> robj = Report(testdir / 'work' / 'reportlets', testdir / 'out',
191
- ... 'madeoutuuid', subject_id='01')
191
+ ... 'madeoutuuid', subject_id='01', packagename='fmriprep' )
192
192
>>> robj.layout.get(subject='01', desc='reconall')
193
- [<BIDSFile filename='fmriprep/sub-01/ anat/sub-01_desc-reconall_T1w.svg'>]
193
+ [<BIDSFile filename='anat/sub-01_desc-reconall_T1w.svg'>]
194
194
195
195
>>> robj.generate_report()
196
196
0
197
- >>> len((testdir / 'out' / 'niworkflows ' / 'sub-01.html').read_text())
197
+ >>> len((testdir / 'out' / 'fmriprep ' / 'sub-01.html').read_text())
198
198
20862
199
199
200
200
"""
@@ -204,13 +204,12 @@ def __init__(self, reportlets_dir, out_dir, run_uuid, config=None,
204
204
packagename = None ):
205
205
self .root = reportlets_dir
206
206
207
- # Initialize a BIDS layout
207
+ # Add a new figures spec
208
208
try :
209
209
add_config_paths (figures = pkgrf ('niworkflows' , 'reports/figures.json' ))
210
210
except ValueError as e :
211
211
if "Configuration 'figures' already exists" != str (e ):
212
212
raise
213
- self .layout = BIDSLayout (self .root , config = 'figures' , validate = False )
214
213
215
214
# Initialize structuring elements
216
215
self .sections = []
@@ -232,7 +231,7 @@ def __init__(self, reportlets_dir, out_dir, run_uuid, config=None,
232
231
self ._load_config (Path (config ))
233
232
234
233
def _load_config (self , config ):
235
- from yaml import load
234
+ from yaml import safe_load as load
236
235
settings = load (config .read_text ())
237
236
self .packagename = self .packagename or settings .get ('package' , None )
238
237
@@ -252,8 +251,11 @@ def _load_config(self, config):
252
251
def index (self , config ):
253
252
"""
254
253
Traverse the reports config definition and instantiate reportlets.
254
+
255
255
This method also places figures in their final location.
256
256
"""
257
+ # Initialize a BIDS layout
258
+ self .layout = BIDSLayout (self .root , config = 'figures' , validate = False )
257
259
for subrep_cfg in config :
258
260
# First determine whether we need to split by some ordering
259
261
# (ie. sessions / tasks / runs), which are separated by commas.
@@ -297,9 +299,8 @@ def index(self, config):
297
299
title = subrep_cfg .get ('title' ))
298
300
self .sections .append (sub_report )
299
301
300
- # Populate errors sections
301
- error_dir = self .out_dir / self .packagename / 'sub-{}' .format (self .subject_id ) / \
302
- 'log' / self .run_uuid
302
+ # Populate errors section
303
+ error_dir = self .out_dir / 'sub-{}' .format (self .subject_id ) / 'log' / self .run_uuid
303
304
if error_dir .is_dir ():
304
305
from ..utils .misc import read_crashfile
305
306
self .errors = [read_crashfile (str (f )) for f in error_dir .glob ('crash*.*' )]
@@ -368,16 +369,16 @@ def run_reports(reportlets_dir, out_dir, subject_label, run_uuid, config=None,
368
369
369
370
.. doctest::
370
371
371
- >>> run_reports(str( testdir / 'work' / 'reportlets') ,
372
- ... str(testdir / 'out') , '01 ', 'madeoutuuid ')
372
+ >>> run_reports(testdir / 'work' / 'reportlets', testdir / 'out' ,
373
+ ... '01' , 'madeoutuuid ', packagename='fmriprep ')
373
374
0
374
375
375
376
.. testcleanup::
376
377
377
378
>>> tmpdir.cleanup()
378
379
379
380
"""
380
- report = Report (Path ( reportlets_dir ) , out_dir , run_uuid , config = config ,
381
+ report = Report (reportlets_dir , out_dir , run_uuid , config = config ,
381
382
subject_id = subject_label , packagename = packagename )
382
383
return report .generate_report ()
383
384
@@ -387,9 +388,9 @@ def generate_reports(subject_list, output_dir, work_dir, run_uuid, config=None,
387
388
"""
388
389
A wrapper to run_reports on a given ``subject_list``
389
390
"""
390
- reports_dir = str ( Path (work_dir ) / 'reportlets' )
391
+ reportlets_dir = Path (work_dir ) / 'reportlets'
391
392
report_errors = [
392
- run_reports (reports_dir , output_dir , subject_label , run_uuid ,
393
+ run_reports (reportlets_dir , output_dir , subject_label , run_uuid ,
393
394
config , packagename = packagename )
394
395
for subject_label in subject_list
395
396
]
0 commit comments