statebuilder.layouts
Multi-panel layouts: rows and columns of panels, each showing its own layers.
Neuroglancer's preset layouts ("xy-3d", "4panel", ...) show every layer in every
view. For side-by-side comparisons -- imagery beside a 3d mesh view, or one neuron
beside another -- a layout can instead be a tree of rows and columns whose leaves
are Panels, each with its own layers, view type, and optionally its own camera.
Examples:
>>> from nglui.statebuilder import Panel, row
>>> vs.set_layout(
... row(
... Panel(["img", "seg"], layout="xy"),
... Panel(["seg"], layout="3d", camera=Camera(projection_orientation="xz")),
... )
... )
Classes:
-
Panel–One view in a multi-panel layout, showing a chosen set of layers.
-
StackLayout–A row or column of panels and nested layouts. Build with
roworcolumn.
Functions:
Panel
One view in a multi-panel layout, showing a chosen set of layers.
Parameters:
-
layers(list of str or Layer) –Layers shown in this panel, by name or object. None shows every layer.
-
layout(str) –Which views the panel has, as one of Neuroglancer's presets (e.g. "xy", "3d", "xy-3d"). Default is "xy".
-
camera(Camera) –A camera for this panel. Fields that are set are decoupled from the rest of the viewer (see
camera_link); unset fields follow the global camera. -
camera_link(('unlinked', 'relative'), default:"unlinked") –How the set camera fields relate to the global camera: "unlinked" holds them fixed, "relative" applies them as an offset that follows the global view. Default is "unlinked".
-
flex(float) –Share of the enclosing row or column this panel takes. Default is 1.
Examples:
>>> Panel([img, seg], layout="xy")
>>> Panel(["seg"], layout="3d", camera=Camera(projection_orientation="xz"))
Methods:
-
layer_names–Names of the layers this panel shows, or [] if it shows all of them.
-
to_json–The panel's
viewerlayout JSON.
layer_names()
Names of the layers this panel shows, or [] if it shows all of them.
to_json(all_layers)
The panel's viewer layout JSON.
StackLayout
A row or column of panels and nested layouts. Build with row or column.
Methods:
-
layer_names–Names of every layer a panel in this layout names explicitly.
-
to_json–The layout's JSON.
layer_names()
Names of every layer a panel in this layout names explicitly.
to_json(all_layers)
The layout's JSON.
column(*children, flex=None)
Lay panels out stacked, top to bottom.
Parameters:
-
*children(Panel or StackLayout, default:()) –The panels and nested rows or columns.
-
flex(float, default:None) –Share of an enclosing row or column this column takes.
layout_to_json(value, all_layers)
Convert a layout to the value of the state's layout field.
Raises:
-
ValueError–If a panel names a layer that is not in the state.
row(*children, flex=None)
Lay panels out side by side, left to right.
Parameters:
-
*children(Panel or StackLayout, default:()) –The panels and nested rows or columns.
-
flex(float, default:None) –Share of an enclosing row or column this row takes.
validate_layout(value)
Raise if value is not a preset name, Panel, or StackLayout.