mcot.cifti.cifti

Functions

axis_from_hdf5(group)

Stores the information from an axis in HDF5 group.

axis_to_hdf5(group, axis)

Stores the information from an axis in HDF5 group.

combine(brain_models)

Find the common space of multiple BrainModel axes.

empty_hdf5(group, axes[, dtype, compression])

Creates a new HDF5 group with an empty dataset.

empty_zarr(group, axes[, dtype, compressor])

Creates a new zarr group with an empty dataset.

from_hdf5(group)

Reads a CIFTI array from the HDF5 format.

guess_extension(axes)

Guesses the extension based on the CIFTI axes.

to_hdf5(group, arr, axes[, compression])

Store the CIFTI array in an HDF5 format.

write(filename, arr, axes)

Writes a CIFTI file guessing the extension of the filename.

axis_from_hdf5

mcot.cifti.cifti.axis_from_hdf5(group: Union[h5py._hl.group.Group, zarr.hierarchy.Group])[source]

Stores the information from an axis in HDF5 group.

axis_to_hdf5

mcot.cifti.cifti.axis_to_hdf5(group: Union[h5py._hl.group.Group, zarr.hierarchy.Group], axis: nibabel.cifti2.cifti2_axes.Axis)[source]

Stores the information from an axis in HDF5 group.

combine

mcot.cifti.cifti.combine(brain_models: Sequence[nibabel.cifti2.cifti2_axes.BrainModelAxis])[source]

Find the common space of multiple BrainModel axes.

Parameters

brain_models – sequence of brain model axes

Returns

tuple of common brain model and sequence of indices with the common space

empty_hdf5

mcot.cifti.cifti.empty_hdf5(group: Union[h5py._hl.group.Group, zarr.hierarchy.Group], axes: Sequence[nibabel.cifti2.cifti2_axes.Axis], dtype=<class 'float'>, compression='gzip')[source]

Creates a new HDF5 group with an empty dataset.

Parameters
  • group – HDF5 group

  • axes – sequence of axes (all have to be defined)

  • dtype – data type

  • compression – which compression to use on each chunk

Returns

new array to be filled

empty_zarr

mcot.cifti.cifti.empty_zarr(group: Union[h5py._hl.group.Group, zarr.hierarchy.Group], axes: Sequence[nibabel.cifti2.cifti2_axes.Axis], dtype=<class 'float'>, compressor='default')[source]

Creates a new zarr group with an empty dataset.

Parameters
  • group – zarr group

  • axes – sequence of axes (all have to be defined)

  • dtype – data type

  • compressor – which compressor to use on each chunk

Returns

new array to be filled

from_hdf5

mcot.cifti.cifti.from_hdf5(group: Union[h5py._hl.group.Group, zarr.hierarchy.Group]) → Tuple[h5py._hl.dataset.Dataset, Sequence[nibabel.cifti2.cifti2_axes.Axis]][source]

Reads a CIFTI array from the HDF5 format.

Parameters

group – HDF5 group the data was stored in

Returns

tuple with data array (still on disk) and sequence of axes

guess_extension

mcot.cifti.cifti.guess_extension(axes: Tuple[nibabel.cifti2.cifti2_axes.Axis]) → Sequence[str][source]

Guesses the extension based on the CIFTI axes.

Parameters

axes – CIFTI axes describing the rows/columns of a CIFTI file

Returns

tuple of possible file extensions

to_hdf5

mcot.cifti.cifti.to_hdf5(group: Union[h5py._hl.group.Group, zarr.hierarchy.Group], arr, axes: Sequence[nibabel.cifti2.cifti2_axes.Axis], compression='gzip')[source]

Store the CIFTI array in an HDF5 format.

Parameters
  • group – HDF5 group to store the data in (can be top-level HDF5 file)

  • arr – data array

  • axes – sequence of axes (optionally None)

  • compression – which compression to use on the main data array (None, ‘gzip’, or ‘lzf’)

write

mcot.cifti.cifti.write(filename: str, arr: numpy.ndarray, axes: Tuple[nibabel.cifti2.cifti2_axes.Axis])[source]

Writes a CIFTI file guessing the extension of the filename.

Parameters
  • filename – full filename of basename

  • arr – array to be stored

  • axes – CIFTI axes describing the rows/columns of a CIFTI file