1212
1313DEFAULT_OUTPUT_SPACES = {"MNIInfant" ,}
1414
15+ CHECKMARK = u' \u2713 '
16+
1517
1618def get_parser ():
1719
@@ -88,8 +90,10 @@ def test_functionals(func_dir):
8890 outtype = None
8991 if 'desc-brain_mask' in fl .name :
9092 outtype = 'masks'
91- elif 'desc-preproc_bold' in fl .name or '_boldref.' in fl . name :
93+ elif 'desc-preproc_bold' in fl .name :
9294 outtype = 'preprocs'
95+ elif '_boldref.' in fl .name :
96+ outtype = 'boldrefs'
9397 elif 'desc-aseg_dseg' in fl .name or '_probseg.' in fl .name :
9498 outtype = 'segs'
9599 elif '_xfm.' in fl .name :
@@ -103,6 +107,7 @@ def test_functionals(func_dir):
103107 outputs [outtype ].append (fl )
104108
105109 _check_bold_preprocs (outputs ['preprocs' ])
110+ _check_boldrefs (outputs ['boldrefs' ])
106111 _check_masks (outputs ['masks' ])
107112 _check_segs (outputs ['segs' ])
108113 _check_xfms (outputs ['xfms' ])
@@ -121,7 +126,7 @@ def _check_masks(masks):
121126 img = nb .load (mask )
122127 assert img .dataobj .dtype == np .uint8
123128 assert np .all (np .unique (img .dataobj ) == [0 , 1 ])
124- print (u' \u2713 ' )
129+ print (CHECKMARK )
125130
126131
127132def _check_segs (segs ):
@@ -148,7 +153,7 @@ def _check_segs(segs):
148153 assert img .dataobj .dtype == np .float32
149154 assert np .max (img .dataobj ) == 1
150155 assert np .min (img .dataobj ) == 0
151- print (u' \u2713 ' )
156+ print (CHECKMARK )
152157
153158
154159def _check_xfms (xfms ):
@@ -158,9 +163,12 @@ def _check_xfms(xfms):
158163 assert nt .linear .load (xfm , fmt = 'itk' )
159164 elif xfm .name .endswith ('.h5' ):
160165 assert nt .manip .load (xfm )
166+ elif xfm .name .endswith ('.json' ):
167+ meta = json .loads (xfm .read_text ())
168+ assert 'Sources' in meta
161169 else :
162170 raise NotImplementedError
163- print (u' \u2713 ' )
171+ print (CHECKMARK )
164172
165173
166174def _check_surfs (surfs ):
@@ -172,7 +180,7 @@ def _check_surfs(surfs):
172180 da0 , da1 = img .darrays
173181 assert da0 .intent == 1008 # NIFTI_INTENT_POINTSET
174182 assert da1 .intent == 1009 # NIFTI_INTENT_TRIANGLE
175- print (u' \u2713 ' )
183+ print (CHECKMARK )
176184
177185
178186def _check_t1w_preprocs (preprocs ):
@@ -184,7 +192,7 @@ def _check_t1w_preprocs(preprocs):
184192 else :
185193 img = nb .load (preproc )
186194 assert len (img .shape ) == 3
187- print (u' \u2713 ' )
195+ print (CHECKMARK )
188196
189197
190198def _check_bold_preprocs (preprocs ):
@@ -195,11 +203,21 @@ def _check_bold_preprocs(preprocs):
195203 assert metadata ['SkullStripped' ] is False
196204 else :
197205 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 )
203221
204222
205223def _check_ciftis (ciftis ):
@@ -217,7 +235,7 @@ def _check_ciftis(ciftis):
217235 bm_map = matrix .get_index_map (1 )
218236 assert series_map .indices_map_to_data_type == 'CIFTI_INDEX_TYPE_SERIES'
219237 assert bm_map .indices_map_to_data_type == 'CIFTI_INDEX_TYPE_BRAIN_MODELS'
220- print (u' \u2713 ' )
238+ print (CHECKMARK )
221239
222240
223241if __name__ == "__main__" :
0 commit comments