pcg_skel
Basic functions for generating chunk-resolution skeletons from a pychunkedgraph.
pcg_graph(root_id, client, cv=None, return_l2dict=False, nan_rounds=10, require_complete=False, level2_graph=None)
¶
Compute the level 2 spatial graph (or mesh) of a given root id using the l2cache.
Parameters:
-
root_id
(int
) –Root id of a segment
-
client
(caveclient
) –Initialized CAVEclient for the dataset.
-
cv
(CloudVolume
, default:None
) –Initialized CloudVolume object for the dataset. This does not replace the caveclient, but a pre-initizialized cloudvolume can save some time during batch processing.
-
return_l2dict
(bool
, default:False
) –If True, returns the mappings between l2 ids and vertices.
-
nan_rounds
(int
, default:10
) –If vertices are missing (or not computed), this sets the number of iterations for smoothing over them.
-
require_complete
(bool
, default:False
) –If True, raise an Exception if any vertices are missing from the cache.
-
level2_graph
(ndarray
, default:None
) –Level 2 graph for the root id as returned by client.chunkedgraph.level2_chunk_graph. A list of lists of edges between level 2 chunks, as defined by their chunk ids. If None, will query the chunkedgraph for the level 2 graph. Optional, by default None.
Returns:
-
mesh
(Mesh
) –Object with a vertex for every level 2 id and edges between all connected level 2 chunks.
-
l2dict
((dict, optional)
) –Dictionary with keys as level 2 ids and values as mesh vertex index. Optional, only returned if
return_l2dict
is True. -
l2dict_reverse
((dict, optional)
) –Dictionary with keys as mesh vertex indices and values as level 2 id. Optional, only returned if
return_l2dict
is True.
pcg_skeleton(root_id, client, datastack_name=None, cv=None, invalidation_d=7500, return_mesh=False, return_l2dict=False, return_l2dict_mesh=False, root_point=None, root_point_resolution=None, collapse_soma=False, collapse_radius=7500, nan_rounds=10, require_complete=False, level2_graph=None)
¶
Produce a skeleton from the level 2 graph.
Parameters:
-
root_id
(int
) –Root id of a segment
-
client
(CAVEclientFull
) –Initialized CAVEclient for the dataset.
-
datastack_name
(string
, default:None
) –If client is None, initializes a CAVEclient at this datastack.
-
cv
(CloudVolume
, default:None
) –Initialized CloudVolume object for the dataset. This does not replace the caveclient, but a pre-initizialized cloudvolume can save some time during batch processing.
-
invalidation_d
(int
, default:7500
) –Distance (in nanometers) for TEASAR skeleton invalidation.
-
return_mesh
(bool
, default:False
) –If True, returns the mesh graph as well as the skeleton.
-
return_l2dict
(bool
, default:False
) –If True, returns the mappings between l2 ids and skeleton vertices.
-
return_l2dict_mesh
(bool
, default:False
) –If True, returns mappings between l2 ids and mesh graph vertices.
-
root_point
(ArrayLike
, default:None
) –3-element list or array with the x,y,z location of the root point. If None, the most distant tip is set to root.
-
root_point_resolution
(ArrayLike
, default:None
) –3-element list or array with the x,y,z resolution of the root point, in nanometers per voxel dimension.
-
collapse_soma
(bool
, default:False
) –If True, collapse nearby vertices into the root point.
-
collapse_radius
(int
, default:7500
) –Distance (in nanometers) for soma collapse.
-
nan_rounds
(int
, default:10
) –If vertices are missing (or not computed), this sets the number of iterations for smoothing over them.
-
require_complete
(bool
, default:False
) –If True, raise an Exception if any vertices are missing from the cache.
-
level2_graph
(ndarray
, default:None
) –Level 2 graph for the root id as returned by client.chunkedgraph.level2_chunk_graph. A list of lists of edges between level 2 chunks, as defined by their chunk ids. If None, will query the chunkedgraph for the level 2 graph. Optional, by default None.
Returns:
-
sk
(Skeleton
) –Skeleton for the root id
-
mesh
((Mesh, optional)
) –Mesh graph that the skeleton is based on, only returned if return_mesh is True.
-
(l2dict_skel, l2dict_reverse): (dict, dict), optional
–Dictionaries mapping l2 ids to skeleton vertices and skeleton vertices to l2 ids, respectively. Only returned if return_l2dict is True.
-
(l2dict_mesh, l2dict_mesh): (dict, dict), optional
–Dictionaries mapping l2 ids to mesh graph vertices and mesh_graph vertices to l2 ids, respectively. Only returned if return_l2dict is True.
pcg_skeleton_direct(vertices, edges, invalidation_d=DEFAULT_INVALIDATION_D, root_point=None, collapse_soma=False, collapse_radius=DEFAULT_COLLAPSE_RADIUS, root_id=None)
¶
Produce a skeleton from an already-computed l2graph. This is effectively a wrapper for meshparty skeletonize with a consistent set of parameters and format.
Parameters:
-
vertices
(array
) –Array of vertices for the mesh graph.
-
edges
(array
) –Array of edges for the mesh graph.
-
invalidation_d
(int
, default:DEFAULT_INVALIDATION_D
) –Distance (in nanometers) for TEASAR skeleton invalidation.
-
root_point
(array
, default:None
) –3-element list or array with the x,y,z location of the root point in same units as vertices. If None, the most distant tip is set to root.
-
collapse_soma
(bool
, default:False
) –If True, collapse nearby vertices into the root point.
-
collapse_radius
(int
, default:DEFAULT_COLLAPSE_RADIUS
) –Distance (in nanometers) for soma collapse.
-
root_id
(int
, default:None
) –Root id of the segment, used in metadata. Optional, by default None.
-
level2_graph
(ndarray
) –Level 2 graph for the root id as returned by client.chunkedgraph.level2_chunk_graph. A list of lists of edges between level 2 chunks, as defined by their chunk ids. If None, will query the chunkedgraph for the level 2 graph. Optional, by default None.
Returns:
-
sk
(Skeleton
) –Skeleton for the l2graph.
pcg_meshwork(root_id, datastack_name=None, client=None, cv=None, root_point=None, root_point_resolution=None, collapse_soma=False, collapse_radius=DEFAULT_COLLAPSE_RADIUS, synapses=None, synapse_table=None, remove_self_synapse=True, live_query=False, timestamp=None, invalidation_d=DEFAULT_INVALIDATION_D, require_complete=False, metadata=False, synapse_partners=False, synapse_point_resolution=[1, 1, 1], synapse_representative_point_pre='ctr_pt_position', synapse_representative_point_post='ctr_pt_position', level2_graph=None)
¶
Generate a meshwork file based on the level 2 graph.
Parameters:
-
root_id
(int
) –Root id of an object in the pychunkedgraph.
-
datastack_name
(str or None
, default:None
) –Datastack name to use to initialize a client, if none is provided. By default None.
-
client
(CAVEclientFull or None
, default:None
) –Initialized CAVE client. If None is given, will use the datastack_name to create one. By default None
-
cv
(CloudVolume or None
, default:None
) –Initialized cloudvolume. If none is given, the client info will be used to create one. By default None
-
root_point
(array - like or None
, default:None
) –3 element xyz location for the location to set the root in units set by root_point_resolution, by default None. If None, a distal tip is selected.
-
root_point_resolution
(array - like
, default:None
) –Resolution in euclidean space of the root_point, by default [4, 4, 40]
-
collapse_soma
((bool, optional)
, default:False
) –If True, collapses vertices within a given radius of the root point into the root vertex, typically to better represent primary neurite branches. Requires a specified root_point. Default if False.
-
collapse_radius
(float
, default:DEFAULT_COLLAPSE_RADIUS
) –Max distance in euclidean space for soma collapse. Default is 10,000 nm (10 microns).
-
synapses
('pre', 'post', 'all', True, or None
, default:None
) –If not None, queries the synapse_table for presynaptic synapses (if 'pre'), postsynaptic sites (if 'post'), or both (if 'all' or True). By default None
-
synapse_table
(str
, default:None
) –Name of the synapse table to query if synapses are requested, by default None
-
remove_self_synapse
(bool
, default:True
) –If True, filters out synapses whose pre- and postsynaptic root ids are the same neuron, by default True
-
live_query
(bool
, default:False
) –If True, expect a timestamp for querying at a give point in time. Otherwise, use the materializatio set by the client. Optional, by default False.
-
timestamp
(Optional[datetime]
, default:None
) –If set, acts as the time at which all root ids and annotations are found at.
-
invalidation_d
(int
, default:DEFAULT_INVALIDATION_D
) –Invalidation radius in hops for the mesh skeletonization along the chunk adjacency graph, by default 3
-
require_complete
(bool
, default:False
) –If True, raise an Exception if any vertices are missing from the cache, by default False
-
metadata
(bool
, default:False
) –If True, adds metadata to the meshwork annotations. By default False.
-
synapse_partners
(bool
, default:False
) –If True, includes the partner root id to the synapse annotation. By default False, because partner roots can change across time.
-
synapse_point_resolution
(array - like
, default:[1, 1, 1]
) –Resolution in euclidean space of the synapse points, by default None. If None, the resolution will be the default of the synapse table.
-
synapse_representative_point_pre
(str
, default:'ctr_pt_position'
) –If set, uses the specified column in the synapse table for the pre-synaptic points. By default 'ctr_pt_position'.
-
synapse_representative_point_post
(str
, default:'ctr_pt_position'
) –If set, uses the specified column in the synapse table for the post-synaptic points. By default 'ctr_pt_position'.
Returns:
-
Meshwork
–Meshwork object with skeleton based on the level 2 graph. See documentation for details.