|
49 | 49 | We can create brain models covering the left cortex and left thalamus using: |
50 | 50 |
|
51 | 51 | >>> from nibabel import cifti2 |
52 | | ->>> bm_cortex = cifti2.BrainModel.from_mask(cortex_mask, brain_structure='cortex_left') |
| 52 | +>>> bm_cortex = cifti2.BrainModel.from_mask(cortex_mask, |
| 53 | +... brain_structure='cortex_left') # doctest: +SKIP |
53 | 54 | >>> bm_thal = cifti2.BrainModel.from_mask(thalamus_mask, affine=affine, |
54 | | - brain_structure='thalamus_left') |
| 55 | +... brain_structure='thalamus_left') # doctest: +SKIP |
55 | 56 |
|
56 | 57 | Brain structure names automatically get converted to valid CIfTI2 indentifiers using |
57 | 58 | :meth:`BrainModel.to_cifti_brain_structure_name`. |
|
61 | 62 | These can be concatenated in a single brain model covering the left cortex and thalamus by |
62 | 63 | simply adding them together |
63 | 64 |
|
64 | | ->>> bm_full = bm_cortex + bm_thal |
| 65 | +>>> bm_full = bm_cortex + bm_thal # doctest: +SKIP |
65 | 66 |
|
66 | 67 | Brain models covering the full HCP grayordinate space can be constructed by adding all the |
67 | 68 | volumetric and surface brain models together like this (or by reading one from an already |
68 | 69 | existing HCP file). |
69 | 70 |
|
70 | 71 | Getting a specific brain region from the full brain model is as simple as: |
71 | 72 |
|
72 | | ->>> assert bm_full[bm_full.name == 'CIFTI_STRUCTURE_CORTEX_LEFT'] == bm_cortex |
73 | | ->>> assert bm_full[bm_full.name == 'CIFTI_STRUCTURE_THALAMUS_LEFT'] == bm_thal |
| 73 | +>>> assert bm_full[bm_full.name == 'CIFTI_STRUCTURE_CORTEX_LEFT'] == bm_cortex # doctest: +SKIP |
| 74 | +>>> assert bm_full[bm_full.name == 'CIFTI_STRUCTURE_THALAMUS_LEFT'] == bm_thal # doctest: +SKIP |
74 | 75 |
|
75 | 76 | You can also iterate over all brain structures in a brain model: |
76 | 77 |
|
77 | | ->>> for name, slc, bm in bm_full.iter_structures(): ... |
| 78 | +>>> for name, slc, bm in bm_full.iter_structures(): ... # doctest: +SKIP |
78 | 79 |
|
79 | 80 | In this case there will be two iterations, namely: |
80 | 81 | ('CIFTI_STRUCTURE_CORTEX_LEFT', slice(0, <size of cortex mask>), bm_cortex) |
|
84 | 85 | Parcels can be constructed from selections of these brain models: |
85 | 86 |
|
86 | 87 | >>> parcel = cifti2.Parcels.from_brain_models([ |
87 | | - ('surface_parcel', bm_cortex[:100]), # contains first 100 cortical vertices |
88 | | - ('volume_parcel', bm_thal), # contains thalamus |
89 | | - ('combined_parcel', bm_full[[1, 8, 10, 50, 120, 127]) # contains selected voxels/vertices |
90 | | - ]) |
| 88 | +... ('surface_parcel', bm_cortex[:100]), # contains first 100 cortical vertices |
| 89 | +... ('volume_parcel', bm_thal), # contains thalamus |
| 90 | +... ('combined_parcel', bm_full[[1, 8, 10, 50, 120, 127]) # contains selected voxels/vertices |
| 91 | +... ]) # doctest: +SKIP |
91 | 92 |
|
92 | 93 | Time series are represented by their starting time (typically 0), step size |
93 | 94 | (i.e. sampling time or TR), and number of elements: |
94 | 95 |
|
95 | | ->>> series = cifti2.Series(start=0, step=100, size=5000) |
| 96 | +>>> series = cifti2.Series(start=0, step=100, size=5000) # doctest: +SKIP |
96 | 97 |
|
97 | 98 | So a header for fMRI data with a TR of 100 ms covering the left cortex and thalamus with |
98 | 99 | 5000 timepoints could be created with |
99 | 100 |
|
100 | | ->>> cifti2.Cifti2Header.from_axes((series, bm_cortex + bm_thal)) |
| 101 | +>>> cifti2.Cifti2Header.from_axes((series, bm_cortex + bm_thal)) # doctest: +SKIP |
101 | 102 |
|
102 | 103 | Similarly the curvature and cortical thickness on the left cortex could be stored using a header |
103 | 104 | like: |
104 | 105 |
|
105 | | ->>> cifti2.Cifti2Header.from_axes((cifti.Scalar(['curvature', 'thickness'], bm_cortex)) |
| 106 | +>>> cifti2.Cifti2Header.from_axes((cifti.Scalar(['curvature', 'thickness'], |
| 107 | +... bm_cortex)) # doctest: +SKIP |
106 | 108 | """ |
107 | 109 | import numpy as np |
108 | 110 | from . import cifti2 |
|
0 commit comments