Skip to content

Commit a5f88c2

Browse files
RF: set surface BrainModel default structure to Other
1 parent e4bc7b0 commit a5f88c2

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

nibabel/cifti2/cifti2_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def from_mask(cls, mask, name='other', affine=None):
232232
"3-dimensional (for volumes), not %i-dimensional" % mask.ndim)
233233

234234
@classmethod
235-
def from_surface(cls, vertices, nvertex, name='Cortex'):
235+
def from_surface(cls, vertices, nvertex, name='Other'):
236236
"""
237237
Creates a new BrainModel axis describing the vertices on a surface
238238

nibabel/cifti2/tests/test_axes.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,33 +125,34 @@ def test_brain_models():
125125
assert (bml[4].voxel == -1).all()
126126
assert (bml[4].vertex == [2, 9, 14]).all()
127127

128-
for bm, label in zip(bml, ['ThalamusRight', 'Other', 'cortex_left', 'cortex']):
128+
for bm, label, is_surface in zip(bml, ['ThalamusRight', 'Other', 'cortex_left', 'Other'],
129+
(False, False, True, True)):
129130
structures = list(bm.iter_structures())
130131
assert len(structures) == 1
131132
name = structures[0][0]
132133
assert name == axes.BrainModel.to_cifti_brain_structure_name(label)
133-
if 'CORTEX' in name:
134+
if is_surface:
134135
assert bm.nvertices[name] == 15
135136
else:
136137
assert name not in bm.nvertices
137138
assert (bm.affine == rand_affine).all()
138139
assert bm.volume_shape == vol_shape
139140

140-
bmt = bml[0] + bml[1] + bml[2] + bml[3]
141-
assert len(bmt) == 14
141+
bmt = bml[0] + bml[1] + bml[2]
142+
assert len(bmt) == 10
142143
structures = list(bmt.iter_structures())
143-
assert len(structures) == 4
144-
for bm, (name, _, bm_split) in zip(bml, structures):
144+
assert len(structures) == 3
145+
for bm, (name, _, bm_split) in zip(bml[:3], structures):
145146
assert bm == bm_split
146147
assert (bm_split.name == name).all()
147148
assert bm == bmt[bmt.name == bm.name[0]]
148149
assert bm == bmt[np.where(bmt.name == bm.name[0])]
149150

150-
bmt = bmt + bml[3]
151-
assert len(bmt) == 18
151+
bmt = bmt + bml[2]
152+
assert len(bmt) == 13
152153
structures = list(bmt.iter_structures())
153-
assert len(structures) == 4
154-
assert len(structures[-1][2]) == 8
154+
assert len(structures) == 3
155+
assert len(structures[-1][2]) == 6
155156

156157
# break brain model
157158
bmt.affine = np.eye(4)
@@ -320,7 +321,7 @@ def test_parcels():
320321
assert prc[2] == ('surface', ) + prc['surface']
321322
assert prc['surface'][0].shape == (0, 3)
322323
assert len(prc['surface'][1]) == 1
323-
assert prc['surface'][1]['CIFTI_STRUCTURE_CORTEX'].shape == (4, )
324+
assert prc['surface'][1]['CIFTI_STRUCTURE_OTHER'].shape == (4, )
324325

325326
prc2 = prc + prc
326327
assert len(prc2) == 6

0 commit comments

Comments
 (0)