Skip to content

webknossos.skeleton.tree

Classes:

  • Graph

    Deprecated, please use Tree instead.

  • Tree

    Contains a collection of nodes and edges. Despite the name, trees may contain cycles.

Graph

Graph(name: str, group: Group, skeleton: Skeleton, color: Optional[Vector4] = None, enforced_id: Optional[int] = None)

Bases: Tree

Deprecated, please use Tree instead.

Methods:

Attributes:

color instance-attribute

color = color

group instance-attribute

group = group

id property

id: int

Read-only property.

name instance-attribute

name = name

node_dict_factory class-attribute instance-attribute

node_dict_factory = _NodeDict

add_node

add_node(position: Vec3IntLike, comment: Optional[str] = None, radius: Optional[float] = None, rotation: Optional[Vector3] = None, inVp: Optional[int] = None, inMag: Optional[int] = None, bitDepth: Optional[int] = None, interpolation: Optional[bool] = None, time: Optional[int] = None, is_branchpoint: bool = False, branchpoint_time: Optional[int] = None, _enforced_id: Optional[int] = None) -> 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.

adjlist_inner_dict_factory

adjlist_inner_dict_factory() -> _AdjDict

adjlist_outer_dict_factory

adjlist_outer_dict_factory() -> _AdjDict

get_max_node_id

get_max_node_id() -> int

Returns the highest node id.

get_node_by_id

get_node_by_id(node_id: int) -> Node

Returns the node in this tree with the requested id.

get_node_positions

get_node_positions() -> ndarray

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

Tree

Tree(name: str, group: Group, skeleton: Skeleton, color: Optional[Vector4] = None, enforced_id: Optional[int] = None)

Bases: 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)

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.

Methods:

Attributes:

color instance-attribute

color = color

group instance-attribute

group = group

id property

id: int

Read-only property.

name instance-attribute

name = name

node_dict_factory class-attribute instance-attribute

node_dict_factory = _NodeDict

add_node

add_node(position: Vec3IntLike, comment: Optional[str] = None, radius: Optional[float] = None, rotation: Optional[Vector3] = None, inVp: Optional[int] = None, inMag: Optional[int] = None, bitDepth: Optional[int] = None, interpolation: Optional[bool] = None, time: Optional[int] = None, is_branchpoint: bool = False, branchpoint_time: Optional[int] = None, _enforced_id: Optional[int] = None) -> 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.

adjlist_inner_dict_factory

adjlist_inner_dict_factory() -> _AdjDict

adjlist_outer_dict_factory

adjlist_outer_dict_factory() -> _AdjDict

get_max_node_id

get_max_node_id() -> int

Returns the highest node id.

get_node_by_id

get_node_by_id(node_id: int) -> Node

Returns the node in this tree with the requested id.

get_node_positions

get_node_positions() -> ndarray

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