Skip to content

webknossos.skeleton.group

Vector3 = typing.Tuple[float, float, float]
Vector4 = typing.Tuple[float, float, float, float]
GroupOrTree = typing.Union[ForwardRef('Group'), webknossos.skeleton.tree.Tree]
class Group:
Group( name: str, skeleton: webknossos.skeleton.skeleton.Skeleton, enforced_id: Union[int, NoneType] = None)

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

A small usage example:

subgroup = group.add_group("a subgroup")
tree = subgroup.add_tree("a tree")
name: str
id: int

Read-only property.

def add_tree( self, name_or_tree: Union[str, webknossos.skeleton.tree.Tree], color: Union[Tuple[float, float, float, float], Tuple[float, float, float], NoneType] = None, _enforced_id: Union[int, NoneType] = None) -> webknossos.skeleton.tree.Tree:

Adds a tree to the current group. If the first parameter is a string, a new tree will be added with the provided name and color if specified. Otherwise, the first parameter is assumed to be a tree object (e.g., from another skeleton). A copy of that tree will then be added. If the id of the tree already exists, a new id will be generated.

def add_graph( self, name: str, color: Union[Tuple[float, float, float, float], Tuple[float, float, float], NoneType] = None, _enforced_id: Union[int, NoneType] = None) -> webknossos.skeleton.tree.Tree:

Deprecated, please use add_tree.

def remove_tree_by_id(self, tree_id: int) -> None:
children: collections.abc.Iterator[typing.Union[webknossos.skeleton.group.Group, webknossos.skeleton.tree.Tree]]

Returns all (immediate) children (groups and trees) as an iterator.

Returns all (immediate) tree children as an iterator. Use flattened_trees if you need also need trees within subgroups.

graphs: Iterator[webknossos.skeleton.tree.Tree]

Deprecated, please use trees.

groups: collections.abc.Iterator[webknossos.skeleton.group.Group]

Returns all (immediate) group children as an iterator. Use flattened_groups if you need also need groups within subgroups.

def add_group( self, name: str, _enforced_id: Union[int, NoneType] = None) -> webknossos.skeleton.group.Group:

Adds a (sub) group to the current group with the provided name.

def get_total_node_count(self) -> int:

Returns the total number of nodes of all trees within this group (and its subgroups).

def get_max_tree_id(self) -> int:

Returns the highest tree id of all trees within this group (and its subgroups).

def get_max_graph_id(self) -> int:

Deprecated, please use get_max_tree_id.

def get_max_node_id(self) -> int:

Returns the highest node id of all nodes of all trees within this group (and its subgroups).

def flattened_trees(self) -> Iterator[webknossos.skeleton.tree.Tree]:

Returns an iterator of all trees within this group (and its subgroups).

def flattened_graphs(self) -> Iterator[webknossos.skeleton.tree.Tree]:

Deprecated, please use flattened_trees.

def flattened_groups(self) -> collections.abc.Iterator[webknossos.skeleton.group.Group]:

Returns an iterator of all groups within this group (and its subgroups).

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

Returns the node which has the specified node id.

def get_tree_by_id(self, tree_id: int) -> webknossos.skeleton.tree.Tree:

Returns the tree which has the specified tree id.

def has_tree_id(self, tree_id: int) -> bool:

Returns true if this group (or a subgroup) contains a tree with the given id.

def get_graph_by_id(self, graph_id: int) -> webknossos.skeleton.tree.Tree:

Deprecated, please use get_tree_by_id.

def get_group_by_id(self, group_id: int) -> webknossos.skeleton.group.Group:

Returns the group which has the specified group id.

def as_nml_group(self) -> webknossos._nml.group.Group:

Returns a named tuple representation of this group.