scene
ngtools.scene
A neuroglancer scene with a programmatic interface.
ViewerState
Bases:
Smart ng.ViewerState that knows default values set in the frontend.
Attributes:
| Name | Type | Description |
|---|---|---|
|
str, default=None
|
Window title |
|
|
All "global" dimensions. |
|
|
??? |
|
|
The 2 or 3 dimensions that are displayed in the cross section. Their order matters, as they map to the red, green and blue axes. |
|
|
Position in the "global frame". This vector must have as many values as there are dimensions. |
|
|
??? |
|
vector[float], default=(0, 0, 0, 1)
|
Orientation of the cross-sections in the "displayed global frame".
It is a quaternion ordered as |
|
float, default=1
|
Zoom level of the cross-sections. |
|
|
??? |
|
|
Zoom level of the 3D window. |
|
|
??? |
|
vector[float], default=[0, 0, 0, 1]
|
Orientation of the 3D window in the "displayed global frame".
It is a quaternion ordered as |
|
bool, default=True
|
Whether to display orthogonal cross sections in the 3D window. |
|
bool, default=False
|
Whether to display mesh wire frames in the 3D window. |
|
bool, default=True
|
??? |
|
bool, default=True
|
Whether to show the scale bar. |
|
bool, default=True
|
??? |
|
|
Maximum GPU usage. |
|
|
Maximum CPU usage. |
|
|
Maximum number of concurrent downloads. |
|
bool, default=True
|
Prefetch chunks. |
|
|
List of (named) registered layers. |
|
|
If a string, can be one of
|
|
str, default="black"
|
Background color of cross-sections. |
|
str, default="black"
|
Background color of 3D window. |
|
|
With fields
* |
|
|
With fields
* |
|
|
With fields
* |
|
|
With fields
* |
|
vector[float], default=[0, 0, 1, 1]
|
Top-left and bottom-right corner of the visible portion of the
viewer, where |
|
|
User-specific key bindings. |
Scene
Bases:
A neuroglancer scene with a programmatic interface.
Other Parameters:
| Name | Type | Description |
|---|---|---|
stdout |
|
Output stream. |
stderr |
|
Error stream. |
level |
(
|
Level of printing. * If None: no printing * If "error": print errors * If "warning": print errors and warnings * If "info": print errors, warnings and infos * If "debug": print errors, warnings, infos and debug messages. * If "any: print any message. |
load
Load file(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
|
Paths or URL, eventually prepended with "type" and "format"
protocols. Ex: |
None
|
transform
|
|
Affine transform to apply to the loaded volume. |
None
|
inv
|
|
Invert the transform before applying it. |
False
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
name |
|
Alternative way of providing layer names.
If used, |
unload
Unload layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
|
Layer(s) to unload |
None
|
rename
Rename a layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
|
Current name |
required |
dst
|
|
New name |
required |
world_axes
Map native model axes ("x", "y", "z", "t") to
neuroanatomical or arbitrary names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
|
Mapping from native to user names. If None, simply return current mapping. |
None
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
src |
|
Native/New axes names. If used, |
dst |
|
Native/New axes names. If used, |
Returns:
| Name | Type | Description |
|---|---|---|
axes |
|
Mapping from native to user names. |
rename_axes
Rename world axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
|
A dictionary that maps old names to new names, or a known
neurospace (e.g., |
None
|
layer
|
|
Layers to rename. By default, all. |
None
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
src |
|
Old/New axes names. If used, |
dst |
|
Old/New axes names. If used, |
Returns:
| Name | Type | Description |
|---|---|---|
axes |
|
Mapping from old names to new names |
space
Rotate the view such that the cross-sections are aligned with the voxel axes of a layer. Also, switch between radiological and neurological orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
|
Neurological (patient's point of view) or radiological (facing the patient) orientation. |
'radio'
|
layer
|
|
Name of a layer or |
None
|
display
Change displayed dimensions and/or change neurospace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimensions
|
|
The three dimensions to display. Each dimension can be one of:
Otherwise, dimensions can be native axis names of the loaded
data, such as A compact representation ( |
None
|
transform
Apply an affine transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transform
|
|
Affine transform (RAS+) |
None
|
layer
|
|
Layer(s) to transform |
None
|
inv
|
|
Invert the transform |
False
|
reset
|
|
Reset the default transform prior to applying the new transform. |
False
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
mov |
|
Moving/Floating image (required by some affine formats) |
fix |
|
Fixed/Reference image (required by some affine formats) |
save_transform
Save transform from default space to current space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
[list of] str | None
|
Output filename(s). |
None
|
layer
|
[list of] str | none
|
Layer(s) for which to save the transform(s). |
None
|
format
|
|
Format hint. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
transform |
[list of] ng.CoordinateSpaceTransform
|
Estimated transform(s). |
channel_mode
Change the mode (local or intensity) of an axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
(
|
How to interpret this dimension:
|
"local"
|
layer
|
[list of] str
|
Names of layers to process |
None
|
dimension
|
[list of] str
|
Names of dimensions to process |
'c'
|
move
Change cursor position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coord
|
[list of] float | dict[str, float]
|
New position. If a dictionary, maps axes to values. |
0
|
dimensions
|
[list of] str
|
Axis of each coordinate. Can be a compact name like 'RAS'.
Cannot be used when |
None
|
unit
|
|
Units of the coordinates. Default: Unit of current axes. |
None
|
absolute
|
|
Move to absolute position, rather than relative to current. |
False
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
reset |
|
Reset position to default |
Returns:
| Name | Type | Description |
|---|---|---|
coord |
|
Current cursor position. |
zoom
Zoom by some factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factor
|
|
Zoom factor |
2.0
|
reset
|
|
Reset zoom level to default |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
scale |
|
Current zoom level |
unzoom
Unzoom by some factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
factor
|
|
Unzoom factor |
2.0
|
reset
|
|
Reset zoom level to default |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
scale |
|
Current zoom level |
shader
Apply a shader (that is, a colormap or lookup table).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shader
|
|
A known shader name (from |
required |
layer
|
|
Apply the shader to these layers. Default: all layers. |
None
|
layer_type
|
|
Apply the shader to these layer types. Default: all layers. |
None
|
change_layout
change_layout(layout=None, stack=None, layer=None, *, flex=1, append=None, assign=None, insert=None, remove=None)
Change layout.
Append/Assign/Insert/Remove
The requested (stack of) layout(s) can be inserted into existing layouts.
Arguments must be an integer or list of integer, that are used to navigate through the existing nested stacks of layouts.
Only one of {append, assign, insert, remove} can be used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
[list of] {"xy", "yz", "xz", "xy-3d", "yz-3d", "xz-3d", "4panel", "3d"}
|
Layout(s) to set or insert. If list, |
None
|
stack
|
(
|
Insert a stack of layouts.
If input layout is a list and |
"row"
|
layer
|
[list of] str
|
Set of layers to include in the layout. By default, all layers are included (even future ones). |
None
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
flex |
|
??? |
append |
bool or [list of] int or str
|
Append the layout to an existing stack. |
assign |
int or [list of] int or str
|
Assign the layout into an existing stack. |
insert |
int or [list of] int or str
|
Insert the layout into an existing stack. |
remove |
int or [list of] int or str
|
Remove the layout from an existing stack. |
Returns:
| Name | Type | Description |
|---|---|---|
layout |
|
Current JSON layout |
zorder
Move or reorder layers.
In neuroglancer, layers are listed in the order they are loaded, with the latest layer appearing on top of the other ones in the scene. Counter-intuitively, the latest/topmost layer is listed at the bottom of the layer list, while the earliest/bottommost layer is listed at the top of the layer list. In this function, we list layers in their expected z-order, top to bottom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
|
Name of layers to move.
If |
required |
steps
|
|
Number of steps to take. Positive steps move layers towards the top and negative steps move layers towards the bottom. |
None
|
state
Print or save or load the viewer's JSON state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
load
|
|
Load state from JSON file, or JSON string (or URL if |
None
|
save
|
|
Save state to JSON file |
None
|
url
|
|
Print/load/save a JSON URL rather than a JSON object |
False
|
instance
|
(
|
Neuroglancer instance to use in the URL. |
"ng"
|
print
|
|
print the JSON object or URL |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
state |
|
JSON state |