statebuilder.base
Classes:
-
NumpyEncoder–Custom JSON encoder that handles numpy and pandas types.
-
ViewerState–
NumpyEncoder
Bases: JSONEncoder
Custom JSON encoder that handles numpy and pandas types.
Converts numpy scalars, arrays, and pandas Series to native Python types for JSON serialization.
Methods:
-
default–Override default method to handle numpy types.
ViewerState(target_site=None, target_url=None, layers=None, dimensions=None, *, position=None, scale_imagery=1.0, scale_3d=50000.0, show_slices=False, selected_layer=None, selected_layer_visible=False, layout='xy-3d', base_state=None, interactive=False, infer_coordinates=True, client=None)
Parameters:
-
target_site(str, default:None) –The target site for the viewer. If None, the default site will be used.
-
target_url(str, default:None) –The target URL for the viewer. If None, the default URL will be used.
-
layers(list of Layer, default:None) –The layers to add to the viewer.
-
dimensions(list or CoordSpace, default:None) –The dimensions of the viewer. If None, the default dimensions will be used.
-
position(list or ndarray, default:None) –The position of the viewer in 3D space. If None, the default position will be used.
-
scale_imagery(float, default:1.0) –The scale factor for imagery layers. Default is 1.0.
-
scale_3d(float, default:50000.0) –The scale factor for 3D projections. Default is 50000.0.
-
show_slices(bool, default:False) –Whether to show cross-sectional slices in the viewer. Default is False.
-
selected_layer(str, default:None) –The name of the selected layer. If None, no layer is selected.
-
selected_layer_visible(bool, default:False) –Whether the selected layer is visible. Default is False.
-
layout(str, default:'xy-3d') –The panel layout of the viewer. Default is "xy-3d".
-
base_state(dict, default:None) –The base state of the viewer. If None, the default state will be used.
-
interactive(bool, default:False) –Whether the viewer is interactive. Default is False.
-
infer_coordinates(bool, default:True) –Whether to infer resolution and position from the source information using CloudVolume. Default is True.
-
client(CAVEclient, default:None) –A CAVE client to use for configuration. If provided, it will be used by default in functions that can accept it.
Methods:
-
add_annotation_layer–Add an annotation layer, either local or with precomputed annotation source
-
add_annotation_source–Add a precomputed annotation source to the viewer.
-
add_boxes–Add bounding box annotations to an existing annotation layer or create a new one.
-
add_ellipsoids–Add ellipsoid annotations to an existing annotation layer or create a new one.
-
add_image_layer–Add an image layer to the viewer.
-
add_layer–Add a layer to the viewer.
-
add_layers_from_client–Configure the viewer with information from a CaveClient.
-
add_lines–Add lines to an existing annotation layer or create a new one.
-
add_points–Add points to an existing annotation layer or create a new one.
-
add_raw_layer–Add a layer based on a raw state dictionary. Useful when copying existing layers, but offers limited customization.
-
add_segment_properties–Upload segment properties and add to the layer.
-
add_segmentation_layer–Add a segmentation layer to the viewer.
-
add_segments–Add segments directly to an existing segmentation layer.
-
add_segments_from_data–Add segments from a DataFrame or DataMap to an existing segmentation layer.
-
get_layer–Get a layer by name.
-
map–Apply a datamap to the viewer state to freeze the state of the viewer.
-
set_viewer_properties–Set various properties of the viewer state.
-
to_browser–Open the viewer state URL in a web browser.
-
to_clipboard–Copy the viewer state URL to the system clipboard.
-
to_dict–Return a dictionary representation of the viewer state.
-
to_json_string–Return a JSON string representation of the viewer state.
-
to_link–Return an HTML link representation of the viewer state.
-
to_link_shortener–Shorten the URL using the CAVE link shortener service.
-
to_url–Return a URL representation of the viewer state.
-
with_datamap–Context manager to apply datamaps.
Attributes:
-
viewer–Get the Neuroglancer viewer object.
viewer
property
Get the Neuroglancer viewer object.
add_annotation_layer(name='annotation', source=None, resolution=None, tags=None, linked_segmentation=True, shader=None, **kwargs)
Add an annotation layer, either local or with precomputed annotation source
Parameters:
-
name(str, default:'annotation') –Layer name, by default "annotation"
-
source(Optional[str], default:None) –Cloud annotation source path, if using. By default None
-
resolution(Optional[Union[list, ndarray]], default:None) –Layer resolution, only used by local annotation layers. By default None, where it is inferred from the viewer.
-
tags(Optional[list], default:None) –Ordered list of tags, by default None.
-
linked_segmentation(Union[str, bool], default:True) –If True, will link to the first segmentation layer found in the viewer. If False, will not link to any segmentation layer. If a string is provided, it will be used as the name of the segmentation layer to link to.
-
**kwargs(dict, default:{}) –Additional keyword arguments to pass to the annotation layer constructor.
Returns:
-
Self–The viewer state object with the added annotation layer.
add_annotation_source(source, name='annotation', linked_segmentation=True, shader=None)
Add a precomputed annotation source to the viewer.
Parameters:
-
source(str) –The source path for the annotation layer.
-
name(str, default:'annotation') –The name of the annotation layer, by default "annotation".
-
shader(Optional[str], default:None) –The shader to use for the annotation layer, by default None.
Returns:
-
Self–The viewer state object with the added annotation layer.
add_boxes(data=None, name='annotation', point_a_column=None, point_b_column=None, segment_column=None, description_column=None, tag_column=None, tag_bools=None, data_resolution=None, tags=None, linked_segmentation=True, shader=None, color=None, swap_visible_segments_on_move=True)
Add bounding box annotations to an existing annotation layer or create a new one.
Parameters:
-
data(DataFrame, default:None) –The DataFrame containing the bounding box annotations.
-
name(str, default:'annotation') –The name of the annotation layer, by default "annotation".
-
point_a_column(str, default:None) –The column name for the start point coordinates of the box.
-
point_b_column(str, default:None) –The column name for the end point coordinates of the box.
-
segment_column(Optional[str], default:None) –The name of the column containing linked segment IDs, by default None.
-
description_column(Optional[str], default:None) –The name of the column containing descriptions, by default None.
-
tag_column(Optional[str], default:None) –The name of a column containing tags, by default None.
-
tag_bools(Optional[list], default:None) –A list of column names indicating tags as booleans, by default None.
-
data_resolution(Optional[list], default:None) –The resolution of the data, by default None.
-
tags(Optional[list], default:None) –A list of tags to add to the annotation layer, by default None.
-
linked_segmentation(str or bool, default:True) –The name of the segmentation layer to link to, by default None. If True, will link to the first segmentation layer found in the viewer. If False, will not link to any segmentation layer.
-
shader(Optional[str], default:None) –The shader to use for the annotation layer, by default None.
-
color(Optional[str], default:None) –The color to use for the bounding boxes, by default None.
-
swap_visible_segments_on_move(bool, default:True) –If True, will swap the visibility of segments when moving boxes.
Returns:
-
Self–The viewer state object with the added bounding boxes.
add_ellipsoids(data=None, name='annotation', center_column=None, radii_column=None, segment_column=None, description_column=None, tag_column=None, tag_bools=None, data_resolution=None, tags=None, linked_segmentation=True, shader=None, color=None, swap_visible_segments_on_move=True)
Add ellipsoid annotations to an existing annotation layer or create a new one.
Parameters:
-
data(DataFrame, default:None) –The DataFrame containing the ellipsoid annotations.
-
name(str, default:'annotation') –The name of the annotation layer, by default "annotation".
-
center_column(str, default:None) –The column name for the ellipsoid center coordinates.
-
radii_column(str, default:None) –The column name for the ellipsoid radii.
-
segment_column(Optional[str], default:None) –The name of the column containing linked segment IDs, by default None.
-
description_column(Optional[str], default:None) –The name of the column containing descriptions, by default None.
-
tag_column(Optional[str], default:None) –The name of a column containing tags, by default None.
-
tag_bools(Optional[list], default:None) –A list of column names indicating tags as booleans, by default None.
-
data_resolution(Optional[list], default:None) –The resolution of the data, by default None.
-
tags(Optional[list], default:None) –A list of tags to add to the annotation layer, by default None.
-
linked_segmentation(str or bool, default:True) –The name of the segmentation layer to link to, by default None. If True, will link to the first segmentation layer found in the viewer. If False, will not link to any segmentation layer.
-
shader(Optional[str], default:None) –The shader to use for the annotation layer, by default None.
-
color(Optional[str], default:None) –The color to use for the ellipsoids, by default None.
-
swap_visible_segments_on_move(bool, default:True) –If True, will swap the visibility of segments when moving ellipsoids.
Returns:
-
Self–The viewer state object with the added ellipsoids.
add_image_layer(source, name='imagery', resolution=None, **kwargs)
Add an image layer to the viewer.
Parameters:
-
source(str) –The source path for the image layer.
-
name(str, default:'imagery') –The name of the image layer, by default "imagery".
-
resolution(Optional[Union[list, ndarray]], default:None) –The resolution of the image layer. If None, the viewer's current resolution will be used or it will be inferred from the source (if cloud-volume is installed).
-
**kwargs(dict, default:{}) –Additional keyword arguments to pass to the image layer constructor.
add_layer(layers, selected=False)
Add a layer to the viewer.
Parameters:
-
layers(Layer or list of Layer) –The layer(s) to add to the viewer.
add_layers_from_client(client=None, imagery=True, segmentation=True, skeleton_source=True, resolution=True, target_url=False, selected_alpha=None, alpha_3d=None, mesh_silhouette=None, imagery_kws=None, segmentation_kws=None)
Configure the viewer with information from a CaveClient. Can set the target URL, viewer resolution, and add image and segmentation layers.
Parameters:
-
client(CAVEclient, default:None) –The client to use for configuration. If None, will use the client set in the viewer state if allowed.
-
imagery(Union[bool, str], default:True) –Whether to add an image layer, by default True. If a string is provided, it will be used as the name of the layer.
-
segmentation(Union[bool, str], default:True) –Whether to add a segmentation layer, by default True If a string is provided, it will be used as the name of the layer.
-
skeleton_source(bool, default:True) –Whether to try to add a skeleton source for the segmentation layer, if provided, by default True
-
resolution(bool, default:True) –Whether to infer viewer resolution from the client info, by default True
-
target_url(bool, default:False) –Whether to set the neuroglancer URL from the client, by default False
-
selected_alpha(Optional[float], default:None) –The alpha value for the segmentation layer, by default None.
-
alpha_3d(Optional[float], default:None) –The alpha value for 3D meshes, by default None.
-
mesh_silhouette(Optional[float], default:None) –The mesh silhouette value, by default None.
-
imagery_kws(Optional[dict], default:None) –Additional keyword arguments to pass to the image layer constructor.
-
segmentation_kws(Optional[dict], default:None) –Additional keyword arguments to pass to the segmentation layer constructor.P
Returns:
-
Self–The updated viewer state object.
add_lines(data=None, name='annotation', point_a_column=None, point_b_column=None, segment_column=None, description_column=None, tag_column=None, tag_bools=None, data_resolution=None, tags=None, linked_segmentation=True, shader=None, color=None, swap_visible_segments_on_move=True)
Add lines to an existing annotation layer or create a new one.
Parameters:
-
data(DataFrame, default:None) –The DataFrame containing the line annotations or a tuple of (start_points, end_points) as Nx3 arrays.
-
name(str, default:'annotation') –The name of the annotation layer, by default "annotation".
-
point_a_column(str, default:None) –The column name for the start point coordinates. If you have a split point representation in the format {prefix}_x, {prefix}_y, {prefix}_z, you can specify this with "prefix" only and the suffixes will be ignored. If you provide a list, they will be used explicitly as the x,y, and z columns.
-
point_b_column(str, default:None) –The column name for the end point coordinates, formatted similarly as
point_a_column. -
segment_column(Optional[str], default:None) –The name of the column containing linked segment IDs, by default None.
-
description_column(Optional[str], default:None) –The name of the column containing descriptions, by default None.
-
tag_column(Optional[str], default:None) –The name of a column containing tags, by default None.
-
tag_bools(Optional[list], default:None) –A list of column names indicating tags as booleans, by default None.
-
data_resolution(Optional[list], default:None) –The resolution of the data, by default None.
-
tags(Optional[list], default:None) –A list of tags to add to the annotation layer, by default None.
-
linked_segmentation(str or bool, default:True) –The name of the segmentation layer to link to, by default None. If True, will link to the first segmentation layer found in the viewer. If False, will not link to any segmentation layer.
-
shader(Optional[str], default:None) –The shader to use for the annotation layer, by default None.
-
color(Optional[str], default:None) –The color to use for the lines, by default None.
-
swap_visible_segments_on_move(bool, default:True) –If True, will swap the visibility of segments when moving lines.
Returns:
-
Self–The viewer state object with the added lines.
add_points(data=None, name='annotation', point_column=None, segment_column=None, description_column=None, tag_column=None, tag_bools=None, data_resolution=None, tags=None, linked_segmentation=True, shader=None, color=None, swap_visible_segments_on_move=True)
Add points to an existing annotation layer or create a new one.
Parameters:
-
data(Union[list, ndarray, DataFrame], default:None) –The data to add to the annotation layer.
-
name(str, default:'annotation') –The name of the annotation layer, by default "annotation".
-
point_column(Optional[Union[str, list]] = None,, default:None) –The name of the column containing point coordinates, by default None. If you have a split point representation in the format {prefix}_x, {prefix}_y, {prefix}_z, you can specify this with "prefix" only and the suffixes will be ignored. If you provide a list, they will be used explicitly as the x,y, and z columns. None is needed if the data is an array, but is required if the data is a DataFrame.
-
segment_column(Optional[str], default:None) –The name of the column containing linked segment IDs, by default None.
-
description_column(Optional[str], default:None) –The name of the column containing descriptions, by default None. If None, no descriptions will be added.
-
tag_column(Optional[str], default:None) –The name of a column containing tags, by default None.
-
tag_bools(Optional[list], default:None) –A list of column names indicating tags as booleans, by default None.
-
data_resolution(Optional[list], default:None) –The resolution of the data, by default None. If None, the viewer's current resolution will be used.
-
tags(Optional[list], default:None) –A list of tags to add to the annotation layer, by default None. If None, tags will be inferred from the data, if any tag columns are provided.
-
linked_segmentation(str or bool, default:True) –The name of the segmentation layer to link to, by default None. If True, will link to the first segmentation layer found in the viewer. If False, will not link to any segmentation layer.
-
shader(Optional[str], default:None) –The shader to use for the annotation layer, by default None. If None, the default shader will be used.
-
swap_visible_segments_on_move(bool, default:True) –If True, will swap the visibility of segments when moving points.
Returns:
-
Self–The viewer state object with the added points.
add_raw_layer(data, name=None, visible=None, archived=None, source_remap=None)
Add a layer based on a raw state dictionary. Useful when copying existing layers, but offers limited customization.
Parameters:
-
data(dict) –The raw state dictionary for the layer.
-
name(str, default:None) –The new name of the layer, if you want to change it.
-
visible(bool, default:None) –Whether the layer is visible, if you want to change it.
-
archived(bool, default:None) –Whether the layer is archived, if you want to change it.
-
source_remap(Optional[dict], default:None) –A dictionary mapping source cloudpaths to new cloudpaths, for example to update the layer's data source without changing anything else.
Returns:
-
Self–The updated viewer state object.
add_segment_properties(data, id_column='pt_root_id', client=None, label_column=None, description_column=None, string_columns=None, number_columns=None, tag_value_columns=None, tag_bool_columns=None, tag_descriptions=None, allow_disambiguation=True, label_separator='_', label_format_map=None, prepend_col_name=False, random_columns=None, random_column_prefix=None, dry_run=False, name=None)
Upload segment properties and add to the layer.
If you already have a segment properties cloud path, use add_source to add it to the layer.
Parameters:
-
data(DataFrame) –The DataFrame containing the segment properties.
-
id_column(str, default:'pt_root_id') –The column name for the segment IDs. Default is 'pt_root_id'.
-
client(CAVEclient, default:None) –The CAVEclient object needed to upload .
-
label_column(str or list, default:None) –The column name(s) for the segment labels. Default is None.
-
description_column(str, default:None) –The column name for the segment descriptions. Default is None.
-
string_columns(list, default:None) –The column names for string properties. Default is None.
-
number_columns(list, default:None) –The column names for number properties. Default is None.
-
tag_value_columns(list, default:None) –The column names for tag value properties. Default is None.
-
tag_bool_columns(list, default:None) –The column names for tag boolean properties. Default is None.
-
tag_descriptions(list, default:None) –The descriptions for the tags. Default is None.
-
allow_disambiguation(bool, default:True) –Whether to allow disambiguation of segment IDs. Default is True.
-
label_separator(str, default:'_') –The separator for label formatting. Default is "_".
-
label_format_map(str, default:None) –The format map for labels. Default is None.
-
prepend_col_name(bool, default:False) –Whether to prepend the column name to the label. Default is False.
-
random_columns(Optional[int], default:None) –Number of random columns to add. Default is None.
-
random_column_prefix(str, default:None) –Name prefix of the random columns. Default is None.
-
dry_run(bool, default:False) –If dry run is true, build but do not actually upload and instead use a placeholder source text. Default is False.
-
name(Optional[str], default:None) –Layer name. Must be specified if there is more than one segmentation layer in the state.
Returns:
-
Self–
add_segmentation_layer(source, name='segmentation', resolution=None, segments=None, **kwargs)
Add a segmentation layer to the viewer.
Parameters:
-
source(str) –The source path for the segmentation layer.
-
name(str, default:'segmentation') –The name of the segmentation layer, by default "segmentation".
-
resolution(Optional[Union[list, ndarray]], default:None) –The resolution of the segmentation layer. If None, the viewer's current resolution will be used or it will be inferred from the source (if cloud-volume is installed).
-
segments(Optional[list], default:None) –A list of segments to set as selected in the segmentation layer.
-
**kwargs(dict, default:{}) –Additional keyword arguments to pass to the segmentation layer constructor.
add_segments(segments, visible=None, segment_colors=None, name=None)
Add segments directly to an existing segmentation layer. By default, it will use the first segmentation layer found in the viewer, otherwise you must specify a layer name.
Parameters:
-
segments(list or dict or VisibleSegments) –The segments to add. If a dict, the keys are the segment IDs and the values are the boolean visibility.
-
visible(Optional[Union[list, ndarray]], default:None) –The visibility of the segments, assumed to be True if not provided. Should be the same length as segments, and segments should be a list of the same length.
-
segment_colors(Union[str, list, dict], default:None) –The color(s) to assign to the segments. If a string or list, all segments will be assigned the same color. A list is assumed to be a color tuple. If a dict, the keys are segment IDs and the values are colors.
-
name(Optional[str], default:None) –The name of the segmentation layer to add segments to. If None, it will use the first segmentation layer found in the viewer.
Returns:
-
The viewer state object with the added segments.–
add_segments_from_data(data, segment_column, visible_column=None, color_column=None, name=None)
Add segments from a DataFrame or DataMap to an existing segmentation layer. By default, it will use the first segmentation layer found in the viewer, otherwise you must specify a layer name.
Parameters:
-
data(Union[DataFrame, DataMap]) –The data containing segment information or a datamap to be filled in later
-
segment_column(str) –The name of the column containing segment IDs in the DataFrame.
-
visible_column(str, default:None) –The name of the column containing visibility information in the DataFrame. If not provided, all segments will be considered visible.
-
color_column(str, default:None) –The name of the column containing color information for the segments.
-
name(Optional[str], default:None) –The name of the segmentation layer to add segments to. If None, it will use the first segmentation layer found in the viewer.
get_layer(name)
map(datamap, inplace=False)
Apply a datamap to the viewer state to freeze the state of the viewer. Must be used if any layers use a datamap. By default, this will return a new viewer state with the datamap applied without changing the current object.
Parameters:
-
datamap(dict) –A dictionary mapping layer names to their corresponding datamaps.
-
inplace(bool, default:False) –If True, apply the datamap in place and return the modified viewer state. If False, return a new viewer state with the datamap applied.
Returns:
-
Self–A new ViewerState object with the datamap applied.
set_viewer_properties(position=None, dimensions=None, scale_imagery=None, scale_3d=None, show_slices=None, selected_layer=None, selected_layer_visible=None, layout=None, base_state=None, interactive=None, infer_coordinates=False)
Set various properties of the viewer state.
This function allows you to configure the viewer's position, dimensions, scale, layout, and other properties. Any property not explicitly set will remain unchanged.
Parameters:
-
position(list or ndarray, default:None) –The position of the viewer in 3D space.
-
dimensions(list or ndarray, default:None) –The dimensions of the viewer's coordinate space. Can be either a list of 3 values treated as nanometer resolution or a CoordSpace object with more detailed options.
-
scale_imagery(float, default:None) –The scale factor for imagery layers.
-
scale_3d(float, default:None) –The scale factor for 3D projections.
-
show_slices(bool, default:None) –Whether to show cross-sectional slices in the viewer.
-
selected_layer(str or ImageLayer, default:None) –The name of the selected layer or the layer object itself.
-
selected_layer_visible(bool, default:None) –Whether the selected layer is visible.
-
layout(('xy', 'yz', 'xz', 'xy-3d', 'xz-3d', 'yz-3d', '4panel', '3d', '4panel-alt'), default:"xy") –The panel layout of the viewer.
-
base_state(dict, default:None) –The base state of the viewer.
-
interactive(bool, default:None) –Whether the viewer is interactive.
-
infer_coordinates(bool, default:False) –Whether to infer resolution and position from the source information. If True, the viewer will attempt to extract this information from the info provided by the source if not provided explicitly.
Returns:
-
self–The updated viewer state object.
to_browser(target_url=None, target_site=None, shorten=False, client=None, new=2, autoraise=True, browser=None)
Open the viewer state URL in a web browser.
Parameters:
-
target_url(str, default:None) –The base URL to use for the Neuroglancer state. If not provided, the default server URL will be used.
-
target_site(str, default:None) –The target site for the URL, based on the keys in site_utils.NEUROGLANCER_SITES. If not provided, the default server URL will be used.
-
shorten(Union[bool, Literal['if_long']], default:False) –If True, the URL will be shortened using the CAVE link shortener service. If "if_long", the URL will only be shortened if it exceeds a certain length.
-
client(Optional[CAVEclient], default:None) –The CAVE client to use for shortening the URL. If not provided, the URL will not be shortened.
-
new(int, default:2) –If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (“tab”) is opened if possible. Note that not all browsers support all values of new, and some may ignore this parameter.
-
autoraise(bool, default:True) –If True, the browser window will be raised to the front when opened. Note that under many window managers this will occur regardless of the setting of this variable.
-
browser(Optional[str], default:None) –The name of the browser to use. If None, the system default browser will be used. Note that the browser name needs to be registered on your system, see webbrowser.register for more details.
See Also
webbrowser.open : Opens a URL in the web browser.
Returns:
-
str–The URL representation of the viewer state that has also been opened in the browser.
to_clipboard(target_url=None, target_site=None, shorten=False, client=None)
Copy the viewer state URL to the system clipboard.
Parameters:
-
target_url(str, default:None) –The base URL to use for the Neuroglancer state. If not provided, the default server URL will be used.
-
target_site(str, default:None) –The target site for the URL, based on the keys in site_utils.NEUROGLANCER_SITES. If not provided, the default server URL will be used.
-
shorten(Union[bool, Literal['if_long']], default:False) –If True, the URL will be shortened using the CAVE link shortener service. If "if_long", the URL will only be shortened if it exceeds a certain length.
-
client(Optional[CAVEclient], default:None) –The CAVE client to use for shortening the URL. If not provided, the URL will not be shortened.
Returns:
-
str–The URL representation of the viewer state that has also been copied to the clipboard.
to_dict()
Return a dictionary representation of the viewer state.
Returns:
-
dict–A dictionary representation of the viewer state.
to_json_string(indent=2, compact=False)
Return a JSON string representation of the viewer state.
Parameters:
-
indent(int, default:2) –The number of spaces to use for indentation in the JSON string. Default is 2.
-
compact(bool, default:False) –If True, the JSON string will be compact with no extra whitespace or newlines. Default is False.
Returns:
-
str–A JSON string representation of the viewer state.
to_link(target_url=None, target_site=None, link_text='Neuroglancer Link', shorten=False, client=None)
Return an HTML link representation of the viewer state.
Parameters:
-
target_url(str, default:None) –The base URL to use for the Neuroglancer state. If not provided, the default server URL will be used.
-
target_site(str, default:None) –The target site for the URL, based on the keys in site_utils.NEUROGLANCER_SITES. If not provided, the default server URL will be used.
-
link_text(str, default:'Neuroglancer Link') –The text to display for the HTML link.
-
shorten(Union[bool, Literal['if_long']], default:False) –If True, the URL will be shortened using the CAVE link shortener service. If "if_long", the URL will only be shortened if it exceeds a certain length.
-
client(Optional[CAVEclient], default:None) –The CAVE client to use for shortening the URL. If not provided, the URL will not be shortened.
Returns:
-
HTML–An HTML link representation of the viewer state.
to_link_shortener(client=None, target_url=None, target_site=None)
Shorten the URL using the CAVE link shortener service.
Parameters:
-
client(CAVEclient, default:None) –The CAVE client to use for shortening the URL.
-
target_url(str, default:None) –The base URL to use for the Neuroglancer state. If not provided, the default server URL will be used.
-
target_site(str, default:None) –The target site for the URL, based on the keys in site_utils.NEUROGLANCER_SITES. If not provided, the default server URL will be used.
Returns:
-
str–A shortened URL representation of the viewer state.
to_url(target_url=None, target_site=None, shorten=False, client=None)
Return a URL representation of the viewer state.
Parameters:
-
target_url(str, default:None) –The base URL to use for the Neuroglancer state. If not provided, the default server URL will be used.
-
target_site(str, default:None) –The target site for the URL, based on the keys in site_utils.NEUROGLANCER . If not provided, the default server URL will be used.
-
shorten(Union[bool, Literal['if_long']], default:False) –If True, the URL will be shortened using the CAVE link shortener service. If "if_long", the URL will only be shortened if it exceeds a certain length.
-
client(Optional[CAVEclient], default:None) –The CAVE client to use for shortening the URL. If not provided, the URL will not be shortened.
Returns:
-
str–A URL representation of the viewer state.
with_datamap(datamap)
Context manager to apply datamaps.