statebuilder.shaders
Classes:
-
InverlpControl–Deprecated misspelling of
InvlerpControl. -
InvlerpControl–An
invlerpcontrol: maps a data range to [0, 1] with an interactive histogram. -
PointShader–
Functions:
-
color_to_vec3–Convert a color to a string representation of an RGB triple.
-
shader_base–Set a skeleton vertex attribute in the shader code.
-
simple_point_shader–Generate a simple point shader with a specified color.
InverlpControl
InvlerpControl
Bases: ShaderControl
An invlerp control: maps a data range to [0, 1] with an interactive histogram.
Neuroglancer's default image shader uses one named normalized; declare your
own when writing a custom shader, then call it in main as name().
Parameters:
-
name(str) –The control's name, which the shader calls as a function.
-
range(list of float) –Data values mapped to 0 and 1. Defaults to the data type's full range. An inverted interval such as
[200, 30]inverts the mapping. -
window(list of float) –Extent of the histogram shown in the layer panel. Defaults to
range. -
channel(int or list of int) –Channel of a multi-channel image to read. Image layers only.
-
clamp(bool) –Whether values outside
rangeare clamped to [0, 1]. Default is True. -
property(str) –Annotation or segment property to read, instead of image data.
Examples:
>>> str(InvlerpControl("contrast", range=[30, 220]))
'#uicontrol invlerp contrast(range=[30, 220]);'
PointShader(colors=None, colormap=None, n_colors=None, many_label_color='white', no_label_color='grey', markersize=5, markerslider=True)
Create a point shader with customizable colors and properties. See https://jiffyclub.github.io/palettable/ for available colormaps.
Parameters:
-
colors(list, default:None) –List of colors (strings, hex, or RGB tuples/lists)
-
colormap(str, default:None) –Name of a palettable colormap (ignoring category) (e.g., 'Set1') Not used if colors is specified.
-
n_colors(int, default:None) –Number of colors to extract from colormap. Cannot be more than the available numbers in the colormap. Only used if a colormap is specified.
-
many_label_color(str, default:'white') –Color for points with multiple labels, by default 'white'
-
no_label_color(str, default:'grey') –Color for points with no labels, by default 'grey'
-
markersize(int, default:5) –Default marker size, by default 5
-
markerslider(bool, default:True) –Whether to include marker size slider, by default True
Methods:
-
make_properties–Return property configuration for neuroglancer.
make_properties()
Return property configuration for neuroglancer.
color_to_vec3(clr)
Convert a color to a string representation of an RGB triple.
:param clr: Color in various formats (string, tuple, list). :return: String representation of the RGB triple.
shader_base(vertex_attributes=None, checkbox_controls=None, sliders=None, defined_colors=None, uicontrols=None, body=None)
Set a skeleton vertex attribute in the shader code.
Parameters:
-
vertex_attributes(list[str], default:None) –The names of the vertex attribute to set.
-
checkbox_controls(dict or list, default:None) –Dictionary of checkbox controls with names as keys and default values as values. If a list is provided, it will be converted to a dictionary with True as default value.
-
sliders(dict, default:None) –Dictionary of slider controls with names as keys and a tuple of (type, min, max, default) as values. If a list is provided, it will be converted to a dictionary with default values of float, 0, 1, 0.5.
-
defined_colors(dict, default:None) –Dictionary of defined colors with names as keys and color values as values. If a list is provided, it will be converted to a dictionary with colors from the Tableau-10 palette.
-
body(str, default:None) –The body of the shader code to execute in the main function. If none is provided, a simple emitRGB is given.
Returns:
-
str–The shader code to set the vertex attribute.