CIFTI-2 format IO
cifti2 | |
cifti2_axes |
Read / write access to CIFTI-2 image format
Format of the NIFTI2 container format described here:
Definition of the CIFTI-2 header format and file extensions can be found at:
Cifti2BrainModel([index_offset, ...]) | Element representing a mapping of the dimension to vertex or voxels. |
Cifti2Header([matrix, version]) | Class for CIFTI-2 header extension |
Cifti2HeaderError | Error in CIFTI-2 header |
Cifti2Image([dataobj, header, nifti_header, ...]) | Class for single file CIFTI-2 format image |
Cifti2Label([key, label, red, green, blue, ...]) | CIFTI-2 label: association of integer key with a name and RGBA values |
Cifti2LabelTable() | CIFTI-2 label table: a sequence of ``Cifti2Label``s |
Cifti2Matrix() | CIFTI-2 Matrix object |
Cifti2MatrixIndicesMap(...[, ...]) | Class for Matrix Indices Map |
Cifti2MetaData([metadata]) | A list of name-value pairs |
Cifti2NamedMap([map_name, metadata, label_table]) | CIFTI-2 named map: association of name and optional data with a map index |
Cifti2Parcel([name, voxel_indices_ijk, vertices]) | CIFTI-2 parcel: association of a name with vertices and/or voxels |
Cifti2Surface([brain_structure, ...]) | Cifti surface: association of brain structure and number of vertices |
Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ([...]) | Matrix that translates voxel indices to spatial coordinates |
Cifti2VertexIndices([indices]) | CIFTI-2 vertex indices: vertex indices for an associated brain model |
Cifti2Vertices([brain_structure, vertices]) | CIFTI-2 vertices - association of brain structure and a list of vertices |
Cifti2Volume([volume_dimensions, ...]) | CIFTI-2 volume: information about a volume for mappings that use voxels |
Cifti2VoxelIndicesIJK([indices]) | CIFTI-2 VoxelIndicesIJK: Set of voxel indices contained in a structure |
load(filename) | Load cifti2 from filename |
save(img, filename) | Save cifti to filename |
Defines Axis objects to create, read, and manipulate CIFTI-2 files
These axes provide an alternative interface to the information in the CIFTI-2 header. Each type of CIFTI-2 axes describing the rows/columns in a CIFTI-2 matrix is given a unique class:
All of these classes are derived from the Axis class.
After loading a CIFTI-2 file a tuple of axes describing the rows and columns can be obtained from the cifti2.Cifti2Header.get_axis() method on the header object (e.g. nibabel.load(<filename>).header.get_axis()). Inversely, a new cifti2.Cifti2Header object can be created from existing Axis objects using the cifti2.Cifti2Header.from_axes() factory method.
CIFTI-2 Axis objects of the same type can be concatenated using the ‘+’-operator. Numpy indexing also works on axes (except for SeriesAxis objects, which have to remain monotonically increasing or decreasing).
New Axis objects can be constructed by providing a description for what is contained in each row/column of the described tensor. For each Axis sub-class this descriptor is:
Several helper functions exist to create new BrainModelAxis axes:
A ParcelsAxis axis can be created from a sequence of BrainModelAxis axes using ParcelsAxis.from_brain_models().
We can create brain models covering the left cortex and left thalamus using:
>>> from nibabel import cifti2
>>> import numpy as np
>>> bm_cortex = cifti2.BrainModelAxis.from_mask([True, False, True, True],
... name='cortex_left')
>>> bm_thal = cifti2.BrainModelAxis.from_mask(np.ones((2, 2, 2)), affine=np.eye(4),
... name='thalamus_left')
In this very simple case bm_cortex describes a left cortical surface skipping the second out of four vertices. bm_thal contains all voxels in a 2x2x2 volume.
Brain structure names automatically get converted to valid CIFTI-2 indentifiers using BrainModelAxis.to_cifti_brain_structure_name(). A 1-dimensional mask will be automatically interpreted as a surface element and a 3-dimensional mask as a volume element.
These can be concatenated in a single brain model covering the left cortex and thalamus by simply adding them together
>>> bm_full = bm_cortex + bm_thal
Brain models covering the full HCP grayordinate space can be constructed by adding all the volumetric and surface brain models together like this (or by reading one from an already existing HCP file).
Getting a specific brain region from the full brain model is as simple as:
>>> assert bm_full[bm_full.name == 'CIFTI_STRUCTURE_CORTEX_LEFT'] == bm_cortex
>>> assert bm_full[bm_full.name == 'CIFTI_STRUCTURE_THALAMUS_LEFT'] == bm_thal
You can also iterate over all brain structures in a brain model:
>>> for idx, (name, slc, bm) in enumerate(bm_full.iter_structures()):
... print((str(name), slc))
... assert bm == bm_full[slc]
... assert bm == bm_cortex if idx == 0 else bm_thal
('CIFTI_STRUCTURE_CORTEX_LEFT', slice(0, 3, None))
('CIFTI_STRUCTURE_THALAMUS_LEFT', slice(3, None, None))
In this case there will be two iterations, namely: (‘CIFTI_STRUCTURE_CORTEX_LEFT’, slice(0, <size of cortex mask>), bm_cortex) and (‘CIFTI_STRUCTURE_THALAMUS_LEFT’, slice(<size of cortex mask>, None), bm_thal)
ParcelsAxis can be constructed from selections of these brain models:
>>> parcel = cifti2.ParcelsAxis.from_brain_models([
... ('surface_parcel', bm_cortex[:2]), # contains first 2 cortical vertices
... ('volume_parcel', bm_thal), # contains thalamus
... ('combined_parcel', bm_full[[1, 8, 10]]), # contains selected voxels/vertices
... ])
Time series are represented by their starting time (typically 0), step size (i.e. sampling time or TR), and number of elements:
>>> series = cifti2.SeriesAxis(start=0, step=100, size=5000)
So a header for fMRI data with a TR of 100 ms covering the left cortex and thalamus with 5000 timepoints could be created with
>>> type(cifti2.Cifti2Header.from_axes((series, bm_cortex + bm_thal)))
<class 'nibabel.cifti2.cifti2.Cifti2Header'>
Similarly the curvature and cortical thickness on the left cortex could be stored using a header like:
>>> type(cifti2.Cifti2Header.from_axes((cifti2.ScalarAxis(['curvature', 'thickness']),
... bm_cortex)))
<class 'nibabel.cifti2.cifti2.Cifti2Header'>
Axis | Abstract class for any object describing the rows or columns of a CIFTI-2 vector/matrix |
BrainModelAxis(name[, voxel, vertex, ...]) | Each row/column in the CIFTI-2 vector/matrix represents a single vertex or voxel |
LabelAxis(name, label[, meta]) | Defines CIFTI-2 axis for label array. |
ParcelsAxis(name, voxels, vertices[, ...]) | Each row/column in the CIFTI-2 vector/matrix represents a parcel of voxels/vertices |
ScalarAxis(name[, meta]) | Along this axis of the CIFTI-2 vector/matrix each row/column has been given |
SeriesAxis(start, step, size[, unit]) | Along this axis of the CIFTI-2 vector/matrix the rows/columns increase monotonously in time |
from_index_mapping(mim) | Parses the MatrixIndicesMap to find the appropriate CIFTI-2 axis describing the rows or columns |
to_header(axes) | Converts the axes describing the rows/columns of a CIFTI-2 vector/matrix to a Cifti2Header |
Cifti2Extension([code, content]) | |
Cifti2Parser([encoding, buffer_size, verbose]) | Class to parse an XML string into a CIFTI-2 header object |
Bases: nibabel.xmlutils.XmlSerializable
Element representing a mapping of the dimension to vertex or voxels.
Mapping to vertices of voxels must be specified.
Description - Maps a range of indices to surface vertices or voxels when IndicesMapToDataType is “CIFTI_INDEX_TYPE_BRAIN_MODELS.”
Attributes
- IndexOffset - The matrix index of the first brainordinate of this BrainModel. Note that matrix indices are zero-based.
- IndexCount - Number of surface vertices or voxels in this brain model, must be positive.
- ModelType - Type of model representing the brain structure (surface or voxels). Valid values are listed in the table below.
- BrainStructure - Identifies the brain structure. Valid values for BrainStructure are listed in the table below. However, if the needed structure is not listed in the table, a message should be posted to the CIFTI Forum so that a standardized name can be created for the structure and added to the table.
- SurfaceNumberOfVertices - When ModelType is CIFTI_MODEL_TYPE_SURFACE this attribute contains the actual (or true) number of vertices in the surface that is associated with this BrainModel. When this BrainModel represents all vertices in the surface, this value is the same as IndexCount. When this BrainModel represents only a subset of the surface’s vertices, IndexCount will be less than this value.
Child Elements
- VertexIndices (0...1)
- VoxelIndicesIJK (0...1)
Text Content: [NA]
Parent Element - MatrixIndicesMap
For ModelType values, see CIFTI_MODEL_TYPES module attribute.
For BrainStructure values, see CIFTI_BRAIN_STRUCTURES model attribute.
Attributes
voxel_indices_ijk | |
vertex_indices |
index_offset | int | Start of the mapping |
index_count | int | Number of elements in the array to be mapped |
model_type | str | One of CIFTI_MODEL_TYPES |
brain_structure | str | One of CIFTI_BRAIN_STRUCTURES |
surface_number_of_vertices | int | Number of vertices in the surface. Use only for surface-type structure |
Bases: nibabel.filebasedimages.FileBasedHeader, nibabel.xmlutils.XmlSerializable
Class for CIFTI-2 header extension
Creates a new Cifti2 header based on the Cifti2 axes
Parameters: | axes : tuple of :class`.cifti2_axes.Axis`
|
---|---|
Returns: | header : Cifti2Header
|
Generates the Cifti2 axis for a given dimension
Parameters: | index : int
|
---|---|
Returns: | axis : cifti2_axes.Axis |
Cifti2 Mapping class for a given index
Parameters: | index : int
|
---|---|
Returns: | cifti2_map : Cifti2MatrixIndicesMap
|
List of matrix indices that are mapped
Number of mapped indices
Bases: nibabel.dataobj_images.DataobjImage
Class for single file CIFTI-2 format image
Initialize image
The image is a combination of (dataobj, header), with optional metadata in nifti_header (a NIfTI2 header). There may be more metadata in the mapping extra. Filename / file-like objects can also go in the file_map mapping.
Parameters: | dataobj : object
header : Cifti2Header instance or sequence of cifti2_axes.Axis
nifti_header : None or mapping or NIfTI2 header instance, optional
extra : None or mapping
file_map : mapping, optional
|
---|
Initialize image
The image is a combination of (dataobj, header), with optional metadata in nifti_header (a NIfTI2 header). There may be more metadata in the mapping extra. Filename / file-like objects can also go in the file_map mapping.
Parameters: | dataobj : object
header : Cifti2Header instance or sequence of cifti2_axes.Axis
nifti_header : None or mapping or NIfTI2 header instance, optional
extra : None or mapping
file_map : mapping, optional
|
---|
Load a CIFTI-2 image from a file_map
Parameters: | file_map : file_map |
---|---|
Returns: | img : Cifti2Image
|
Class method to create new instance of own class from img
Parameters: | img : instance
|
---|---|
Returns: | cimg : instance
|
alias of Cifti2Header
Write image to file_map or contained self.file_map
Parameters: | file_map : None or mapping, optional
|
---|---|
Returns: | None : |
Harmonize CIFTI-2 and NIfTI headers with image data
>>> import numpy as np
>>> data = np.zeros((2,3,4))
>>> img = Cifti2Image(data)
>>> img.shape == (2, 3, 4)
True
>>> img.update_headers()
>>> img.nifti_header.get_data_shape() == (2, 3, 4)
True
Bases: nibabel.xmlutils.XmlSerializable
CIFTI-2 label: association of integer key with a name and RGBA values
For all color components, value is floating point with range 0.0 to 1.0.
Description - Associates a label key value with a name and a display color.
Attributes
- Key - Integer, data value which is assigned this name and color.
- Red - Red color component for label. Value is floating point with range 0.0 to 1.0.
- Green - Green color component for label. Value is floating point with range 0.0 to 1.0.
- Blue - Blue color component for label. Value is floating point with range 0.0 to 1.0.
- Alpha - Alpha color component for label. Value is floating point with range 0.0 to 1.0.
Child Elements: [NA]
Text Content - Name of the label.
Parent Element - LabelTable
Attributes
key | int, optional | Integer, data value which is assigned this name and color. |
label | str, optional | Name of the label. |
red | float, optional | Red color component for label (between 0 and 1). |
green | float, optional | Green color component for label (between 0 and 1). |
blue | float, optional | Blue color component for label (between 0 and 1). |
alpha | float, optional | Alpha color component for label (between 0 and 1). |
Returns RGBA as tuple
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableMapping
CIFTI-2 label table: a sequence of ``Cifti2Label``s
Description - Used by NamedMap when IndicesMapToDataType is “CIFTI_INDEX_TYPE_LABELS” in order to associate names and display colors with label keys. Note that LABELS is the only mapping type that uses a LabelTable. Display coloring of continuous-valued data is not specified by CIFTI-2.
Attributes: [NA]
Child Elements
- Label (0...N)
Text Content: [NA]
Parent Element - NamedMap
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableSequence
CIFTI-2 Matrix object
This is a list-like container where the elements are instances of Cifti2MatrixIndicesMap.
Description: contains child elements that describe the meaning of the values in the matrix.
Attributes: [NA]
Child Elements
- MetaData (0 .. 1)
- MatrixIndicesMap (1 .. N)
Text Content: [NA]
Parent Element: CIFTI
For each matrix (data) dimension, exactly one MatrixIndicesMap element must list it in the AppliesToMatrixDimension attribute.
Cifti2 Mapping class for a given index
Parameters: | index : int
|
---|---|
Returns: | cifti2_map : Cifti2MatrixIndicesMap
|
List of matrix indices that are mapped
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableSequence
Class for Matrix Indices Map
Description - Provides a mapping between matrix indices and their interpretation.
Attributes
- AppliesToMatrixDimension - Lists the dimension(s) of the matrix to which this MatrixIndicesMap applies. The dimensions of the matrix start at zero (dimension 0 describes the indices along the first dimension, dimension 1 describes the indices along the second dimension, etc.). If this MatrixIndicesMap applies to more than one matrix dimension, the values are separated by a comma.
- IndicesMapToDataType - Type of data to which the MatrixIndicesMap applies.
- NumberOfSeriesPoints - Indicates how many samples there are in a series mapping type. For example, this could be the number of timepoints in a timeseries.
- SeriesExponent - Integer, SeriesStart and SeriesStep must be multiplied by 10 raised to the power of the value of this attribute to give the actual values assigned to indices (e.g., if SeriesStart is “5” and SeriesExponent is “-3”, the value of the first series point is 0.005).
- SeriesStart - Indicates what quantity should be assigned to the first series point.
- SeriesStep - Indicates amount of change between each series point.
- SeriesUnit - Indicates the unit of the result of multiplying SeriesStart and SeriesStep by 10 to the power of SeriesExponent.
Child Elements
- BrainModel (0...N)
- NamedMap (0...N)
- Parcel (0...N)
- Surface (0...N)
- Volume (0...1)
Text Content: [NA]
Parent Element - Matrix
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableMapping
A list of name-value pairs
Description - Provides a simple method for user-supplied metadata that associates names with values.
Attributes: [NA]
Child Elements
- MD (0...N)
Text Content: [NA]
Parent Elements - Matrix, NamedMap
MD elements are a single metadata entry consisting of a name and a value.
Attributes
data | list of (name, value) tuples |
Remove metadata key-value pairs
Parameters: | metadata : dict-like datatype |
---|---|
Returns: | None : |
Bases: nibabel.xmlutils.XmlSerializable
CIFTI-2 named map: association of name and optional data with a map index
Associates a name, optional metadata, and possibly a LabelTable with an index in a map.
Description - Associates a name, optional metadata, and possibly a LabelTable with an index in a map.
Attributes: [NA]
Child Elements
- MapName (1)
- LabelTable (0...1)
- MetaData (0...1)
Text Content: [NA]
Parent Element - MatrixIndicesMap
Attributes
metadata | |
label_table |
map_name | str | Name of map |
Bases: nibabel.xmlutils.XmlSerializable
CIFTI-2 parcel: association of a name with vertices and/or voxels
Description - Associates a name, plus vertices and/or voxels, with an index.
Attributes
- Name - The name of the parcel
Child Elements
- Vertices (0...N)
- VoxelIndicesIJK (0...1)
Text Content: [NA]
Parent Element - MatrixIndicesMap
Attributes
voxel_indices_ijk |
name | str | Name of parcel |
vertices | list of Cifti2Vertices | Vertices associated with parcel |
Appends a Cifti2Vertices element to the Cifti2Parcel
Parameters: | vertices : Cifti2Vertices |
---|
Pops the ith vertices element from the Cifti2Parcel
Bases: nibabel.xmlutils.XmlSerializable
Cifti surface: association of brain structure and number of vertices
Description - Specifies the number of vertices for a surface, when IndicesMapToDataType is “CIFTI_INDEX_TYPE_PARCELS.” This is separate from the Parcel element because there can be multiple parcels on one surface, and one parcel may involve multiple surfaces.
Attributes
- BrainStructure - A string from the BrainStructure list to identify what surface structure this element refers to (usually left cortex, right cortex, or cerebellum).
- SurfaceNumberOfVertices - The number of vertices that this structure’s surface contains.
Child Elements: [NA]
Text Content: [NA]
Parent Element - MatrixIndicesMap
Attributes
brain_structure | str | Name of brain structure |
surface_number_of_vertices | int | Number of vertices on surface |
Bases: nibabel.xmlutils.XmlSerializable
Matrix that translates voxel indices to spatial coordinates
Description - Contains a matrix that translates Voxel IJK Indices to spatial XYZ coordinates (+X=>right, +Y=>anterior, +Z=> superior). The resulting coordinate is the center of the voxel.
Attributes
- MeterExponent - Integer, specifies that the coordinate result from the transformation matrix should be multiplied by 10 to this power to get the spatial coordinates in meters (e.g., if this is “-3”, then the transformation matrix is in millimeters).
Child Elements: [NA]
Text Content - Sixteen floating-point values, in row-major order, that form a 4x4 homogeneous transformation matrix.
Parent Element - Volume
Attributes
meter_exponent | int | See attribute description above. |
matrix | array-like shape (4, 4) | Affine transformation matrix from voxel indices to RAS space. |
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableSequence
CIFTI-2 vertex indices: vertex indices for an associated brain model
The vertex indices (which are independent for each surface, and zero-based) that are used in this brain model[.] The parent BrainModel’s index_count indicates the number of indices.
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableSequence
CIFTI-2 vertices - association of brain structure and a list of vertices
Description - Contains a BrainStructure type and a list of vertex indices within a Parcel.
Attributes
- BrainStructure - A string from the BrainStructure list to identify what surface this vertex list is from (usually left cortex, right cortex, or cerebellum).
Child Elements: [NA]
Text Content - Vertex indices (which are independent for each surface, and zero-based) separated by whitespace characters.
Parent Element - Parcel
The class behaves like a list of Vertex indices (which are independent for each surface, and zero-based)
Attributes
brain_structure | str | A string from the BrainStructure list to identify what surface this vertex list is from (usually left cortex, right cortex, or cerebellum). |
Bases: nibabel.xmlutils.XmlSerializable
CIFTI-2 volume: information about a volume for mappings that use voxels
Description - Provides information about the volume for any mappings that use voxels.
Attributes
- VolumeDimensions - Three integer values separated by commas, the lengths of the three volume file dimensions that are related to spatial coordinates, in number of voxels. Voxel indices (which are zero-based) that are used in the mapping that this element applies to must be within these dimensions.
Child Elements
- TransformationMatrixVoxelIndicesIJKtoXYZ (1)
Text Content: [NA]
Parent Element - MatrixIndicesMap
Attributes
volume_dimensions | array-like shape (3,) | See attribute description above. |
transformation_matrix_voxel_indices_ijk_to_xyz | Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ | Matrix that translates voxel indices to spatial coordinates |
Bases: nibabel.xmlutils.XmlSerializable, _abcoll.MutableSequence
CIFTI-2 VoxelIndicesIJK: Set of voxel indices contained in a structure
Each element of this sequence is a triple of integers.
Load cifti2 from filename
Parameters: | filename : str
|
---|---|
Returns: | img : Cifti2Image
|
Raises: | ImageFileError: if `filename` doesn’t look like cifti : IOError : if filename does not exist |
Save cifti to filename
Parameters: | filename : str
|
---|
Bases: object
Abstract class for any object describing the rows or columns of a CIFTI-2 vector/matrix
Mainly used for type checking.
Base class for the following concrete CIFTI-2 axes:
x.__init__(...) initializes x; see help(type(x)) for signature
Bases: nibabel.cifti2.cifti2_axes.Axis
Each row/column in the CIFTI-2 vector/matrix represents a single vertex or voxel
This Axis describes which vertex/voxel is represented by each row/column.
New BrainModelAxis axes can be constructed by passing on the greyordinate brain-structure names and voxel/vertex indices to the constructor or by one of the factory methods:
from respectively 1D or 3D masks - from_surface(): creates a surface BrainModelAxis axis
The resulting BrainModelAxis axes can be concatenated by adding them together.
Parameters: | name : array_like
voxel : array_like, optional
vertex : array_like, optional
affine : array_like, optional
volume_shape : tuple of three integers, optional
nvertices : dict from string to integer, optional
|
---|
New BrainModelAxis axes can be constructed by passing on the greyordinate brain-structure names and voxel/vertex indices to the constructor or by one of the factory methods:
from respectively 1D or 3D masks - from_surface(): creates a surface BrainModelAxis axis
The resulting BrainModelAxis axes can be concatenated by adding them together.
Parameters: | name : array_like
voxel : array_like, optional
vertex : array_like, optional
affine : array_like, optional
volume_shape : tuple of three integers, optional
nvertices : dict from string to integer, optional
|
---|
Affine of the volumetric image in which the greyordinate voxels were defined
Creates a new BrainModel axis based on a CIFTI-2 dataset
Parameters: | mim : cifti2.Cifti2MatrixIndicesMap |
---|---|
Returns: | BrainModelAxis : |
Creates a new BrainModelAxis axis describing the provided mask
Parameters: | mask : array_like
name : str, optional
affine : array_like, optional
|
---|---|
Returns: | BrainModelAxis which covers the provided mask : |
Creates a new BrainModelAxis axis describing the vertices on a surface
Parameters: | vertices : array_like
nvertex : int
name : str
|
---|---|
Returns: | BrainModelAxis which covers (part of) the surface : |
Describes a single element from the axis
Parameters: | index : int
|
---|---|
Returns: | tuple with 3 elements : - str, ‘CIFTI_MODEL_TYPE_SURFACE’ for vertex or ‘CIFTI_MODEL_TYPE_VOXELS’ for voxel : - vertex index if it is a surface element, otherwise array with 3 voxel indices : - structure.BrainStructure object describing the brain structure the element was taken from : |
Iterates over all brain structures in the order that they appear along the axis
The brain structure to which the voxel/vertices of belong
(N, ) boolean array which is true for any element on the surface
Attempts to convert the name of an anatomical region in a format recognized by CIFTI-2
This function returns:
see nibabel.cifti2.tests.test_name() for examples of which conversions are possible
Parameters: | name: iterable of 2-element tuples of integer and string :
|
---|---|
Returns: | CIFTI-2 compatible name : |
Raises: | ValueError: raised if the input name does not match a known anatomical structure in CIFTI-2 : |
Converts the brain model axis to a MatrixIndicesMap for storage in CIFTI-2 format
Parameters: | dim : int
|
---|---|
Returns: | :class:`.cifti2.Cifti2MatrixIndicesMap` : |
(N, ) boolean array which is true for any element on the surface
Shape of the volumetric image in which the greyordinate voxels were defined
Bases: nibabel.cifti2.cifti2_axes.Axis
Defines CIFTI-2 axis for label array.
Along this axis of the CIFTI-2 vector/matrix each row/column has been given a unique name, label table, and optionally metadata
Parameters: | name : array_like
label : array_like
meta : array_like, optional
|
---|
Parameters: | name : array_like
label : array_like
meta : array_like, optional
|
---|
Creates a new Label axis based on a CIFTI-2 dataset
Parameters: | mim : cifti2.Cifti2MatrixIndicesMap |
---|---|
Returns: | LabelAxis : |
Describes a single element from the axis
Parameters: | index : int
|
---|---|
Returns: | tuple with 2 elements : - unicode name of the row/column : - dictionary with the label table : - dictionary with the element metadata : |
Converts the hcp_labels to a MatrixIndicesMap for storage in CIFTI-2 format
Parameters: | dim : int
|
---|---|
Returns: | :class:`.cifti2.Cifti2MatrixIndicesMap` : |
Bases: nibabel.cifti2.cifti2_axes.Axis
Each row/column in the CIFTI-2 vector/matrix represents a parcel of voxels/vertices
This Axis describes which parcel is represented by each row/column.
Individual parcels can be accessed based on their name, using parcel = parcel_axis[name]
Use of this constructor is not recommended. New ParcelsAxis axes can be constructed more easily from a sequence of BrainModelAxis axes using from_brain_models()
Parameters: | name : array_like
voxels : array_like
vertices : array_like
affine : array_like, optional
volume_shape : tuple of three integers, optional
nvertices : dict from string to integer, optional
|
---|
Use of this constructor is not recommended. New ParcelsAxis axes can be constructed more easily from a sequence of BrainModelAxis axes using from_brain_models()
Parameters: | name : array_like
voxels : array_like
vertices : array_like
affine : array_like, optional
volume_shape : tuple of three integers, optional
nvertices : dict from string to integer, optional
|
---|
Affine of the volumetric image in which the greyordinate voxels were defined
Creates a Parcel axis from a list of BrainModelAxis axes with names
Parameters: | named_brain_models : iterable of 2-element tuples of string and BrainModelAxis
|
---|---|
Returns: | ParcelsAxis : |
Creates a new Parcels axis based on a CIFTI-2 dataset
Parameters: | mim : cifti2.Cifti2MatrixIndicesMap |
---|---|
Returns: | ParcelsAxis : |
Describes a single element from the axis
Parameters: | index : int
|
---|---|
Returns: | tuple with 3 elements : - unicode name of the parcel : - (M, 3) int array with voxel indices : - dict from string to (K, ) int array with vertex indices :
|
Converts the Parcel to a MatrixIndicesMap for storage in CIFTI-2 format
Parameters: | dim : int
|
---|---|
Returns: | :class:`cifti2.Cifti2MatrixIndicesMap` : |
Shape of the volumetric image in which the greyordinate voxels were defined
Bases: nibabel.cifti2.cifti2_axes.Axis
Along this axis of the CIFTI-2 vector/matrix each row/column has been given a unique name and optionally metadata
Parameters: | name : array_like
meta : array_like
|
---|
Parameters: | name : array_like
meta : array_like
|
---|
Creates a new Scalar axis based on a CIFTI-2 dataset
Parameters: | mim : cifti2.Cifti2MatrixIndicesMap |
---|---|
Returns: | ScalarAxis : |
Describes a single element from the axis
Parameters: | index : int
|
---|---|
Returns: | tuple with 2 elements : - unicode name of the row/column : - dictionary with the element metadata : |
Converts the hcp_labels to a MatrixIndicesMap for storage in CIFTI-2 format
Parameters: | dim : int
|
---|---|
Returns: | :class:`.cifti2.Cifti2MatrixIndicesMap` : |
Bases: nibabel.cifti2.cifti2_axes.Axis
Along this axis of the CIFTI-2 vector/matrix the rows/columns increase monotonously in time
This Axis describes the time point of each row/column.
Creates a new SeriesAxis axis
Parameters: | start : float
step : float
size : int
unit : str
|
---|
Creates a new SeriesAxis axis
Parameters: | start : float
step : float
size : int
unit : str
|
---|
Creates a new SeriesAxis axis based on a CIFTI-2 dataset
Parameters: | mim : cifti2.Cifti2MatrixIndicesMap |
---|---|
Returns: | SeriesAxis : |
Gives the time point of a specific row/column
Parameters: | index : int
|
---|---|
Returns: | float : |
Converts the SeriesAxis to a MatrixIndicesMap for storage in CIFTI-2 format
Parameters: | dim : int
|
---|---|
Returns: | :class:`cifti2.Cifti2MatrixIndicesMap` : |
Parses the MatrixIndicesMap to find the appropriate CIFTI-2 axis describing the rows or columns
Parameters: | mim : cifti2.Cifti2MatrixIndicesMap |
---|---|
Returns: | axis : subclass of Axis |
Converts the axes describing the rows/columns of a CIFTI-2 vector/matrix to a Cifti2Header
Parameters: | axes : iterable of Axis objects
|
---|---|
Returns: | header : cifti2.Cifti2Header |
Bases: nibabel.nifti1.Nifti1Extension
Bases: nibabel.xmlutils.XmlParser
Class to parse an XML string into a CIFTI-2 header object
Parameters: | encoding : str
buffer_size: None or int, optional :
verbose : int, optional
|
---|
Parameters: | encoding : str
buffer_size: None or int, optional :
verbose : int, optional
|
---|
Collect character data chunks pending collation
The parser breaks the data up into chunks of size depending on the buffer_size of the parser. A large bit of character data, with standard parser buffer_size (such as 8K) can easily span many calls to this function. We thus collect the chunks and process them when we hit start or end tags.
Collate and process collected character data
True if there is character data pending for processing