12
12
13
13
DEFAULT_OUTPUT_SPACES = {"MNIInfant" ,}
14
14
15
+ CHECKMARK = u' \u2713 '
16
+
15
17
16
18
def get_parser ():
17
19
@@ -88,8 +90,10 @@ def test_functionals(func_dir):
88
90
outtype = None
89
91
if 'desc-brain_mask' in fl .name :
90
92
outtype = 'masks'
91
- elif 'desc-preproc_bold' in fl .name or '_boldref.' in fl . name :
93
+ elif 'desc-preproc_bold' in fl .name :
92
94
outtype = 'preprocs'
95
+ elif '_boldref.' in fl .name :
96
+ outtype = 'boldrefs'
93
97
elif 'desc-aseg_dseg' in fl .name or '_probseg.' in fl .name :
94
98
outtype = 'segs'
95
99
elif '_xfm.' in fl .name :
@@ -103,6 +107,7 @@ def test_functionals(func_dir):
103
107
outputs [outtype ].append (fl )
104
108
105
109
_check_bold_preprocs (outputs ['preprocs' ])
110
+ _check_boldrefs (outputs ['boldrefs' ])
106
111
_check_masks (outputs ['masks' ])
107
112
_check_segs (outputs ['segs' ])
108
113
_check_xfms (outputs ['xfms' ])
@@ -121,7 +126,7 @@ def _check_masks(masks):
121
126
img = nb .load (mask )
122
127
assert img .dataobj .dtype == np .uint8
123
128
assert np .all (np .unique (img .dataobj ) == [0 , 1 ])
124
- print (u' \u2713 ' )
129
+ print (CHECKMARK )
125
130
126
131
127
132
def _check_segs (segs ):
@@ -148,7 +153,7 @@ def _check_segs(segs):
148
153
assert img .dataobj .dtype == np .float32
149
154
assert np .max (img .dataobj ) == 1
150
155
assert np .min (img .dataobj ) == 0
151
- print (u' \u2713 ' )
156
+ print (CHECKMARK )
152
157
153
158
154
159
def _check_xfms (xfms ):
@@ -158,9 +163,12 @@ def _check_xfms(xfms):
158
163
assert nt .linear .load (xfm , fmt = 'itk' )
159
164
elif xfm .name .endswith ('.h5' ):
160
165
assert nt .manip .load (xfm )
166
+ elif xfm .name .endswith ('.json' ):
167
+ meta = json .loads (xfm .read_text ())
168
+ assert 'Sources' in meta
161
169
else :
162
170
raise NotImplementedError
163
- print (u' \u2713 ' )
171
+ print (CHECKMARK )
164
172
165
173
166
174
def _check_surfs (surfs ):
@@ -172,7 +180,7 @@ def _check_surfs(surfs):
172
180
da0 , da1 = img .darrays
173
181
assert da0 .intent == 1008 # NIFTI_INTENT_POINTSET
174
182
assert da1 .intent == 1009 # NIFTI_INTENT_TRIANGLE
175
- print (u' \u2713 ' )
183
+ print (CHECKMARK )
176
184
177
185
178
186
def _check_t1w_preprocs (preprocs ):
@@ -184,7 +192,7 @@ def _check_t1w_preprocs(preprocs):
184
192
else :
185
193
img = nb .load (preproc )
186
194
assert len (img .shape ) == 3
187
- print (u' \u2713 ' )
195
+ print (CHECKMARK )
188
196
189
197
190
198
def _check_bold_preprocs (preprocs ):
@@ -195,11 +203,21 @@ def _check_bold_preprocs(preprocs):
195
203
assert metadata ['SkullStripped' ] is False
196
204
else :
197
205
img = nb .load (preproc )
198
- if '_boldref.' in preproc .name :
199
- assert len (img .shape ) == 3
200
- elif 'desc-preproc_bold' in preproc .name :
201
- assert len (img .shape ) == 4
202
- print (u' \u2713 ' )
206
+ assert len (img .shape ) == 4
207
+ print (CHECKMARK )
208
+
209
+
210
+ def _check_boldrefs (boldrefs ):
211
+ for boldref in boldrefs :
212
+ print (str (boldref ), end = '' )
213
+ if '.json' in boldref .name :
214
+ metadata = json .loads (boldref .read_text ())
215
+ assert 'Sources' in metadata
216
+ else :
217
+ bimg = nb .load (boldref )
218
+ if len (bimg .shape ) > 3 :
219
+ assert len (bimg .shape ) == 4 and bimg .shape [3 ] == 1
220
+ print (CHECKMARK )
203
221
204
222
205
223
def _check_ciftis (ciftis ):
@@ -217,7 +235,7 @@ def _check_ciftis(ciftis):
217
235
bm_map = matrix .get_index_map (1 )
218
236
assert series_map .indices_map_to_data_type == 'CIFTI_INDEX_TYPE_SERIES'
219
237
assert bm_map .indices_map_to_data_type == 'CIFTI_INDEX_TYPE_BRAIN_MODELS'
220
- print (u' \u2713 ' )
238
+ print (CHECKMARK )
221
239
222
240
223
241
if __name__ == "__main__" :
0 commit comments