neu_glance.served_layer¶
A layer to host: an array, how to show it, and its translation into neuroglancer terms.
ServedLayer is what neu_glance.serve() and neu_glance.Server.add_layer()
take. neuroglancer is imported only inside functions (the serve extra).
The volume type comes from ``kind``, never from the dtype. neuroglancer would guess that a uint8 label array is an image, averaging label ids and losing the segment UI.
Exceptions¶
The arrays or options given cannot be served as asked. |
Classes¶
One array to host, and how to show it. |
Module Contents¶
- exception neu_glance.served_layer.ServeProblem¶
Bases:
RuntimeErrorThe arrays or options given cannot be served as asked.
Initialize self. See help(type(self)) for accurate signature.
- class neu_glance.served_layer.ServedLayer¶
One array to host, and how to show it.
frameis aneu_lib.Frame(voxel size and origin in nm). Without it a crop is placed at nm zero instead of over the volume it came from.colorsets the shader’s single colour, for shaders that have one, such as theprobabilitydefault (red, with opacity carrying the value); it accepts anythingas_hex_color()does.opacityis the layer’s overall opacity, multiplied with the shader’s per-voxel alpha.channel_axis(a leading, channel-first axis) follows from the array’s rank: 4-D has one, 3-D does not. Passing it is allowed but checked.- classmethod from_array(array: Any, kind: str, *, name: str | None = None, frame: Any = None, voxel_size: Sequence[float] | None = None, origin: Sequence[float] | None = None, channel_axis: bool | None = None, **kwargs) ServedLayer¶
An in-memory array.
voxel_size/originbuild the frame for you.ServedLayer.from_array(prob, “probability”, voxel_size=(40, 8, 8))
channel_axisfollows from the array’s rank (seeServedLayer).
- classmethod from_hdf5(path: str, dataset: str | None = None, kind: str | None = None, *, crop: Any = None, name: str | None = None, voxel_size: Sequence[float] | None = None, **kwargs) ServedLayer¶
One dataset of an HDF5 file, with the frame it records about itself.
ServedLayer.from_hdf5(“piece.h5”, kind=”segmentation”) ServedLayer.from_hdf5(“gt.h5”, “/z07901”, “segmentation”)
datasetmay be omitted when the file holds exactly one 3D+ array. The frame comes from the file’svoxel_size/axes/voxel_offsetattributes, asneu-vol to-hdf5writes them;voxel_sizeoverrides, and is required if the file records none.kindis required, since HDF5 has no standard place to record it. The format is forced to HDF5, whatever the extension.
- classmethod from_piece(piece: Any, kind: str | None = None, *, name: str | None = None, **kwargs) ServedLayer¶
A
neu_lib.Piece— an array that already carries its frame and kind.piece = neu_vol.read_piece(“gt.h5:/vol_03700”, “segmentation”) layer = ServedLayer.from_piece(piece)
kindandnamedefault to the piece’s own. If the piece’skindisNone, pass one: it is not guessed from the dtype.
- classmethod from_source(src: str, kind: str | None = None, *, level: int = 0, crop: Any = None, name: str | None = None, voxel_size: Sequence[float] | None = None, **kwargs) ServedLayer¶
Anything readable, addressed as
PATHorPATH:/DATASET.The form the CLI takes. The format is detected, and a trailing
:/nameselects a dataset in an HDF5 file (only a colon followed by a slash, sos3://is safe).
- classmethod from_volume(volume: str, kind: str | None = None, *, level: int = 0, crop: Any = None, name: str | None = None, voxel_size: Sequence[float] | None = None, **kwargs) ServedLayer¶
A box out of a stored volume — zarr, precomputed, an image stack.
- ServedLayer.from_volume(“s3://my-bucket/seg_v1”, level=1,
crop=((0, 0, 0), (64, 512, 512)))
kinddefaults to what the volume records (precomputed’sinfo["type"], OME-NGFF’s multiscalestype) and is required only where it records nothing. A whole volume is usually too large for memory, so passcrop.
- array: Any¶
- property bounds_nm: Any¶
Where this layer sits, in nanometres. Also what
crop=reads off a layer.
- channel_axis: bool | None = None¶
- color: Any = None¶
- frame: Any = None¶
- kind: str = 'image'¶
- name: str | None = None¶
- opacity: float | None = None¶
- property piece: Any¶
This layer’s array and frame as a
neu_lib.Piece, for.bbox,.bounds_nmand.crop().
- shader: str | None = None¶