statebuilder.viewer_config
Config objects for the parts of a Neuroglancer state that are nested structures.
Neuroglancer models the camera and each side panel as a sub-object of the viewer state, and the same shapes reappear elsewhere (a layer-group panel has its own camera; tool palettes are placed like any other side panel). Each class here maps onto one of those sub-objects so it can be built once and reused.
Every field defaults to None, meaning "not set": unset fields are left out of the emitted state, so Neuroglancer's own defaults -- or a base state's values -- apply.
Classes:
-
Camera–Where the viewer looks, in both the 2d cross-section and the 3d projection.
-
SidePanel–Placement and visibility of one of Neuroglancer's side panels.
-
SkeletonRendering–How a segmentation layer draws skeletons.
Functions:
-
parse_orientation–Convert an orientation to a normalized
[x, y, z, w]quaternion.
Camera
Where the viewer looks, in both the 2d cross-section and the 3d projection.
Neuroglancer keeps separate zoom, orientation, and depth for the cross-section (2d) and projection (3d) views. Field names follow Neuroglancer's own.
Parameters:
-
cross_section_scale(float) –Zoom of the 2d views, in voxels per screen pixel. Smaller is closer.
-
cross_section_orientation(str or sequence of float) –Orientation of the 2d views, as a plane name (
"xy","xz","yz") or an[x, y, z, w]quaternion. Seeparse_orientation. -
cross_section_depth(float) –Depth of field of the 2d views, used when rendering annotations off-plane.
-
projection_scale(float) –Zoom of the 3d view. Smaller is closer.
-
projection_orientation(str or sequence of float) –Orientation of the 3d view, as a plane name or quaternion.
-
projection_depth(float) –Depth of the 3d view's clipping volume.
Examples:
>>> vs.set_camera(projection_orientation="xz", projection_scale=5000)
>>> side_view = Camera(projection_orientation=[0.5, 0.5, 0.5, 0.5])
>>> vs.set_camera(side_view)
Methods:
-
apply_to_neuroglancer–Write the set fields onto a neuroglancer state or layer-group panel.
-
merge–Return a camera with
other's set fields laid over this one's.
apply_to_neuroglancer(state)
Write the set fields onto a neuroglancer state or layer-group panel.
merge(other)
Return a camera with other's set fields laid over this one's.
SidePanel
Placement and visibility of one of Neuroglancer's side panels.
Used for the layer list, statistics, help, and selected-layer panels.
Parameters:
-
visible(bool) –Whether the panel is open.
-
side(('left', 'right', 'top', 'bottom'), default:"left") –Which edge of the viewer the panel docks to.
-
size(int) –Width (or height, for top/bottom panels) in pixels.
-
flex(float) –Share of the edge's length when several panels dock to the same side.
-
row(int) –Position among other panels docked to the same side.
-
col(int) –Position among other panels docked to the same side.
Examples:
>>> vs.set_panels(
... layer_list_panel=True, selected_layer_panel=SidePanel(side="right", size=500)
... )
Methods:
-
apply_to_neuroglancer–Write the set fields onto a neuroglancer side panel state.
-
coerce–Accept a SidePanel, a dict of its fields, or a bool meaning
visible. -
merge–Return a panel with
other's set fields laid over this one's.
apply_to_neuroglancer(panel_state)
Write the set fields onto a neuroglancer side panel state.
coerce(value)
classmethod
Accept a SidePanel, a dict of its fields, or a bool meaning visible.
merge(other)
Return a panel with other's set fields laid over this one's.
SkeletonRendering
How a segmentation layer draws skeletons.
Parameters:
-
shader(str) –GLSL skeleton shader. See
nglui.statebuilder.shadersfor ready-made ones. -
shader_controls(dict) –Values for the
#uicontrolcontrols the shader declares, keyed by name. -
mode_2d(('lines', 'lines_and_points'), default:"lines") –Whether to draw vertices as well as edges, in the 2d and 3d views.
-
mode_3d(('lines', 'lines_and_points'), default:"lines") –Whether to draw vertices as well as edges, in the 2d and 3d views.
-
line_width_2d(float) –Edge width in pixels, in the 2d and 3d views.
-
line_width_3d(float) –Edge width in pixels, in the 2d and 3d views.
Examples:
>>> SegmentationLayer(
... source=...,
... skeleton_rendering=SkeletonRendering(line_width_3d=3, mode_3d="lines_and_points"),
... )
Methods:
-
coerce–Accept a SkeletonRendering or a dict of its fields.
-
to_json–The set fields, under Neuroglancer's
skeletonRenderingJSON keys.
coerce(value)
classmethod
Accept a SkeletonRendering or a dict of its fields.
to_json()
The set fields, under Neuroglancer's skeletonRendering JSON keys.
parse_orientation(value)
Convert an orientation to a normalized [x, y, z, w] quaternion.
Parameters:
-
value(str, sequence of 4 floats, or None) –Either the name of a plane (
"xy","xz","yz"), matching the orientation of Neuroglancer's panel of that name, or a quaternion in Neuroglancer's[x, y, z, w]order. Quaternions are normalized.
Returns:
-
list of float or None–The quaternion, or None if
valueis None.
Examples: