cellmap_flow.viewer.raw ======================= .. py:module:: cellmap_flow.viewer.raw .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: cellmap_flow.viewer.raw.logger cellmap_flow.viewer.raw.RAW_SHADER cellmap_flow.viewer.raw.PREDICTION_SHADER cellmap_flow.viewer.raw.PREDICTION_COLORS cellmap_flow.viewer.raw.FLOW_SHADER Classes ------- .. autoapisummary:: cellmap_flow.viewer.raw.ScalePyramid Functions --------- .. autoapisummary:: cellmap_flow.viewer.raw.prediction_shader cellmap_flow.viewer.raw.flow_shader cellmap_flow.viewer.raw.neuroglancer_source cellmap_flow.viewer.raw.get_raw_layer Module Contents --------------- .. py:data:: logger .. py:data:: RAW_SHADER :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """#uicontrol invlerp normalized(range=[{lo:.6g}, {hi:.6g}], window=[{wlo:.6g}, {whi:.6g}]); #uicontrol vec3 color color(default="white"); void main(){{emitRGB(color * normalized());}}""" .. raw:: html
.. py:data:: PREDICTION_SHADER :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """#uicontrol invlerp normalized(range=[{lo:.6g}, {hi:.6g}], window=[{wlo:.6g}, {whi:.6g}]); #uicontrol vec3 color color(default="{color}"); void main(){{emitRGB(color * normalized());}}""" .. raw:: html
.. py:data:: PREDICTION_COLORS :value: ['red', 'green', 'blue', 'yellow', 'purple', 'orange', 'cyan', 'magenta'] .. py:function:: 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. .. py:data:: FLOW_SHADER :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """#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); }}""" .. raw:: html
.. py:function:: flow_shader(color, value_range, flow_y, flow_x, display_channel=None) FLOW_SHADER over channels ``flow_y`` and ``flow_x``, dimmed by channel ``display_channel`` over ``value_range`` (as prediction_shader's), or not dimmed without one. .. py:function:: neuroglancer_source(dataset_path) The source neuroglancer reads ``dataset_path`` from 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://`` or ``precomputed://``, followed by a local path or an ``http(s)://``, ``s3://`` or ``gs://`` URL. A precomputed volume is named whole: neuroglancer opens a volume, never one of its scales (``…/s2`` has no info of its own), and a bare ``gs://`` path is one. .. py:function:: 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). ``segmentation`` gives 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_meshes`` then turns off its meshes subsource (see _layer). .. py:class:: ScalePyramid(volume_layers) One neuroglancer volume served from a ``LocalVolume`` per 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_key`` such 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. :param volume_layers: One ``LocalVolume`` per level. :type volume_layers: ``list`` of ``LocalVolume`` .. py:attribute:: dims .. py:attribute:: volume_layers .. py:property:: volume_type .. py:property:: token .. py:method:: info() .. py:method:: get_encoded_subvolume(data_format, start, end, scale_key=None) .. py:method:: get_object_mesh(object_id) .. py:method:: invalidate() Mark the data invalidated. Clients will refetch the volume.