jaxley.io.graph.to_swc_graph

Navigation

jaxley.io.graph.to_swc_graph#

to_swc_graph(fname, num_lines=None)[source]#

Read a SWC file and return a SWC graph via networkX.

The graph is read such that each entry in the swc file becomes a graph node with the column attributes (id, x, y, z, r). Then each node is connected to its designated parent via an edge. A “type” attribute is added to the graph to identify its processing stage for subsequent steps.

Parameters:
  • fname (str) – Path to the swc file.

  • num_lines (int | None) – Number of lines to read from the file. If None, all lines are read.

Returns:

nodes: {‘id’: 1, ‘x’: 0.0, ‘y’: 0.0, ‘z’: 0.0, ‘r’: 1.0, ‘p’: -1} edges: {‘l’: 1.0}

Return type:

A networkx graph of the traced morphology in the swc file. It has attributes

Example usage#

from jaxley.io.graph to_swc_graph
swc_graph = to_swc_graph("path_to_swc.swc")