Skip to content

paleo

Modules:

Name Description
graph_edits
level2_graph
networkdelta
replay
skeletons
synapses
utils

Classes:

Name Description
NetworkDelta

Functions:

Name Description
compare_graphs

Compare two graphs and return the differences.

get_detailed_change_log

Get a detailed change log for a root ID.

get_metadata_table

Retrieve metadata for a list of operations or root IDs.

get_metaedits

Combine edits into meta-edits based on shared nodes.

get_operation_level2_edit

Extract changes to the level2 graph for a specific operation.

get_operations_level2_edits

Extract changes to the level2 graph for a list of operations.

get_root_level2_edits

Extract changes to the level2 graph for all operations on a root.

get_initial_graph

Get the initial graph for a given root_id, including objects that could become

get_node_aliases

For a given supervoxel, get the node that it was part of at stop_layer for

get_component_masks

From a list of components, get a node by component boolean DataFrame of masks.

get_nucleus_supervoxel

Get the supervoxel corresponding to the nucleus of a neuron by looking it up

get_nodes_aliases

For a list of supervoxels, get all of the nodes at stop_layer that they were

get_supervoxel_mappings

For a set of supervoxels and edits, get a mapping between the supervoxels and

get_changed_nodes

From a set of edits, get the nodes that have changed (added or removed).

get_used_node_ids

Starting from an initial graph and a series of edits, get the nodes that are

apply_edit

Apply the edit described by the networkdelta to the graph.

resolve_edit

Apply the edit described by the networkdelta and return the connected component

find_anchor_node

Find the first anchor node that is in the graph.

apply_edit_sequence

Apply a sequence of edits to the graph in order, storing information about

get_mutable_synapses

Get all synapses that could have been part of this root_id across all states.

map_synapses_to_sequence

Map synapses (with level2 node information) to a sequence of level2 nodes.

skeletonize_sequence

Generate skeletons for a sequence of graphs.

NetworkDelta(removed_nodes, added_nodes, removed_edges, added_edges, metadata={})

A class to represent a change to a network.

Parameters:

Name Type Description Default
removed_nodes ndarray

IDs of nodes that were removed by this operation.

required
added_nodes ndarray

IDs of nodes that were added by this operation.

required
removed_edges ndarray

Edges that were removed by this operation.

required
added_edges ndarray

Edges that were added by this operation.

required
metadata dict

A dictionary of arbitrary metadata about the operation.

{}

compare_graphs(graph_before, graph_after, metadata=False)

Compare two graphs and return the differences.

Parameters:

Name Type Description Default
graph_before Graph

The graph before the operation. Can either be a tuple of (nodes, edges) stored as np.ndarrays, or just the edges as an np.ndarray.

required
graph_after Graph

The graph after the operation. Can either be a tuple of (nodes, edges) stored as np.ndarrays, or just the edges as an np.ndarray.

required

Returns:

Type Description
NetworkDelta

The differences between the two graphs.

get_detailed_change_log(root_id, client, filtered=True)

Get a detailed change log for a root ID.

Parameters:

Name Type Description Default
root_id int

The root ID to get the change log for.

required
client CAVEclient

The CAVEclient instance to use.

required
filtered bool

Whether to filter the change log to only include changes which affect the final state of the root ID.

True

Returns:

Type Description
DataFrame

A detailed change log for the root ID.

get_metadata_table(operation_ids=None, root_ids=None, client=None)

Retrieve metadata for a list of operations or root IDs.

NOTE: aspirational, not yet implemented. To make this efficient, would probably need a server-side implementation

Parameters:

Name Type Description Default
operation_ids list of int

The operation IDs to retrieve metadata for.

None
root_ids list of int

The root IDs to retrieve metadata for.

None
client CAVEclient

The CAVEclient instance to use.

None

Returns:

Type Description
DataFrame

The metadata for the operations or root IDs. Metadata includes:

  • operation_id: The operation ID.
  • timestamp: The timestamp of the operation.
  • location: The approximate [x,y,z] centroid of the operation in nanometers.
  • volume_added: The volume added by the operation in cubic nanometers.
  • volume_removed: The volume removed by the operation in cubic nanometers.
  • n_added_nodes: The number of level2 nodes added by the operation.
  • n_removed_nodes: The number of level2 nodes removed by the operation.
  • n_modified_nodes: The number of level2 nodes modified by the operation.
  • n_added_edges: The number of level2 edges added by the operation.
  • n_removed_edges: The number of level2 edges removed by the operation.
  • n_modified_edges: The number of level2 edges modified by the operation.

get_metaedits(networkdeltas)

Combine edits into meta-edits based on shared nodes.

Meta-edits are groups of one or more edits which affected a local region in the chunkedgraph. More specifically, they are defined as groups of edits which are connected components in a graph where nodes are edits and edges are shared nodes between edits.

Parameters:

Name Type Description Default
networkdeltas dict[Integer, NetworkDelta]

The changes to the level2 graph from each operation.

required

Returns:

Type Description
dict[Integer, NetworkDelta]

The changes to the level2 graph from each meta-operation.

dict[Integer, list[Integer]]

A mapping of meta-operation IDs to the operation IDs that make them up.

get_operation_level2_edit(operation_id, client, before_root_ids=None, after_root_ids=None, timestamp=None, point=None, radius=20000, metadata=False)

Extract changes to the level2 graph for a specific operation.

Parameters:

Name Type Description Default
operation_id int

The operation ID to extract changes for.

required
client CAVEclient

The CAVEclient instance to use.

required
before_root_ids Optional[Collection[int]]

The root ID(s) that were involved in the operation prior to it happening. If None, these will be looked up.

None
after_root_ids Optional[Collection[int]]

The root ID(s) that were created by the operation. If None, these will be looked up.

None
timestamp Optional[datetime]

The timestamp of the operation. Only used if before_root_ids is not provided. If None, this will be looked up.

None
point Optional[ndarray]

The point to center the bounding box on. If None, will compare the entire level2 graphs of the objects before and after the operation.

None
radius Number

The radius of the bounding box to use.

20000
metadata bool

Whether to include metadata about the changes in the output.

False

Returns:

Type Description
NetworkDelta

The changes to the level2 graph from this operation.

get_operations_level2_edits(operation_ids, client, radius=20000, metadata=False, n_jobs=-1, verbose=True)

Extract changes to the level2 graph for a list of operations.

Parameters:

Name Type Description Default
operation_ids Union[Collection[Integer], Integer]

The operation ID(s) to extract changes for.

required
client CAVEclient

The CAVEclient instance to use.

required
radius Number

The radius of the bounding box to use.

20000
metadata bool

Whether to include metadata about the changes in the output.

False
n_jobs int

The number of jobs to run in parallel. If -1, will use all available cores.

-1
verbose bool

Whether to display a progress bar.

True

Returns:

Type Description
dict[Integer, NetworkDelta]

The changes to the level2 graph from these operations

get_root_level2_edits(root_id, client, radius=20000, metadata=False, filtered=False, n_jobs=-1, verbose=True)

Extract changes to the level2 graph for all operations on a root.

Parameters:

Name Type Description Default
root_id Integer

The root ID to extract changes for.

required
client CAVEclient

The CAVEclient instance to use.

required
radius Number

The radius of the bounding box to use.

20000
metadata bool

Whether to include metadata about the changes in the output.

False
filtered bool

Whether to filter the change log to only include changes which affect the final state of the root ID.

False
n_jobs int

The number of jobs to run in parallel. If -1, will use all available cores.

-1
verbose bool

Whether to display a progress bar.

True

Returns:

Type Description
dict[Integer, NetworkDelta]

The changes to the level2 graph from each operation

get_initial_graph(root_id, client, verbose=True, return_as='networkx', n_jobs=-1)

Get the initial graph for a given root_id, including objects that could become part of the neuron in the future.

get_node_aliases(supervoxel_id, client, stop_layer=2, return_as='list')

For a given supervoxel, get the node that it was part of at stop_layer for each timestamp.

get_component_masks(components)

From a list of components, get a node by component boolean DataFrame of masks.

get_nucleus_supervoxel(root_id, client)

Get the supervoxel corresponding to the nucleus of a neuron by looking it up in the soma table.

get_nodes_aliases(supervoxel_ids, client, stop_layer=2, verbose=True, return_as='list')

For a list of supervoxels, get all of the nodes at stop_layer that they were part of across time.

get_supervoxel_mappings(supervoxel_ids, edits, client, n_jobs=-1)

For a set of supervoxels and edits, get a mapping between the supervoxels and any level2 nodes they could have been part of across time.

get_changed_nodes(edits)

From a set of edits, get the nodes that have changed (added or removed).

get_used_node_ids(initial_graph, edits, anchor_nodes)

Starting from an initial graph and a series of edits, get the nodes that are used in at least one state of the graph throughout its history.

Parameters:

Name Type Description Default
initial_graph Graph

The initial graph to start from.

required
edits dict

A dictionary of edits where the key is the operation_id and the value is a NetworkDelta object.

required
anchor_nodes list

A list of nodes that are on the object of interest, used to pick the connected component to consider at each point in the history.

required

Returns:

Type Description

Nodes that are ever used in the history of the graph.

apply_edit(graph, networkdelta)

Apply the edit described by the networkdelta to the graph.

resolve_edit(graph, networkdelta, anchor_nodes)

Apply the edit described by the networkdelta and return the connected component containing the anchor node.

find_anchor_node(graph, anchor_nodes)

Find the first anchor node that is in the graph.

apply_edit_sequence(graph, edits, anchor_nodes, return_graphs=False, include_initial=True, verbose=True)

Apply a sequence of edits to the graph in order, storing information about intermediate states.

get_mutable_synapses(root_id, edits, client, sides='both', synapse_table=None, remove_self=True, verbose=False, n_jobs=-1)

Get all synapses that could have been part of this root_id across all states.

map_synapses_to_sequence(synapses, nodes_by_state, side='pre')

Map synapses (with level2 node information) to a sequence of level2 nodes.

skeletonize_sequence(graphs_by_state, client=None, root_id=None, root_point=None, level2_data=None)

Generate skeletons for a sequence of graphs.