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
Bases:
List of data sources.
DataSourceInfo
Base class for source-specific metadata.
LayerDataSource
Bases:
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:
Base class for volume metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
|
URL to the file |
required |
VolumeDataSource
Bases:
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:
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:
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:
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:
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: ,
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: ,
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: ,
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:
Metadata of a NIfTI volume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
|
URL to the file |
required |
align_corner
|
|
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
|
(
|
Which orientation matrix to use. Neuroglancer uses the qform by default. |
"qform"
|
NiftiDataSource
Bases:
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
|
|
URL to the file |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
url |
|
URL to the file |
align_corner |
|
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 |
(
|
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:
Base class + common methods for Zarr metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
|
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:
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:
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:
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:
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:
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
Bases:
Base class + common methods for N5 metadata.
N5DataSource
Bases:
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
Bases:
Metadata of a precomputed mesh (legacy).
PrecomputedSkeletonInfo
Bases:
Metadata of a precomputed skeleton.
PrecomputedAnnotationInfo
Bases:
Metadata of a precomputed annotation.
PrecomputedVolumeInfo
Bases:
Metadata of a precomputed volume.
PrecomputedDataSource
Bases:
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: ,
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: ,
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: ,
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: ,
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:
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: ,
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.