9
9
10
10
import matplotlib .pyplot as plt
11
11
from bids .layout .writing import build_path
12
+ from bids .layout import BIDSLayout
12
13
13
14
import pytest
14
15
@@ -24,26 +25,28 @@ def bids_sessions(tmpdir_factory):
24
25
pattern = (
25
26
"sub-{subject}[/ses-{session}]/{datatype<anat|func>}/"
26
27
"sub-{subject}[_ses-{session}][_task-{task}][_acq-{acquisition}]"
27
- "[_ce-{contrast }][_dir-{direction}][_rec-{reconstruction}]"
28
+ "[_ce-{ceagent }][_dir-{direction}][_rec-{reconstruction}]"
28
29
"[_mod-{modality}][_run-{run}][_echo-{echo}][_space-{space}]"
29
30
"[_desc-{desc}]_{suffix<dseg|T1w|bold>}.{extension<svg>}"
30
31
)
31
32
subjects = ['01' ]
32
33
tasks = ['t1' , 't2' , 't3' ]
33
34
runs = ['01' , '02' , None ]
35
+ ces = ['none' , 'Gd' ]
34
36
descs = ['aroma' , 'bbregister' , 'carpetplot' , 'rois' ]
35
37
# create functional data for both sessions
36
- ses1_combos = product (subjects , ['1' ], tasks , runs , descs )
37
- ses2_combos = product (subjects , ['2' ], tasks , [None ], descs )
38
+ ses1_combos = product (subjects , ['1' ], tasks , [ None ], runs , descs )
39
+ ses2_combos = product (subjects , ['2' ], tasks , ces , [None ], descs )
38
40
# have no runs in the second session (ex: dmriprep test data)
39
41
# https://github.com/nipreps/dmriprep/pull/59
40
42
all_combos = list (ses1_combos ) + list (ses2_combos )
41
43
42
- for subject , session , task , run , desc in all_combos :
44
+ for subject , session , task , ce , run , desc in all_combos :
43
45
entities = {
44
46
'subject' : subject ,
45
47
'session' : session ,
46
48
'task' : task ,
49
+ 'ceagent' : ce ,
47
50
'run' : run ,
48
51
'desc' : desc ,
49
52
'extension' : 'svg' ,
@@ -143,10 +146,10 @@ def test_process_orderings_small(test_report1, orderings,
143
146
@pytest .mark .parametrize (
144
147
"orderings,expected_entities,first_value_combo,last_value_combo" ,
145
148
[
146
- (['session' , 'task' , 'run' ],
147
- ['session' , 'task' , 'run' ],
148
- ('1' , 't1' , None ),
149
- ('2' , 't3' , None ),
149
+ (['session' , 'task' , 'ceagent' , ' run' ],
150
+ ['session' , 'task' , 'ceagent' , ' run' ],
151
+ ('1' , 't1' , None , None ),
152
+ ('2' , 't3' , 'none' , None ),
150
153
),
151
154
(['run' , 'task' , 'session' ],
152
155
['run' , 'task' , 'session' ],
@@ -182,6 +185,7 @@ def test_process_orderings_large(test_report2, orderings,
182
185
("run" ),
183
186
("session,task" ),
184
187
("session,task,run" ),
188
+ ("session,task,ceagent,run" ),
185
189
("session,task,acquisition,ceagent,reconstruction,direction,run,echo" ),
186
190
("session,task,run,madeupentity" ),
187
191
])
@@ -198,12 +202,15 @@ def test_generated_reportlets(bids_sessions, ordering):
198
202
# expected number of reportlets
199
203
expected_reportlets_num = len (report .layout .get (extension = 'svg' ))
200
204
# bids_session uses these entities
201
- needed_entities = ['session' , 'task' , 'run' ]
205
+ needed_entities = ['session' , 'task' , 'ceagent' , ' run' ]
202
206
# the last section is the most recently run
203
207
reportlets_num = len (report .sections [- 1 ].reportlets )
208
+ # get the number of figures in the output directory
209
+ out_layout = BIDSLayout (out_dir , config = 'figures' , validate = False )
210
+ out_figs = len (out_layout .get ())
204
211
# if ordering does not contain all the relevent entities
205
212
# then there should be fewer reportlets than expected
206
213
if all (ent in ordering for ent in needed_entities ):
207
- assert reportlets_num == expected_reportlets_num
214
+ assert reportlets_num == expected_reportlets_num == out_figs
208
215
else :
209
- assert reportlets_num < expected_reportlets_num
216
+ assert reportlets_num < expected_reportlets_num == out_figs
0 commit comments