Skip to content

webknossos.skeleton.nml

#   def enforce_not_null(val: Union[~T, NoneType]) -> ~T:
#   def as_int_unless_none(val: Union[str, NoneType]) -> Union[int, NoneType]:
#   class NMLParameters(builtins.tuple):

Contains common metadata for NML files

Note: Setting a task bounding boxes will cause wK to 1) render these visually and 2) prevent data loading from outside them.

Attributes: name (str): Name of a dataset that the annotation is based on. Will cause wK to open the given skeleton annotation with the referenced dataset. scale (Vector3[float]): Voxel scale of the referenced dataset in nanometers. offset (Optional[Vector3[float]]): Deprecated. Kept for backward compatibility. time (Optional[int]): A UNIX timestamp marking the creation time & date of an annotation. editPosition (Optional[Vector3[float]]): The position of the wK camera when creating/downloading an annotation editRotation (Optional[Vector3[float]]): The rotation of the wK camera when creating/downloading an annotation zoomLevel (Optional[float]): The zoomLevel of the wK camera when creating/downloading an annotation taskBoundingBox (Optional[IntVector6[int]]): A custom bounding box specified as part of a wK task. Will be rendered in wK. userBoundingBoxes (Optional[List[IntVector6[int]]]): A list of custom user-defined bounding boxes. Will be rendered in wK.

#   NMLParameters( name: str, scale: Tuple[float, float, float], offset: Union[Tuple[float, float, float], NoneType] = None, time: Union[int, NoneType] = None, editPosition: Union[Tuple[float, float, float], NoneType] = None, editRotation: Union[Tuple[float, float, float], NoneType] = None, zoomLevel: Union[float, NoneType] = None, taskBoundingBox: Union[Tuple[int, int, int, int, int, int], NoneType] = None, userBoundingBoxes: Union[List[Tuple[int, int, int, int, int, int]], NoneType] = None )

Create new instance of NMLParameters(name, scale, offset, time, editPosition, editRotation, zoomLevel, taskBoundingBox, userBoundingBoxes)

#   name: str

Alias for field number 0

#   scale: Tuple[float, float, float]

Alias for field number 1

#   offset: Union[Tuple[float, float, float], NoneType]

Alias for field number 2

#   time: Union[int, NoneType]

Alias for field number 3

#   editPosition: Union[Tuple[float, float, float], NoneType]

Alias for field number 4

#   editRotation: Union[Tuple[float, float, float], NoneType]

Alias for field number 5

#   zoomLevel: Union[float, NoneType]

Alias for field number 6

#   taskBoundingBox: Union[Tuple[int, int, int, int, int, int], NoneType]

Alias for field number 7

#   userBoundingBoxes: Union[List[Tuple[int, int, int, int, int, int]], NoneType]

Alias for field number 8

Inherited Members
builtins.tuple
index
count
#   class Node(builtins.tuple):

A webKnossos skeleton node annotation object.

Attributes: id (int): A unique identifier position (Vector3): 3D position of a node. Format: [x, y, z] radius (Optional[float]): Radius of a node when rendered in wK. Unit: nanometers (nm) rotation (Optional[Vector3]): 3D rotation of the camera when the node was annotated. Mostly relevant for Flight mode to resume in the same direction when returning to Flight mode. inVp (Optional[int]): Enumeration of the wK UI viewport in which the node was annotated. 0: XY plane, 1: YZ plane. 2: XY plane, 3: 3D viewport inMag (Optional[int]): wK rendering magnification-level when the node was annotated. Lower magnification levels typically indicate a "zoomed-in" workflow resulting in more accurate annotations. bitDepth (Optional[int]): wK rendering bit-depth when the node was annotated. 4bit (lower data quality) or 8bit (regular quality). Lower quality data rendering might lead to less accurate annotations. interpolation (Optional[bool]): wK rendering interpolation flag when the node was annotated. Interpolated data rendering might lead to less accurate annotations. time (Optional[int]): A Unix timestamp marking the creation time of the node.

#   Node( id: int, position: Tuple[float, float, float], 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 )

Create new instance of Node(id, position, radius, rotation, inVp, inMag, bitDepth, interpolation, time)

#   id: int

Alias for field number 0

#   position: Tuple[float, float, float]

Alias for field number 1

#   radius: Union[float, NoneType]

Alias for field number 2

#   rotation: Union[Tuple[float, float, float], NoneType]

Alias for field number 3

#   inVp: Union[int, NoneType]

Alias for field number 4

#   inMag: Union[int, NoneType]

Alias for field number 5

#   bitDepth: Union[int, NoneType]

Alias for field number 6

#   interpolation: Union[bool, NoneType]

Alias for field number 7

#   time: Union[int, NoneType]

Alias for field number 8

Inherited Members
builtins.tuple
index
count
#   class Edge(builtins.tuple):

A webKnossos skeleton edge.

Attributes: source (int): node id reference target (int): node id reference

#   Edge(source: int, target: int)

Create new instance of Edge(source, target)

#   source: int

Alias for field number 0

#   target: int

Alias for field number 1

Inherited Members
builtins.tuple
index
count
#   class Tree(builtins.tuple):

A webKnossos skeleton (tree) object. A graph structure consisting of nodes and edges.

Attributes: id: int color (Vector4): RGBA name: str nodes: List[Node] edges: List[Edge] groupId (Optional[int]): group id reference

#   Tree( id: int, color: Union[Tuple[float, float, float, float], NoneType], name: str, nodes: List[webknossos.skeleton.nml.Node], edges: List[webknossos.skeleton.nml.Edge], groupId: Union[int, NoneType] = None )

Create new instance of Tree(id, color, name, nodes, edges, groupId)

#   id: int

Alias for field number 0

#   color: Union[Tuple[float, float, float, float], NoneType]

Alias for field number 1

#   name: str

Alias for field number 2

Alias for field number 3

Alias for field number 4

#   groupId: Union[int, NoneType]

Alias for field number 5

Inherited Members
builtins.tuple
index
count
#   class Branchpoint(builtins.tuple):

A webKnossos branchpoint, i.e. a skeleton node with more than one outgoing edge.

Attributes: id (int): Reference to a Node ID time (int): Unix timestamp

#   Branchpoint(id: int, time: Union[int, NoneType])

Create new instance of Branchpoint(id, time)

#   id: int

Alias for field number 0

#   time: Union[int, NoneType]

Alias for field number 1

Inherited Members
builtins.tuple
index
count
#   class Group(builtins.tuple):

A container to group several skeletons (trees) together. Mostly for cosmetic or organizational purposes.

Attributes: id (int): A unique group identifier name (str): Name of the group. Will be displayed in wK UI children (List[Group]): List of all sub-groups belonging to this parent element for nested structures

#   Group(id: int, name: str, children: List[ForwardRef('Group')])

Create new instance of Group(id, name, children)

#   id: int

Alias for field number 0

#   name: str

Alias for field number 1

Alias for field number 2

Inherited Members
builtins.tuple
index
count
#   class Comment(builtins.tuple):

A single comment belonging to a skeleton node.

Attributes: node (int): Reference to a Node ID content (str): A free text field. Supports Markdown formatting.

#   Comment(node: int, content: str)

Create new instance of Comment(node, content)

#   node: int

Alias for field number 0

#   content: str

Alias for field number 1

Inherited Members
builtins.tuple
index
count
#   class Volume(builtins.tuple):

A metadata reference to a wK volume annotation. Typically, the volume annotation data is provided in a ZIP file in the same directory as the skeleton annotation.

Attributes: id (int): A unique identifier location (str): A path to a ZIP file containing a wK volume annotation fallback_layer (Optional[str]): Name of an already existing wK volume annotation segmentation layer (aka "fallback layer") name (Optional[str]): Name of the volume layer. Older webKnossos versions did not serialize the name which is why the property is optional.

#   Volume( id: int, location: str, fallback_layer: Union[str, NoneType] = None, name: Union[str, NoneType] = None )

Create new instance of Volume(id, location, fallback_layer, name)

#   id: int

Alias for field number 0

#   location: str

Alias for field number 1

#   fallback_layer: Union[str, NoneType]

Alias for field number 2

#   name: Union[str, NoneType]

Alias for field number 3

Inherited Members
builtins.tuple
index
count
#   class NML(builtins.tuple):

A complete webKnossos skeleton annotation object contain one or more skeletons (trees).

Attributes: parameters (NMLParameters): All the metadata attributes associated with a wK annotation. trees (List[Tree]): A list of all skeleton/tree objects. Usually contains the majority of the annotated skeleton information. branchpoints (List[Branchpoint]): A list of all branchpoint objects. comments (List[Comment]): A list of all comment objects. groups (List[Group]): A list of all group objects. volume (Optional[Volume]): A reference to any volume data that is part of this annotation.

Create new instance of NML(parameters, trees, branchpoints, comments, groups, volumes)

Alias for field number 0

Alias for field number 1

Alias for field number 2

Alias for field number 3

Alias for field number 4

Alias for field number 5

Inherited Members
builtins.tuple
index
count
#   def parse_nml(file: IO[bytes]) -> webknossos.skeleton.nml.NML:

Reads a webKnossos NML skeleton file from disk, parses it and returns an NML Python object

Arguments: file (BinaryIO): A Python file handle

Return: NML: A webKnossos skeleton annotation as Python NML object

Example: with open("input.nml", "rb") as f: nml = wknml.parse_nml(f, nml)

#   def filter_none_values(_dict: Dict[str, Union[str, NoneType]]) -> Dict[str, str]:

XML values must not be None.

#   def write_nml(file: <class 'BinaryIO'>, nml: webknossos.skeleton.nml.NML) -> None:

Writes an NML object to a file on disk.

Arguments: file (BinaryIO): A Python file handle nml (NML): A NML object that should be persisted to disk

Example: with open("out.nml", "wb") as f: wknml.write_nml(f, nml)

Submodules

Back to top