jaxley.io.graph.from_graph

Navigation

jaxley.io.graph.from_graph#

from_graph(comp_graph, assign_groups=True, solve_root=None, traverse_for_solve_order=True)[source]#

Return a Jaxley module from a compartmentalized networkX graph.

Parameters:
  • comp_graph (DiGraph) – The compartment graph built with build_compartment_graph() or with to_graph().

  • assign_groups (bool) – Whether to assign groups to the nodes.

  • solve_root (int | None) – The root node to traverse the graph for identifying the solve order.

  • traverse_for_solve_order (bool) – Whether to traverse the graph for identifying the solve order. Should only be set to False if you are confident that the comp_graph is in a form in which it can be solved (i.e. its branch indices, compartment indices, and node names are correct). Typically, this is the case only if you exported a module to a comp_graph via to_graph, did not modify the graph, and now re-import it as a module with from_graph.

Returns:

A jx.Module representing the graph.

Example usage#

from jaxley.io.graph import to_swc_graph, build_compartment_graph, from_graph
swc_graph = to_swc_graph("path_to_swc.swc")
comp_graph = build_compartment_graph(swc_graph, ncomp=1)
cell = from_graph(comp_graph)