datasources
ngtools.datasources
Wrappers around neuroglancer classes that can compute metadata and optional attributes that neuroglancer typically delegates to the frontend.
Dependencies
- nifti:// -> nibabel
- zarr:// -> zarr
- precomputed:// -> cloudvolume
LayerDataSources
DataSourceInfo
Base class for source-specific metadata.
LayerDataSource
Bases: Wraps(LayerDataSource)
A wrapper around ng.LayerDataSource that computes metadata.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
VolumeInfo
Bases: DataSourceInfo
Base class for volume metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to the file |
required |
VolumeDataSource
Bases: LayerDataSource
Wrapper for volume source.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
SkeletonDataSource
Bases: LayerDataSource
Wrapper for skeleton source.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
MeshDataSource
Bases: LayerDataSource
Wrapper for mesh source.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
AnnotationDataSource
Bases: LayerDataSource
Wrapper for annotation source.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
LocalDataSource
Bases: LayerDataSource
Wrapper for local data sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
LocalAnnotationDataSource
Bases: AnnotationDataSource, LocalDataSource
Wrapper for local annotation sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
LocalSkeletonDataSource
Bases: SkeletonDataSource, LocalDataSource
Wrapper for data source that wraps a SkeletonSource.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
LocalVolumeDataSource
Bases: VolumeDataSource, LocalDataSource
Wrapper for data source that wraps a LocalVolume.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
NiftiVolumeInfo
Bases: VolumeInfo
Metadata of a NIfTI volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to the file |
required |
align_corner
|
bool
|
If True, use neuroglancer's native behavior when computing the transform, which is to assume that (0, 0, 0) points to the corner of the first voxel. If False, use NIfTI's spec, which is to assume the (0, 0, 0) points to the center of the first voxel. |
False
|
affine
|
(qform, sform, best, base)
|
Which orientation matrix to use. Neuroglancer uses the qform by default. |
"qform"
|
NiftiDataSource
Bases: VolumeDataSource
Wrapper for nifti sources.
Note that by default, neuroglancer assumes that the coordinate
(0, 0, 0) in voxel space corresponds to the corner of the first
voxel, whereas the nifti spec is that it corresponds to the center
of the first voxel. This wrapper follows the nifti convention by default.
The neuroglancer default behavior can be recovered with the option
align_corner=True.
Also, by default, neuroglancer uses the qform orientation matrix,
whereas the intent code must be used to choose between the sform
and qform according to the spec (as implemented in e.g. nibabel).
This wrapper follows the specification, unless the affine to use
is explicitly specified with the option affine="sform",
affine="qform", or affine="base".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_data
|
dict | NiftiDataSource | str
|
URL to the file |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
url |
str
|
URL to the file |
align_corner |
bool
|
If True, use neuroglancer's native behavior when computing the transform, which is to assume that (0, 0, 0) points to the corner of the first voxel. If False, use NIfTI's spec, which is to assume the (0, 0, 0) points to the center of the first voxel. |
affine |
(qform, sform, best, base)
|
Which orientation matrix to use. Neuroglancer uses the qform by default. |
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
ZarrVolumeInfo
Bases: VolumeInfo
Base class + common methods for Zarr metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to the file |
required |
getTranslations
Return translations (in spatial units).
Although OME-NGFF v0.4 requires translations to appear after scales so that translations are expressed in world units, neuroglancer accepts transformations that have the opposite order, i.e., where translations are expressed in voxels. We also handle this case and rescale translations to world units.
getNiftiInputDimensions
Return nifti dimensions, but using OME axis names.
getNiftiZarrTransform
Return the transform to apply to a Zarr layer so that it's oriented according to the nifti metadata.
getTransform
Return the nifti-zarr transform if it exists, else the ome-zarr transform.
Zarr2VolumeInfo
Bases: ZarrVolumeInfo
Volume info for Zarr v2.
getTransform
Return the nifti-zarr transform if it exists, else the ome-zarr transform.
getTranslations
Return translations (in spatial units).
Although OME-NGFF v0.4 requires translations to appear after scales so that translations are expressed in world units, neuroglancer accepts transformations that have the opposite order, i.e., where translations are expressed in voxels. We also handle this case and rescale translations to world units.
getNiftiInputDimensions
Return nifti dimensions, but using OME axis names.
Zarr3VolumeInfo
Bases: ZarrVolumeInfo
Volume info for Zarr v3.
getTransform
Return the nifti-zarr transform if it exists, else the ome-zarr transform.
getTranslations
Return translations (in spatial units).
Although OME-NGFF v0.4 requires translations to appear after scales so that translations are expressed in world units, neuroglancer accepts transformations that have the opposite order, i.e., where translations are expressed in voxels. We also handle this case and rescale translations to world units.
getNiftiInputDimensions
Return nifti dimensions, but using OME axis names.
ZarrDataSource
Bases: VolumeDataSource
Wrapper for Zarr data sources.
This wrapper will automatically check for the presence of a nifti
group in the zarr object, which indicates that the file really has
the nifti-zarr format.
This behavior can be changed by setting the option nifti=False
(to load the file as a pure OME-Zarr) or nifti=True (which raises
an error if the nifti group is not found).
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
Zarr2DataSource
Bases: ZarrDataSource
Wrapper for Zarr v2 data sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
Zarr3DataSource
Bases: ZarrDataSource
Wrapper for Zarr v3 data sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
N5VolumeInfo
N5DataSource
Bases: VolumeDataSource
Wrapper for N5 data sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedLegacyMeshInfo
PrecomputedSkeletonInfo
PrecomputedAnnotationInfo
PrecomputedVolumeInfo
PrecomputedDataSource
Bases: LayerDataSource
Base wrapper for precomputed data sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedMeshDataSource
Bases: MeshDataSource, PrecomputedDataSource
Base wrapper for precomputed mesh sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedLegacyMeshDataSource
Bases: MeshDataSource, PrecomputedDataSource
Base wrapper for precomputed mesh (legacy) sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedSkeletonDataSource
Bases: SkeletonDataSource, PrecomputedDataSource
Base wrapper for precomputed skeleton sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedAnnotationDataSource
Bases: AnnotationDataSource, PrecomputedDataSource
Base wrapper for precomputed annotations sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedTractsDataSource
Bases: PrecomputedAnnotationDataSource
Base wrapper for track precomputed annotations sources.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.
PrecomputedVolumeDataSource
Bases: VolumeDataSource, PrecomputedDataSource
Wrapper for precomputed volumes.
output_center
property
Center of the field of view in output dimensions space and units.
input_bbox_size
property
Center of the field of view in input dimensions space and units.
output_bbox_size
property
Center of the field of view in output dimensions space and units.