siibra.volumes.providers.neuroglancer
Classes
A surface mesh provided as neuroglancer precomputed mesh. |
|
Helper class that provides a standard way to create an ABC using |
|
One scale of a NeuroglancerVolume. |
|
Only shadows NeuroglancerMesh for the special surface srctype, |
|
Functions
|
Helper method to get nifti standard affine. |
Module Contents
- class siibra.volumes.providers.neuroglancer.NeuroglancerMesh(resource: str | dict, volume=None)

A surface mesh provided as neuroglancer precomputed mesh.
- fetch(label: int, fragment: str)
Fetches a particular mesh. Each mesh is a dictionary with keys:
- Parameters:
label (int) – Label of the volume
fragment (str, default: None) –
A fragment name can be specified to choose from multiple fragments.
Note
If not specified, multiple fragments will be merged into one mesh. In such a case, the verts and faces arrays of different fragments are appended to one another.
- Returns:
‘verts’: An Nx3 array of vertex coordinates (in nanometer)
’faces’: an MX3 array containing connection data of vertices
’name’: Name of the of the mesh variant
- Return type:
- abstract get_boundingbox(clip=False, background=0.0, **fetch_kwargs) siibra.locations.boundingbox.BoundingBox
Bounding box calculation is not yet implemented for meshes.
- volume = None
- class siibra.volumes.providers.neuroglancer.NeuroglancerProvider(url: str | Dict[str, str])

Helper class that provides a standard way to create an ABC using inheritance.
- fetch(fragment: str = None, resolution_mm: float = -1, voi: siibra.locations.boundingbox.BoundingBox = None, max_bytes: float = SIIBRA_MAX_FETCH_SIZE_BYTES, **kwargs) nibabel.Nifti1Image
Fetch 3D image data from neuroglancer volume.
- Parameters:
fragment (str, optional) – The name of a fragment volume to fetch, if any. For example, some volumes are split into left and right hemisphere fragments. See
fragments()resolution_mm (float, default: -1 (i.e, the highest possible given max_bytes)) – Desired resolution in millimeters.
voi (BoundingBox) – optional specification of a volume of interest to fetch.
max_bytes (float: Default: NeuroglancerVolume.MAX_BYTES) – Maximum allowable size (in bytes) for downloading the image. siibra will attempt to find the highest resolution image with a size less than this value.
- get_boundingbox(**fetch_kwargs) siibra.locations.boundingbox.BoundingBox
Return the bounding box in physical coordinates of the union of fragments in this neuroglancer volume.
- Parameters:
fetch_kwargs – key word arguments that are used for fetching volumes, such as voi or resolution_mm.
- class siibra.volumes.providers.neuroglancer.NeuroglancerScale(volume: NeuroglancerVolume, scaleinfo: dict)
One scale of a NeuroglancerVolume.
- __lt__(other)
Sort scales by resolution.
- __repr__()
- __str__()
- fetch(voi: siibra.locations.boundingbox.BoundingBox = None, **kwargs)
- next()
Returns the next scale in this volume, of None if this is the last.
- prev()
Returns the previous scale in this volume, or None if this is the first.
- resolves(resolution_mm)
Test whether the resolution of this scale is sufficient to provide the given resolution.
- property affine
- chunk_sizes
- color_warning_issued = False
- encoding
- key
- property res_mm
- res_nm
- size
- volume
- voxel_offset
- class siibra.volumes.providers.neuroglancer.NeuroglancerSurfaceMesh(spec: str, **kwargs)

Only shadows NeuroglancerMesh for the special surface srctype, which provides a mesh urls plus a mesh index for identifying the surface. Behaves like NeuroglancerMesh otherwise.
TODO this class might be replaced by implementing a default label index for the parent class.
- fetch(**kwargs)
Fetches a particular mesh. Each mesh is a dictionary with keys:
- Parameters:
label (int) – Label of the volume
fragment (str, default: None) –
A fragment name can be specified to choose from multiple fragments.
Note
If not specified, multiple fragments will be merged into one mesh. In such a case, the verts and faces arrays of different fragments are appended to one another.
- Returns:
‘verts’: An Nx3 array of vertex coordinates (in nanometer)
’faces’: an MX3 array containing connection data of vertices
’name’: Name of the of the mesh variant
- Return type:
- property fragments
Returns the set of fragment names available for the mesh with the given index.
- label
- class siibra.volumes.providers.neuroglancer.NeuroglancerVolume(url: str)
- fetch(resolution_mm: float = -1, voi: siibra.locations.boundingbox.BoundingBox = None, max_bytes: float = MAX_BYTES, **kwargs)
- get_shape(resolution_mm=None, max_bytes: float = MAX_BYTES)
- is_float()
- MAX_BYTES
- USE_CACHE = False
- property affine
- property dtype
- property io: neuroglancer_scripts.precomputed_io.PrecomputedIO
- property map_type
- property scales
- property shape
- property transform_nm: numpy.ndarray
This is the transformation matrix created to cater neuroglancer viewer for a neuroglancer precomputed images.
- url
- siibra.volumes.providers.neuroglancer.shift_ng_transfrom(transform_nm: numpy.ndarray, scale_resolution_nm: numpy.ndarray, max_resolution_nm: numpy.ndarray) numpy.ndarray
Helper method to get nifti standard affine.
transfrorm.json stored with neuroglancer precomputed images and meshes are meant to be used for neuroglancer viewers and hence they are not representative of the affine in other tools. This method shifts back half a voxel in each axis. (see https://neuroglancer-scripts.readthedocs.io/en/latest/neuroglancer-info.html#different-conventions-for-coordinate-transformations)
- Parameters:
transform_nm (np.ndarray) – Transform array created for displaying an image correctly from neuroglancer precomputed format in neuroglancer viewer.
max_resolution_nm (np.ndarray) – The voxel resolution of the highest level of resolution.
- Returns:
Standard affine in nm
- Return type:
np.ndarray