Skip to content

webknossos.skeleton.skeleton

Vector3 = typing.Tuple[float, float, float]

Representation of the skeleton of an Annotation. It contains metadata to identify the related dataset and is the root-group of sub-groups and trees. See the parent class Group for methods about group and tree handling. To upload a skeleton to webknossos, please create an Annotation() with it.

A small usage example:

annotation = Annotation(
    name="my_annotation", dataset_name="my_dataset", voxel_size=(11, 11, 24)
)
group = annotation.skeleton.add_group("a group")
tree = group.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)

Also see this example for a more complex interaction.

Skeleton( voxel_size: Tuple[float, float, float], dataset_name: str, organization_id: Union[str, NoneType] = None, description: Union[str, NoneType] = None, enforced_id: Union[int, NoneType] = None)

To initialize a skeleton, setting the following parameters is required (or recommended):

  • voxel_size
  • dataset_name
  • organization_id
  • description
voxel_size: Tuple[float, float, float]
dataset_name: str
organization_id: Union[str, NoneType]
description: Union[str, NoneType]
name: str

Should not be used with Skeleton, this attribute is only useful for sub-groups. Set to Root.

scale: Tuple[float, float, float]

Deprecated, please use voxel_size.

@staticmethod
def load( file_path: Union[os.PathLike, str]) -> webknossos.skeleton.skeleton.Skeleton:

Loads a .nml file or a .zip file containing an NML (and possibly also volume layers). Returns the Skeleton object. Also see Annotation.load if you want to have the annotation which wraps the skeleton.

def save(self, out_path: Union[str, os.PathLike]) -> None:

Stores the skeleton as a zip or nml at the given path.

@staticmethod
def from_path( file_path: Union[os.PathLike, str]) -> webknossos.skeleton.skeleton.Skeleton:

Deprecated. Use Skeleton.load instead.

def write(self, out_path: os.PathLike) -> None:

Deprecated. Use Skeleton.save instead.