Skip to content

Commit 36c162d

Browse files
BF: doctest fixes for tutorial
1 parent 97e16d3 commit 36c162d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

nibabel/cifti2/cifti2_axes.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@
8080
8181
You can also iterate over all brain structures in a brain model:
8282
83-
>>> for name, slc, bm in bm_full.iter_structures(): ...
83+
>>> for idx, (name, slc, bm) in enumerate(bm_full.iter_structures()):
84+
... print(name, slc)
85+
... assert bm == bm_full[slc]
86+
... assert bm == bm_cortex if idx == 0 else bm_thal
87+
CIFTI_STRUCTURE_CORTEX_LEFT slice(0, 3, None)
88+
CIFTI_STRUCTURE_THALAMUS_LEFT slice(3, None, None)
8489
8590
In this case there will be two iterations, namely:
8691
('CIFTI_STRUCTURE_CORTEX_LEFT', slice(0, <size of cortex mask>), bm_cortex)
@@ -90,9 +95,9 @@
9095
ParcelsAxis can be constructed from selections of these brain models:
9196
9297
>>> parcel = cifti2.ParcelsAxis.from_brain_models([
93-
... ('surface_parcel', bm_cortex[:100]), # contains first 100 cortical vertices
98+
... ('surface_parcel', bm_cortex[:2]), # contains first 2 cortical vertices
9499
... ('volume_parcel', bm_thal), # contains thalamus
95-
... ('combined_parcel', bm_full[[1, 8, 10, 120, 127]) # contains selected voxels/vertices
100+
... ('combined_parcel', bm_full[[1, 8, 10]]), # contains selected voxels/vertices
96101
... ])
97102
98103
Time series are represented by their starting time (typically 0), step size
@@ -103,13 +108,15 @@
103108
So a header for fMRI data with a TR of 100 ms covering the left cortex and thalamus with
104109
5000 timepoints could be created with
105110
106-
>>> cifti2.Cifti2Header.from_axes((series, bm_cortex + bm_thal))
111+
>>> type(cifti2.Cifti2Header.from_axes((series, bm_cortex + bm_thal)))
112+
<class 'nibabel.cifti2.cifti2.Cifti2Header'>
107113
108114
Similarly the curvature and cortical thickness on the left cortex could be stored using a header
109115
like:
110116
111-
>>> cifti2.Cifti2Header.from_axes((cifti.ScalarAxis(['curvature', 'thickness'],
112-
... bm_cortex))
117+
>>> type(cifti2.Cifti2Header.from_axes((cifti2.ScalarAxis(['curvature', 'thickness']),
118+
... bm_cortex)))
119+
<class 'nibabel.cifti2.cifti2.Cifti2Header'>
113120
"""
114121
import numpy as np
115122
from . import cifti2

0 commit comments

Comments
 (0)