State Parser
annotation_dataframe(state, expand_tags=False)
Return all annotations across all annotation layers in the state.
Parameters:
-
state
(dict
) –Neuroglancer state dictionary
-
expand_tags
(bool
, default:False
) –If True, expand tags into separate boolean columns named by the tag label. By default False. Note that if tag labels are duplicated in multiple layers, the values will appear in the same column.
Returns:
-
DataFrame
–Dataframe with columns layer, anno_type, point, pointB, linked_segmentation, tags, anno_id, group_id, description. If expand_tags is True, an additional column will be added for each tag.
annotation_layers(state)
bbox_annotations(state, layer_name, description=False, linked_segmentations=False, tags=False, group=False)
Get all bounding box annotation points and other info from a layer.
Parameters:
-
state
(dict
) –Neuroglancer state as JSON dict
-
layer_name
(str
) –Layer name
-
description
(bool
, default:False
) –If True, also returns descriptions as well. By default False
-
linked_segmentations
(bool
, default:False
) –If True, also returns list of linked segmentations, by default False
-
tags
(bool
, default:False
) –If True, also returns list of tags, by default False
Returns:
-
anno_points_A
(list
) –List of N 3-element points (as list) of the first point in each bbox.
-
anno_points_B
(list
) –List of N 3-element points (as list) of the second point in each bbox.
-
anno_descriptions
(list
) –List of N strings (or None), only returned if description=True.
-
anno_linked_segmentations
(list
) –List of N lists of object ids. Only returned if linked_segmentations=True.
-
anno_tags
(list
) –List of N lists of tag ids. Only returned if tags=True.
-
anno_group
(list
) –List of group ids (as string) or None for annotations. Only returned if group=True
extract_multicut(state, seg_layer=None)
Extract information entered into the multicut graph operation
Parameters:
-
state
(dict
) –Neuroglancer state
-
seg_layer
(str
, default:None
) –Name of a segmentation layer or None. If None, the function will check how many segmentation layers there are and, if only one exits, choose it. If more than one segmentation layer is present, it errors. By default None
Returns:
-
pts
(array
) –Nx3 array of points selected
-
side
(array
) –N array with 'source' or 'sink', depending on which side the point is on.
-
svids
(array
) –N array with selected supervoxel. If only points are selected (e.g. via clicking on the mesh), the value will be NaN.
-
root_id
(int
) –Root id of the object to split
get_layer(state, layer_name)
get_selected_ids(state, layer=None)
group_annotations(state, layer_name, description=False, linked_segmentations=False, tags=False)
All group annotations and their associated points
Parameters:
-
state
(dict
) –Neuroglancer state as JSON dict
-
layer_name
(str
) –Annotation layer name
-
description
(bool
, default:False
) –If True, also returns descriptions as well. By default False
-
linked_segmentations
(bool
, default:False
) –If True, also returns list of linked segmentations, by default False
-
tags
(bool
, default:False
) –If True, also returns list of tags, by default False
Returns:
-
group_points
(list
) –List of N 3-element points
-
group_id
(list
) –List of N id strings for groups.
-
anno_descriptions
(list
) –List of N strings (or None), only returned if description=True.
-
anno_linked_segmentations
(list
) –List of N lists of object ids. Only returned if linked_segmentations=True.
-
anno_tags
(list
) –List of N lists of tag ids. Only returned if tags=True.
image_layers(state)
layer_names(state)
line_annotations(state, layer_name, description=False, linked_segmentations=False, tags=False, group=False)
Get all line annotation points and other info from a layer.
Parameters:
-
state
(dict
) –Neuroglancer state as JSON dict
-
layer_name
(str
) –Layer name
-
description
(bool
, default:False
) –If True, also returns descriptions as well. By default False
-
linked_segmentations
(bool
, default:False
) –If True, also returns list of linked segmentations, by default False
-
tags
(bool
, default:False
) –If True, also returns list of tags, by default False
Returns:
-
anno_points_A
(list
) –List of N 3-element points (as list) of the first point in each line.
-
anno_points_B
(list
) –List of N 3-element points (as list) of the second point in each line.
-
anno_descriptions
(list
) –List of N strings (or None), only returned if description=True.
-
anno_linked_segmentations
(list
) –List of N lists of object ids. Only returned if linked_segmentations=True.
-
anno_tags
(list
) –List of N lists of tag ids. Only returned if tags=True.
-
anno_group
(list
) –List of group ids (as string) or None for annotations. Only returned if group=True
point_annotations(state, layer_name, description=False, linked_segmentations=False, tags=False, group=False)
Get all point annotation points and other info from a layer.
Parameters:
-
state
(dict
) –Neuroglancer state as JSON dict
-
layer_name
(str
) –Layer name
-
description
(bool
, default:False
) –If True, also returns descriptions as well. By default False
-
linked_segmentations
(bool
, default:False
) –If True, also returns list of linked segmentations, by default False
-
tags
(bool
, default:False
) –If True, also returns list of tags, by default False
Returns:
-
anno_points
(list
) –List of N 3-element points (as list)
-
anno_descriptions
(list
) –List of N strings (or None), only returned if description=True.
-
anno_linked_segmentations
(list
) –List of N lists of object ids. Only returned if linked_segmentations=True.
-
anno_tags
(list
) –List of N lists of tag ids. Only returned if tags=True.
-
anno_group
(list
) –List of group ids (as string) or None for annotations. Only returned if group=True
segmentation_layers(state)
sphere_annotations(state, layer_name, description=False, linked_segmentations=False, tags=False, group=False)
Get all sphere annotation points and other info from a layer.
Parameters:
-
state
(dict
) –Neuroglancer state as JSON dict
-
layer_name
(str
) –Layer name
-
description
(bool
, default:False
) –If True, also returns descriptions as well. By default False
-
linked_segmentations
(bool
, default:False
) –If True, also returns list of linked segmentations, by default False
-
tags
(bool
, default:False
) –If True, also returns list of tags, by default False
Returns:
-
anno_points
(list
) –List of N 3-element center points (as list)
-
radius_points
(list
) –List of N 3-element radii for each axis of the ellipsoid.
-
anno_descriptions
(list
) –List of N strings (or None), only returned if description=True.
-
anno_linked_segmentations
(list
) –List of N lists of object ids. Only returned if linked_segmentations=True.
-
anno_tags
(list
) –List of N lists of tag ids. Only returned if tags=True.
-
anno_group
(list
) –List of group ids (as string) or None for annotations. Only returned if group=True
tag_dictionary(state, layer_name)
view_settings(state)
Get all data about the view state in neuroglancer: position, image zoom, orientation and zoom of the 3d view, and voxel size.
Parameters:
-
state
(dict
) –Neuroglancer state as JSON dict
Returns:
-
view
(dict
) –Dictionary with keys: position, zoomFactor, perspectiveOrientation, perspectiveZoom, and voxelSize