Skip to content

ngtools.shaders

Functions to generate NeuroGlancer shaders.

NeuroGlancer shaders must be snippets of GLSL code. This module contains functions that dynamically generate such code snippets.

GLSL = OpenGL Shading Language.

pycolormaps

Namespace for dynamic colormaps.

Functions in this class return python functions.

make_colormap staticmethod

make_colormap(name, data=None)

Generate GLSL code for a colormap.

make_listed staticmethod

make_listed(name, data=None)

Generate GLSL code for a listed colormap.

make_weighted staticmethod

make_weighted(name, data=None)

Generate GLSL code for a listed colormap.

make_segmented staticmethod

make_segmented(name, data=None)

Generate GLSL code for a segmented colormap.

colormaps

Namespace for dynamic colormaps.

Functions in this class return shader code.

make_colormap staticmethod

make_colormap(name, data=None, n=_DEFAULT_LENGTH)

Generate GLSL code for a colormap.

make_listed staticmethod

make_listed(name, data=None, n=_DEFAULT_LENGTH)

Generate GLSL code for a listed colormap.

make_segmented staticmethod

make_segmented(name, data=None, n=_DEFAULT_LENGTH)

Generate GLSL code for a segmented colormap.

shaders

Namespace for full-fledged shaders.

skeleton

Shaders for skeletons.

annotation

Shaders for annotations.

colormap staticmethod

colormap(cmap)

Generate a shader based on a known colormap.

Parameters:

Name Type Description Default
cmap str

Name of a colormap. Must be a valid attribute from the colormaps namespace.

required

lut staticmethod

lut(lut)

Generate a shader based on a lookup table.

Parameters:

Name Type Description Default
lut str | dict[int, tuple[str, tuple[float, float, float, float]]]

Path to a FreeSurfer lookup table, or pre-loaded LUT.

required

pretty_colormap_list

pretty_colormap_list(linewidth=79, colorbar=True)

List all existing colormaps.

load_fs_lut

load_fs_lut(path)

Load a FreeSurfer lookup table.

Returns a dictionary that maps integer labels to tuples that contains 1. the structure name, as a string 2. the structure RGBA color, as a 4-tuple of values between 0 and 1.

rotate_shader

rotate_shader(shader, mat, compose=True)

Apply a rotation matrix to orientation vector of a shader.