Skip to content

Commit cffb8c0

Browse files
DOC: test creation of bm_thal and bm_cortex
1 parent 532bed9 commit cffb8c0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

nibabel/cifti2/cifti2_axes.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@
5050
We can create brain models covering the left cortex and left thalamus using:
5151
5252
>>> from nibabel import cifti2
53-
>>> bm_cortex = cifti2.BrainModelAxis.from_mask(cortex_mask,
54-
... brain_structure='cortex_left') # doctest: +SKIP
55-
>>> bm_thal = cifti2.BrainModelAxis.from_mask(thalamus_mask, affine=affine,
56-
... brain_structure='thalamus_left') # doctest: +SKIP
53+
>>> import numpy as np
54+
>>> bm_cortex = cifti2.BrainModelAxis.from_mask([True, False, True, True],
55+
... name='cortex_left')
56+
>>> bm_thal = cifti2.BrainModelAxis.from_mask(np.ones((2, 2, 2)), affine=np.eye(4),
57+
... name='thalamus_left')
58+
59+
In this very simple case ``bm_cortex`` describes a left cortical surface skipping the second
60+
out of four vertices. ``bm_thal`` contains all voxels in a 2x2x2 volume.
5761
5862
Brain structure names automatically get converted to valid CIFTI-2 indentifiers using
5963
:meth:`BrainModelAxis.to_cifti_brain_structure_name`.
@@ -332,6 +336,8 @@ def from_mask(cls, mask, name='other', affine=None):
332336
affine = np.asanyarray(affine)
333337
if affine.shape != (4, 4):
334338
raise ValueError("Affine transformation should be a 4x4 array or None, not %r" % affine)
339+
340+
mask = np.asanyarray(mask)
335341
if mask.ndim == 1:
336342
return cls.from_surface(np.where(mask != 0)[0], mask.size, name=name)
337343
elif mask.ndim == 3:

0 commit comments

Comments
 (0)