statebuilder.helpers
Functions:
-
make_connectivity_state_map–Create a Neuroglancer state with input and output synapses.
-
make_line_state–Generate a state builder that puts line segments from two columns with a linked segmentaton id
-
make_neuron_neuroglancer_link–Create a Neuroglancer state with a neuron and optionally its inputs and outputs.
-
make_point_state–Generate a state builder that puts points on a single column with a linked segmentaton id
-
sort_dataframe_by_root_id–Sort a dataframe so that rows belonging to the same root id are together, ordered by how many times the root id appears.
make_connectivity_state_map(client, show_inputs=True, show_outputs=True, point_column='ctr_pt_position', input_root_id_col='pre_pt_root_id', output_root_id_col='post_pt_root_id', dataframe_resolution_input=None, dataframe_resolution_output=None, input_layer_name='syns_in', output_layer_name='syns_out', input_layer_color=DEFAULT_POSTSYN_COLOR, output_layer_color=DEFAULT_PRESYN_COLOR, input_shader=True, output_shader=True, selected_alpha=None, alpha_3d=None, mesh_silhouette=None)
Create a Neuroglancer state with input and output synapses.
Parameters:
-
client(CAVEclient) –CAVEclient configured for the datastack desired
-
show_inputs(bool, default:True) –Whether to show input synapses, by default True
-
show_outputs(bool, default:True) –Whether to show output synapses, by default True
-
point_column(str, default:'ctr_pt_position') –Column in the dataframe to use for point positions, by default "ctr_pt_position"
-
input_root_id_col(str, default:'pre_pt_root_id') –Column in the dataframe to use for input synapse root ids, by default "pre_pt_root_id"
-
output_root_id_col(str, default:'post_pt_root_id') –Column in the dataframe to use for output synapse root ids, by default "post_pt_root_id"
-
dataframe_resolution_input(Optional[list], default:None) –Resolution of the input dataframe, by default None
-
dataframe_resolution_output(Optional[list], default:None) –Resolution of the output dataframe, by default None
-
input_layer_name(str, default:'syns_in') –Name of the input layer, by default "syns_in"
-
output_layer_name(str, default:'syns_out') –Name of the output layer, by default "syns_out"
-
input_layer_color(Union[tuple, str], default:DEFAULT_POSTSYN_COLOR) –Color of the input layer, by default "turquoise"
-
output_layer_color(Union[tuple, str], default:DEFAULT_PRESYN_COLOR) –Color of the output layer, by default "tomato"
-
input_shader(Optional[Union[bool, str]], default:True) –Shader to use for input synapses, by default None.
-
output_shader(Optional[Union[bool, str]], default:True) –Shader to use for output synapses, by default None (uses default shader)
-
selected_alpha(Optional[float], default:None) –Alpha value for selected segments in the 2d view, by default None (uses default value)
-
alpha_3d(Optional[float], default:None) –Alpha value for meshes, by default None (uses default value)
-
mesh_silhouette(Optional[float], default:None) –Mesh silhouette value, by default None (uses default value)
Returns:
-
ViewerState–A Neuroglancer ViewerState with input and output synapses configured.
make_line_state(client, data=None, point_a_column='pre_pt_position', point_b_column='post_pt_position', segment_column='pt_root_id', description_column=None, tag_column=None, data_resolution=None, tags=None, layer_name='lines', shader=True, selected_alpha=None, alpha_3d=None, mesh_silhouette=None)
Generate a state builder that puts line segments from two columns with a linked segmentaton id
Parameters:
-
client(CAVEclient) –CAVEclient configured for the datastack desired
-
data(Optional[DataFrame], default:None) –Dataframe to use for points, by default None. If None, a simple DataMap will be used with no key. Fill in the resulting state with viewer.map(df).
-
point_a_column(str, default:'pre_pt_position') –Column in the dataframe to use for line start positions, by default "pre_pt_position"
-
point_b_column(str, default:'post_pt_position') –Column in the dataframe to use for line end, by default "post_pt_position"
-
segment_column(str, default:'pt_root_id') –Column in the dataframe to use for segment ids, by default "pt_root_id"
-
description_column(Optional[str], default:None) –Column in the dataframe to use for point descriptions, by default None
-
tag_column(Optional[str], default:None) –Column in the dataframe to use for tags, by default None
-
data_resolution(Optional[list], default:None) –Resolution of the data, by default None
-
tags(Optional[list], default:None) –List of tags to apply to the points, by default None
-
layer_name(str, default:'lines') –Name of the layer to create, by default "Points"
-
shader(Optional[Union[bool, str]], default:True) –Shader to use for the points, by default True (uses default shader)
-
selected_alpha(Optional[float], default:None) –Alpha value for selected segments in the 2D view, by default None (uses default value)
-
alpha_3d(Optional[float], default:None) –Alpha value for meshes, by default None (uses default value)
-
mesh_silhouette(Optional[float], default:None) –Mesh silhouette value, by default None (uses default value)
Returns:
-
ViewerState(ViewerState) –A viewerstate to make points with linked segmentations
make_neuron_neuroglancer_link(client, root_ids, return_as='link', shorten='if_long', show_inputs=True, show_outputs=True, point_column='ctr_pt_position', target_url=None, target_site=None, timestamp=None, infer_coordinates=True)
Create a Neuroglancer state with a neuron and optionally its inputs and outputs.
Parameters:
-
client(CAVEclient) –CAVEclient configured for the datastack desired
-
root_ids(Union[int, list[int]]) –Root IDs of the neuron to visualize. Can be a single ID or a list of IDs.
-
return_as(Literal['link', 'dict', 'json', 'url'], default:'link') –Format to return the Neuroglancer state, by default "link". Options are "link", "dict", "json", or "url".
-
shorten(Literal['never', 'always', 'if_long'], default:'if_long') –Whether to shorten the URL if it is long, by default "if_long". Options are "never", "always", or "if_long".
-
show_inputs(bool, default:True) –Whether to show input synapses, by default True
-
show_outputs(bool, default:True) –Whether to show output synapses, by default True
-
point_column(str, default:'ctr_pt_position') –Column in the dataframe to use for point positions, by default "ctr_pt_position"
-
target_url(Optional[str], default:None) –Target URL to use for the Neuroglancer link, by default None. If None, the default CAVEclient URL will be used.
-
target_site(Optional[str], default:None) –Target site to use for the Neuroglancer link, by default None. If None, the default CAVEclient site will be used.
-
timestamp(Optional[datetime], default:None) –Timestamp to use for the query, by default None. If None, the current time will be used.
-
infer_coordinates(bool, default:True) –Whether to infer coordinates from the data, by default True.
Returns:
-
Neuroglancer state in the specified format.–
make_point_state(client, data=None, point_column='pt_position', segment_column='pt_root_id', description_column=None, tag_column=None, data_resolution=None, tags=None, layer_name='Points', shader=True, selected_alpha=None, alpha_3d=None, mesh_silhouette=None)
Generate a state builder that puts points on a single column with a linked segmentaton id
Parameters:
-
client(CAVEclient) –CAVEclient configured for the datastack desired
-
data(Optional[DataFrame], default:None) –Dataframe to use for points, by default None. If None, a simple DataMap will be used with no key. Fill in the resulting state with viewer.map(df).
-
point_column(str, default:'pt_position') –Column in the dataframe to use for point positions, by default "pt_position"
-
segment_column(str, default:'pt_root_id') –Column in the dataframe to use for segment ids, by default "pt_root_id"
-
description_column(Optional[str], default:None) –Column in the dataframe to use for point descriptions, by default None
-
tag_column(Optional[str], default:None) –Column in the dataframe to use for tags, by default None
-
data_resolution(Optional[list], default:None) –Resolution of the data, by default None
-
tags(Optional[list], default:None) –List of tags to apply to the points, by default None
-
layer_name(str, default:'Points') –Name of the layer to create, by default "Points"
-
shader(Optional[Union[bool, str]], default:True) –Shader to use for the points, by default True (uses default shader)
-
selected_alpha(Optional[float], default:None) –Alpha value for selected segments in the 2D view, by default None (uses default value)
-
alpha_3d(Optional[float], default:None) –Alpha value for meshes, by default None (uses default value)
-
mesh_silhouette(Optional[float], default:None) –Mesh silhouette value, by default None (uses default value)
Returns:
-
ViewerState(ViewerState) –A viewerstate to make points with linked segmentations
sort_dataframe_by_root_id(df, root_id_column, ascending=False, num_column='n_times', drop=False)
Sort a dataframe so that rows belonging to the same root id are together, ordered by how many times the root id appears.
Parameters:
-
df(DataFrame) –dataframe to sort
-
root_id_column(str) –Column name to use for sorting root ids
-
ascending(bool, default:False) –Whether to sort ascending (lowest count to highest) or not, by default False
-
num_column(str, default:'n_times') –Temporary column name to use for count information, by default 'n_times'
-
drop(bool, default:False) –If True, drop the additional column when returning.
Returns: