siibra.volumes.sparsemap

Represents lists of probabilistic brain region maps.

Module Contents

Classes

SparseIndex

SparseMap

A sparse representation of list of statistical (e.g. probabilistic) brain

class siibra.volumes.sparsemap.SparseIndex
property num_volumes
add_img(imgdata: numpy.ndarray, affine: numpy.ndarray)
coords(volume: int)
mapped_voxels(volume: int)
max()
class siibra.volumes.sparsemap.SparseMap(identifier: str, name: str, space_spec: dict, parcellation_spec: dict, indices: Dict[str, siibra.commons.MapIndex], volumes: list = [], shortname: str = '', description: str = '', modality: str = None, publications: list = [], datasets: list = [])
Inheritance diagram of siibra.volumes.sparsemap.SparseMap

A sparse representation of list of statistical (e.g. probabilistic) brain region maps.

It represents the 3D statistical maps of N brain regions by two data structures:

  1. ‘spatial_index’, a 3D volume where non-negative values represent unique indices into a list of region assignments

  2. ‘probs’, a list of region assignments where each entry is a dict

More precisely, given i = sparse_index.voxels[x, y, z] we define that

  • if i<0, no brain region is assigned at this location

  • if i>=0, probs[i] defines the probabilities of brain regions.

Each entry in probs is a dictionary that represents the region assignments for the unique voxel where spatial_index == i. The assignment maps from a MapIndex to the actual (probability) value.

property affine
property shape
property sparse_index
fetch(region_or_index: siibra.commons.MapIndex | str | siibra.core.region.Region = None, *, index: siibra.commons.MapIndex = None, region: str | siibra.core.region.Region = None, **kwargs)

Recreate a particular volumetric map from the sparse representation.

Parameters:
  • region_or_index (str, Region, MapIndex) – Lazy match the specification.

  • index (MapIndex) – The index to be fetched.

  • region (str, Region) – Region name specification. If given, will be used to decode the map index of a particular region.

Return type:

An image or mesh

load_zipped_sparseindex(zipfname: str)

Load SparseIndex from previously computed source and creates a local cache.

Parameters:

zipfile (str) – A url or a path to zip file containing the SparseIndex files for this SparseMap precomputed by siibra.

Return type:

SparseIndex

save_sparseindex(destination: str, filename: str = None)

Save SparseIndex as a .zip in destination folder from local cache. If SparseIndex is not cached, siibra will firt create it first.

Parameters:
  • destination (str) – The path where the zip file will be created.

  • filename (str, default=None) – Name of the zip and prefix of the SparseIndex files. If None, siibra uses name property.