GreyOrdinates

from mcot.cifti.greyordinate import GreyOrdinates
class mcot.cifti.greyordinate.GreyOrdinates(data, brain_model_axis: nibabel.cifti2.cifti2_axes.BrainModelAxis, other_axes: Optional[Sequence[nibabel.cifti2.cifti2_axes.Axis]] = None, parent_file=None)[source]

Represents data on voxels or vertices.

__init__(data, brain_model_axis: nibabel.cifti2.cifti2_axes.BrainModelAxis, other_axes: Optional[Sequence[nibabel.cifti2.cifti2_axes.Axis]] = None, parent_file=None)[source]

Defines a new dataset in greyordinate space.

Parameters
  • data – (…, N) array for N greyordinates

  • brain_model_axis – CIFTI axis describing the greyordinate space

  • other_axes – sequence of CIFTI axes describing the other dimensions

  • parent_file – file in which the dataset has been stored

Inheritance diagram

Inheritance diagram of mcot.cifti.greyordinate.GreyOrdinates

Methods

as_dask([chunks, name])

Returns the greyordinates as a dask array.

empty(filename, axes[, dtype])

Creates an empty file to store the greyordinates with the type determined by the extension:

empty_cifti(filename, axes[, dtype])

Creates an empty greyordinate object based on the axes.

empty_hdf5(filename, axes[, dtype])

Creates an empty greyordinate object based on the axes.

empty_zarr(filename, axes[, dtype])

Creates an empty greyordinate object based on the axes.

from_cifti(filename[, writable])

Creates new greyordinate object from dense CIFTI file.

from_filename(filename[, mask_values, writable])

Reads greyordinate data from the given file.

from_gifti(filename[, mask_values])

Creates a new greyordinate object from a GIFTI file.

from_hdf5(group)

Retrieves data from HDF5 group.

from_nifti(filename[, mask_values])

Creates a new greyordinate object from a NIFTI file.

surface(anatomy[, fill, partial])

Gets a specific surface.

to_cifti([other_axes])

Create a CIFTI image from the data.

to_filename(filename)

Stores the greyordinate data to the given filename.

to_hdf5(group[, compression])

Stores the image in the HDF5 group.

transpose()

Transposes a dense connectome.

volume()

Get the volumetric data as a Nifti1Image.

as_dask

GreyOrdinates.as_dask(chunks='auto', name='greyordinates')[source]

Returns the greyordinates as a dask array.

Parameters
  • chunks – shape of the chunks (defaults to chunks of the dataset)

  • name – name of the dask array

Returns

dask array

empty

classmethod GreyOrdinates.empty(filename, axes, dtype=<class 'float'>)[source]

Creates an empty file to store the greyordinates with the type determined by the extension:

  • .nii: CIFTI file

  • .h5/hdf5/he2/he5: HDF5 file representing CIFTI data

  • .zarr: zarr file representing CIFTI data

Parameters
  • filename – target filename

  • axes – cifti2 axes

  • dtype – data type of array

Returns

Greyordinate object where CIFTI data can be stored

empty_cifti

classmethod GreyOrdinates.empty_cifti(filename, axes, dtype=<class 'float'>)[source]

Creates an empty greyordinate object based on the axes.

Data will be stored on disk in CIFTI format

Parameters
  • filename – filename to store the CIFTI file in

  • axes – cifti2 axes

  • dtype – data type of array

Returns

Greyordinate object where the data is stored in the new HDF5 file

empty_hdf5

classmethod GreyOrdinates.empty_hdf5(filename, axes, dtype=<class 'float'>)[source]

Creates an empty greyordinate object based on the axes.

Data will be stored on disk in an HDF5 file

Parameters
  • filename – filename to store the HDF5 file in or HDF5 group

  • axes – cifti2 axes

  • dtype – data type of array

Returns

Greyordinate object where the data is stored in the new HDF5 file

empty_zarr

classmethod GreyOrdinates.empty_zarr(filename, axes, dtype=<class 'float'>)[source]

Creates an empty greyordinate object based on the axes.

Data will be stored on disk in an HDF5 file

Parameters
  • filename – filename to store the HDF5 file in or HDF5 group

  • axes – cifti2 axes

  • dtype – data type of array

Returns

Greyordinate object where the data is stored in the new HDF5 file

from_cifti

classmethod GreyOrdinates.from_cifti(filename, writable=False)[source]

Creates new greyordinate object from dense CIFTI file.

Parameters
  • filename – CIFTI filename

  • writable – if True, opens data array in writable mode

from_filename

classmethod GreyOrdinates.from_filename(filename, mask_values=(0, nan), writable=False)[source]

Reads greyordinate data from the given file.

File can be:

  • NIFTI mask

  • GIFTI mask

  • CIFTI file

  • HDF5 file representing CIFTI data

  • zarr file representing CIFTI data

Parameters
  • filename – input filename

  • mask_values – which values are outside of the mask for NIFTI or GIFTI input

  • writable – allow to write to disk

Returns

greyordinates object

from_gifti

classmethod GreyOrdinates.from_gifti(filename, mask_values=(0, nan))[source]

Creates a new greyordinate object from a GIFTI file.

Parameters
  • filename – GIFTI filename

  • mask_values – values to mask out

Returns

greyordinate object representing the unmasked vertices

from_hdf5

classmethod GreyOrdinates.from_hdf5(group)[source]

Retrieves data from HDF5 group.

from_nifti

classmethod GreyOrdinates.from_nifti(filename, mask_values=(nan, 0))[source]

Creates a new greyordinate object from a NIFTI file.

Parameters
  • filename – NIFTI filename

  • mask_values – which values to mask out

Returns

greyordinate object representing the unmasked voxels

surface

GreyOrdinates.surface(anatomy, fill=nan, partial=False)[source]

Gets a specific surface.

Parameters
  • anatomy – BrainStructure or string like ‘CortexLeft’ or ‘CortexRight’

  • fill – which value to fill the array with if not all vertices are defined

  • partial – only return the part of the surface defined in the greyordinate file (ignores fill if set)

Returns

  • if not partial: (…, n_vertices) array

  • if partial: (N, ) int array with indices on the surface included in (…, N) array

to_cifti

GreyOrdinates.to_cifti(other_axes=None)[source]

Create a CIFTI image from the data.

Parameters

other_axes – defines the axes besides the greyordinate one

Returns

nibabel CIFTI image

to_filename

GreyOrdinates.to_filename(filename)[source]

Stores the greyordinate data to the given filename.

Type of storage is determined by the extension of the filename:

  • .dscalar/dconn/dlabel.nii: CIFTI file

  • .h5/hdf5/he2/he5: HDF5 file representing CIFTI data

  • .zarr: zarr file representing CIFTI data

  • .gii: GIFTI file (only stores surface data;

    raises error if more that one surface is represented in the greyordinates)

  • .nii: NIFTI file (only stores the volumetric data)

Parameters

filename – target filename

to_hdf5

GreyOrdinates.to_hdf5(group, compression='gzip')[source]

Stores the image in the HDF5 group.

transpose

GreyOrdinates.transpose()[source]

Transposes a dense connectome.

volume

GreyOrdinates.volume()[source]

Get the volumetric data as a Nifti1Image.