Skip to content

make_ng_link

jaybgager edited this page Oct 6, 2026 · 2 revisions

Warning

PAGE UNDER CONSTRUCTION

This function generates a neuroglancer link from a datastack name, optionally adding a list of segment IDs, annotation layers, custom meshes, and other options. Only works on tracertools config-supported datastacks.

Arguments:

  • datastack (string, mandatory)
    • the name of the CAVE datastack to build a link for
  • seg_ids (list of integers, optional, default=[])
    • the IDs of any segments you want included with the link
  • anno_layers (list of dictionaries, optional, default=[])
    • a list of annotation layer dictionaries to make layers out of
  • region_meshes (boolean, optional, default=False)
    • if set to True, includes a layer with the default region meshes for the volume if any exist
  • region_meshes_on (boolean, optional, default=True)
    • if set to False and region_meshes is set to True, will hide the region mesh layer
  • seg_colors (list of strings, optional, default=[])
    • Optional list of hexadecimal value colors for segments starting with #
  • seg_opacity (float, optional, default=1.0)
    • sets segmentation 3D opacity between 0.0 (invisible) and 1.0 (opaque)
    • this is useful for doing segment proofreading comparisons, where the old seg is set to red (#FF0000) and the proofread seg is set to cyan (#00FFFF); this causes the overlap to turn grey, showing added regions as cyan and removed regions as red (any pair of directly complementary colors can be used)
  • viewer_site (string, optional, default="default")
    • setting this to anything other than "default" will override the datastack's default viewer site with custom viewer site url
  • custom_mesh_source (string, optional, default=None)
    • If a mesh source url is given, will create a custom mesh layer
    • Attempts to turn on mesh segment with ID of 1, may break if one isn't present
  • custom_mesh_name (string, optional, default=None)
    • name for custom mesh layer if passed, default None will name the layer "Custom Mesh"
  • custom_mesh_seg_ids (list of integers, optional, default=None)
    • the segment IDs of any segments in the custom mesh volume to be selected
  • custom_mesh_colors (list of strings, optional, default=None)
    • list of colors of custom mesh in hexadecimal notation starting with # (e.g "#00ff00" for green)
    • default None will use color list generated by make_color_list
  • custom_mesh_opacity (float, optional, default=1.0)
    • sets custom mesh 3D opacity between 0.0 (invisible) and 1.0 (opaque)
  • view_coords (optional, list, default=None)
    • if volume-resolution point coordinates are passed, will set the viewer start postiion
    • default value of None will use the tracertools config default start position for the chosen datastack
  • long_url (bool, optional, default=False)
    • setting to True returns the url in the long-form neuroglancer format instead of using a shortened link
    • by default, uses a link shortener to make output postable on platforms with character limits (e.g. Slack)

Returns:

  • output_link (string)
    • the final neuroglancer link

Examples

Default Behavior

INPUT:

import tracertools as tt

ng_url = tt.make_ng_link(
    datastack = "brain_and_nerve_cord",
    seg_ids = [
        720575941441350235,
        720575941519923628,
        720575941703820762,
    ],
    region_meshes = True,
)

print(ng_url)

OUTPUT:

https://spelunker.cave-explorer.org/#!middleauth+https://global.daf-apis.com/nglstate/api/v1/6639015473184768

Custom Colors and Translucency

INPUT:

import tracertools as tt

ng_url = tt.make_ng_link(
    datastack = "brain_and_nerve_cord",
    seg_ids = [
        720575941473274509, # outdated version of 720575941441350235 #
        720575941524660200, # outdated version of 720575941519923628 #
        720575941565377335, # outdated version of 720575941703820762 #
        720575941441350235,
        720575941519923628,
        720575941703820762,
    ],
    seg_colors = [
        "#FF0000",
        "#FF0000",
        "#FF0000",
        "#00FFFF",
        "#00FFFF",
        "#00FFFF",
    ],
    translucent_seg = True,
)

print(ng_url)

OUTPUT:

https://spelunker.cave-explorer.org/#!middleauth+https://global.daf-apis.com/nglstate/api/v1/5192707382181888

Custom Mesh and Manual Viewpoint Setting

INPUT:

import tracertools as tt

ng_url = tt.make_ng_link(
    datastack = "brain_and_nerve_cord",
    custom_mesh_source = "https://c10s.pni.princeton.edu/tracers/examples/mesher/volume_02|neuroglancer-precomputed:",
    custom_mesh_name = "Orange you glad you can customize mesh names?",
    custom_mesh_color = "#FF7800",
    view_coords = [123757, 180557, 4582],
)

print(ng_url)

OUTPUT:

https://spelunker.cave-explorer.org/#!middleauth+https://global.daf-apis.com/nglstate/api/v1/4819158423306240

Note

This output was generated on 2026/06/16 and may vary if this code is run in the future.

Clone this wiki locally