Skip to content

webknossos.skeleton.tree

# &nbsp class Tree(networkx.classes.graph.Graph):

Contains a collection of nodes and edges. Despite the name, trees may contain cycles. This class inherits from networkx.Graph. For further methods, please check the networkx documentation.

See Tree.__init__ for more details.

A small usage example:

tree = skeleton.add_tree("a tree")
node_1 = tree.add_node(position=(0, 0, 0), comment="node 1")
node_2 = tree.add_node(position=(100, 100, 100), comment="node 2")

tree.add_edge(node_1, node_2)
# &nbsp Tree( name: str, group: webknossos.skeleton.group.Group, skeleton: webknossos.skeleton.skeleton.Skeleton, color: Union[Tuple[float, float, float, float], NoneType] = None, enforced_id: Union[int, NoneType] = None )

To create a tree, it is recommended to use Skeleton.add_tree or Group.add_tree. That way, the newly created tree is automatically attached as a child to the object the method was called on.

# &nbsp def adjlist_outer_dict_factory(self) -> webknossos.skeleton.tree._AdjDict:

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

# &nbsp def adjlist_inner_dict_factory(self) -> webknossos.skeleton.tree._AdjDict:

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

# &nbsp id: int

Read-only property.

# &nbsp def get_node_positions(self) -> numpy.ndarray:

Returns an numpy array with the positions of all nodes of this tree.

# &nbsp def get_node_by_id(self, node_id: int) -> webknossos.skeleton.node.Node:

Returns the node in this tree with the requested id.

# &nbsp def add_node( self, position: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], comment: Union[str, NoneType] = None, radius: Union[float, NoneType] = None, rotation: Union[Tuple[float, float, float], NoneType] = None, inVp: Union[int, NoneType] = None, inMag: Union[int, NoneType] = None, bitDepth: Union[int, NoneType] = None, interpolation: Union[bool, NoneType] = None, time: Union[int, NoneType] = None, is_branchpoint: bool = False, branchpoint_time: Union[int, NoneType] = None, _enforced_id: Union[int, NoneType] = None ) -> webknossos.skeleton.node.Node:

Adds a node to the tree. Apart from the mandatory position parameter, there are several optional parameters which can be used to encode additional information. For example, the comment will be shown by the WEBKNOSSOS UI.

# &nbsp def get_max_node_id(self) -> int:

Returns the highest node id.

# &nbsp class Tree.node_dict_factory(collections.abc.MutableMapping):

Dict-like container for the Tree class below to handle both nodes and ids as keys. Only when setting the value of a node for the first time the actual node must be passed. This allows to keep a reference from all ids to the nodes, which can be looked up using get_node(). Iterating over the keys yields the Node objects.

Inherited Members
collections.abc.MutableMapping
pop
popitem
clear
update
setdefault
collections.abc.Mapping
get
keys
items
values
# &nbsp class Graph(Tree):

Deprecated, please use Tree instead.

# &nbsp Graph( name: str, group: webknossos.skeleton.group.Group, skeleton: webknossos.skeleton.skeleton.Skeleton, color: Union[Tuple[float, float, float, float], NoneType] = None, enforced_id: Union[int, NoneType] = None )

To create a tree, it is recommended to use Skeleton.add_tree or Group.add_tree. That way, the newly created tree is automatically attached as a child to the object the method was called on.