@@ -128,7 +128,9 @@ def test_brain_models():
128
128
assert (bml [4 ].vertex == [2 , 9 , 14 ]).all ()
129
129
130
130
for bm , label , is_surface in zip (
131
- bml , ['ThalamusRight' , 'Other' , 'cortex_left' , 'Other' ], (False , False , True , True )
131
+ bml ,
132
+ ['ThalamusRight' , 'Other' , 'cortex_left' , 'Other' ],
133
+ (False , False , True , True ),
132
134
):
133
135
assert np .all (bm .surface_mask == ~ bm .volume_mask )
134
136
structures = list (bm .iter_structures ())
@@ -176,18 +178,27 @@ def test_brain_models():
176
178
177
179
# Test the constructor
178
180
bm_vox = axes .BrainModelAxis (
179
- 'thalamus_left' , voxel = np .ones ((5 , 3 ), dtype = int ), affine = np .eye (4 ), volume_shape = (2 , 3 , 4 )
181
+ 'thalamus_left' ,
182
+ voxel = np .ones ((5 , 3 ), dtype = int ),
183
+ affine = np .eye (4 ),
184
+ volume_shape = (2 , 3 , 4 ),
180
185
)
181
186
assert np .all (bm_vox .name == ['CIFTI_STRUCTURE_THALAMUS_LEFT' ] * 5 )
182
187
assert np .array_equal (bm_vox .vertex , np .full (5 , - 1 ))
183
188
assert np .array_equal (bm_vox .voxel , np .full ((5 , 3 ), 1 ))
184
189
with pytest .raises (ValueError ):
185
190
# no volume shape
186
- axes .BrainModelAxis ('thalamus_left' , voxel = np .ones ((5 , 3 ), dtype = int ), affine = np .eye (4 ))
191
+ axes .BrainModelAxis (
192
+ 'thalamus_left' ,
193
+ voxel = np .ones ((5 , 3 ), dtype = int ),
194
+ affine = np .eye (4 ),
195
+ )
187
196
with pytest .raises (ValueError ):
188
197
# no affine
189
198
axes .BrainModelAxis (
190
- 'thalamus_left' , voxel = np .ones ((5 , 3 ), dtype = int ), volume_shape = (2 , 3 , 4 )
199
+ 'thalamus_left' ,
200
+ voxel = np .ones ((5 , 3 ), dtype = int ),
201
+ volume_shape = (2 , 3 , 4 ),
191
202
)
192
203
with pytest .raises (ValueError ):
193
204
# incorrect name
@@ -207,7 +218,11 @@ def test_brain_models():
207
218
)
208
219
with pytest .raises (ValueError ):
209
220
# no voxels or vertices
210
- axes .BrainModelAxis ('thalamus_left' , affine = np .eye (4 ), volume_shape = (2 , 3 , 4 ))
221
+ axes .BrainModelAxis (
222
+ 'thalamus_left' ,
223
+ affine = np .eye (4 ),
224
+ volume_shape = (2 , 3 , 4 ),
225
+ )
211
226
with pytest .raises (ValueError ):
212
227
# incorrect voxel shape
213
228
axes .BrainModelAxis (
@@ -218,7 +233,9 @@ def test_brain_models():
218
233
)
219
234
220
235
bm_vertex = axes .BrainModelAxis (
221
- 'cortex_left' , vertex = np .ones (5 , dtype = int ), nvertices = {'cortex_left' : 20 }
236
+ 'cortex_left' ,
237
+ vertex = np .ones (5 , dtype = int ),
238
+ nvertices = {'cortex_left' : 20 },
222
239
)
223
240
assert np .array_equal (bm_vertex .name , ['CIFTI_STRUCTURE_CORTEX_LEFT' ] * 5 )
224
241
assert np .array_equal (bm_vertex .vertex , np .full (5 , 1 ))
@@ -227,11 +244,15 @@ def test_brain_models():
227
244
axes .BrainModelAxis ('cortex_left' , vertex = np .ones (5 , dtype = int ))
228
245
with pytest .raises (ValueError ):
229
246
axes .BrainModelAxis (
230
- 'cortex_left' , vertex = np .ones (5 , dtype = int ), nvertices = {'cortex_right' : 20 }
247
+ 'cortex_left' ,
248
+ vertex = np .ones (5 , dtype = int ),
249
+ nvertices = {'cortex_right' : 20 },
231
250
)
232
251
with pytest .raises (ValueError ):
233
252
axes .BrainModelAxis (
234
- 'cortex_left' , vertex = - np .ones (5 , dtype = int ), nvertices = {'cortex_left' : 20 }
253
+ 'cortex_left' ,
254
+ vertex = - np .ones (5 , dtype = int ),
255
+ nvertices = {'cortex_left' : 20 },
235
256
)
236
257
237
258
# test from_mask errors
@@ -244,7 +265,10 @@ def test_brain_models():
244
265
245
266
# tests error in adding together or combining as ParcelsAxis
246
267
bm_vox = axes .BrainModelAxis (
247
- 'thalamus_left' , voxel = np .ones ((5 , 3 ), dtype = int ), affine = np .eye (4 ), volume_shape = (2 , 3 , 4 )
268
+ 'thalamus_left' ,
269
+ voxel = np .ones ((5 , 3 ), dtype = int ),
270
+ affine = np .eye (4 ),
271
+ volume_shape = (2 , 3 , 4 ),
248
272
)
249
273
bm_vox + bm_vox
250
274
assert (bm_vertex + bm_vox )[: bm_vertex .size ] == bm_vertex
@@ -289,7 +313,10 @@ def test_brain_models():
289
313
290
314
# test equalities
291
315
bm_vox = axes .BrainModelAxis (
292
- 'thalamus_left' , voxel = np .ones ((5 , 3 ), dtype = int ), affine = np .eye (4 ), volume_shape = (2 , 3 , 4 )
316
+ 'thalamus_left' ,
317
+ voxel = np .ones ((5 , 3 ), dtype = int ),
318
+ affine = np .eye (4 ),
319
+ volume_shape = (2 , 3 , 4 ),
293
320
)
294
321
bm_other = deepcopy (bm_vox )
295
322
assert bm_vox == bm_other
0 commit comments