cellmap_flow.viewer.raw
The raw data’s neuroglancer layer, and the shaders of the viewer’s layers.
get_raw_layer shows a zarr, N5 or precomputed volume. By default it is
served from this process: a multiscale pyramid (an OME-Zarr group’s
levels, a precomputed volume’s scales) as one ScalePyramid (each level
a LocalVolume, served as a power-of-two downsampling of the finest; a
level that is not one is left out), a single array
as a LocalVolume, both read through ImageDataInterface so that the
input chain applies to what is drawn (never to a segmentation’s ids), and
placed by a source transform that puts voxel 0’s lower corner where the
metadata says. With wrap_raw=False neuroglancer reads the
files itself. RAW_SHADER and prediction_shader are the layers’
shaders, their contrast windows sampled from the data where it can be read.
ScalePyramid is adapted from funlib.show.neuroglancer’s scale_pyramid.py
(https://github.com/funkelab/funlib.show.neuroglancer).
Attributes
Classes
One neuroglancer volume served from a |
Functions
|
Shader for a model output layer, over the range the chain produces. |
|
FLOW_SHADER over channels |
|
The source neuroglancer reads |
|
A neuroglancer layer showing a zarr, n5 or precomputed volume. |
Module Contents
- cellmap_flow.viewer.raw.logger
- cellmap_flow.viewer.raw.RAW_SHADER = Multiline-String
Show Value
"""#uicontrol invlerp normalized(range=[{lo:.6g}, {hi:.6g}], window=[{wlo:.6g}, {whi:.6g}]); #uicontrol vec3 color color(default="white"); void main(){{emitRGB(color * normalized());}}"""
- cellmap_flow.viewer.raw.PREDICTION_SHADER = Multiline-String
Show Value
"""#uicontrol invlerp normalized(range=[{lo:.6g}, {hi:.6g}], window=[{wlo:.6g}, {whi:.6g}]); #uicontrol vec3 color color(default="{color}"); void main(){{emitRGB(color * normalized());}}"""
- cellmap_flow.viewer.raw.PREDICTION_COLORS = ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'cyan', 'magenta']
- cellmap_flow.viewer.raw.prediction_shader(color, value_range=None)
Shader for a model output layer, over the range the chain produces.
Falls back to [0, 1] when the range is undetermined. That is a guess, but the previous default was
range=[0.5, 0.5]– lo == hi makes invlerp a step function rather than a ramp, so every value above 0.5 rendered as solid colour. After a DefaultPostprocessor (0-255) that is the entire prediction.
- cellmap_flow.viewer.raw.FLOW_SHADER = Multiline-String
Show Value
"""#uicontrol bool flows checkbox(default=true); #uicontrol float flow_length slider(min=0.5, max=10, default=5); {cell_control}#uicontrol vec3 color color(default="{color}"); void main(){{ float shown = {cell}; if (!flows) {{ emitRGB(color * shown); return; }} vec2 flow = vec2(toNormalized(getDataValue({flow_x})), toNormalized(getDataValue({flow_y}))); float len = length(flow); vec2 dir = flow / max(len, 1e-6); // cos(angle + 0, -120, 120 degrees), from the direction without atan. vec3 hue = 0.5 + 0.5 * (dir.x * vec3(1.0, -0.5, -0.5) - dir.y * vec3(0.0, -0.866, 0.866)); emitRGB(hue * clamp(len / flow_length, 0.0, 1.0) * shown); }}"""
- cellmap_flow.viewer.raw.flow_shader(color, value_range, flow_y, flow_x, display_channel=None)
FLOW_SHADER over channels
flow_yandflow_x, dimmed by channeldisplay_channelovervalue_range(as prediction_shader’s), or not dimmed without one.
- cellmap_flow.viewer.raw.neuroglancer_source(dataset_path)
The source neuroglancer reads
dataset_pathfrom itself, in the browser (wrap_raw=False): its location with the format in front, as neuroglancer names its data sources –zarr://(v2 or v3, which neuroglancer tells apart),n5://orprecomputed://, followed by a local path or anhttp(s)://,s3://orgs://URL.A precomputed volume is named whole: neuroglancer opens a volume, never one of its scales (
…/s2has no info of its own), and a baregs://path is one.
- cellmap_flow.viewer.raw.get_raw_layer(dataset_path, normalize=True, wrap_raw=True, segmentation=False, disable_meshes=False)
A neuroglancer layer showing a zarr, n5 or precomputed volume.
A multiscale pyramid, or any of its levels, is shown as the whole pyramid (see _pyramid for what its levels are).
segmentationgives a SegmentationLayer over the same source, placed the same way, for a label volume; its ids are served as stored, never through the input normalizers.disable_meshesthen turns off its meshes subsource (see _layer).
- class cellmap_flow.viewer.raw.ScalePyramid(volume_layers)
One neuroglancer volume served from a
LocalVolumeper pyramid level. Mimics a LocalVolume: neuroglancer sees the finest level.neuroglancer’s python data source asks only for power-of-two downsamplings of the volume it sees (a
scale_keysuch as “2,2,2”). Each level is kept under its downsampling factor, its voxel size over the finest’s per axis ((1, 1, 1) for the finest). A request is served by the level at or below it on every axis that leaves the smallest factor on any one axis (in a pyramid whose levels are each coarser than the last on every axis, the coarsest such level), and that level’s LocalVolume downsamples the rest of the way, up to its own limit; neuroglancer is told to ask no further (_max_downsampling).A level that is not a power-of-two multiple of the finest on every axis (1.5×, 3×) could never answer a request exactly, so it is left out, as is a second level at a factor already kept; one warning names them. The finest level is always kept, so the pyramid is never empty.
- Parameters:
volume_layers (
listofLocalVolume) – OneLocalVolumeper level.
- dims
- volume_layers
- property volume_type
- property token
- info()
- get_encoded_subvolume(data_format, start, end, scale_key=None)
- get_object_mesh(object_id)
- invalidate()
Mark the data invalidated. Clients will refetch the volume.