webknossos.skeleton.nml
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.
Create new instance of NMLParameters(name, scale, offset, time, editPosition, editRotation, zoomLevel, taskBoundingBox, userBoundingBoxes)
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
Alias for field number 6
Alias for field number 7
Alias for field number 8
Inherited Members
- builtins.tuple
- index
- count
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.
Create new instance of Node(id, position, radius, rotation, inVp, inMag, bitDepth, interpolation, time)
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
Alias for field number 6
Alias for field number 7
Alias for field number 8
Inherited Members
- builtins.tuple
- index
- count
A webKnossos skeleton edge.
Attributes: source (int): node id reference target (int): node id reference
Create new instance of Edge(source, target)
Alias for field number 0
Alias for field number 1
Inherited Members
- builtins.tuple
- index
- count
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
Create new instance of Tree(id, color, name, nodes, edges, groupId)
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
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
Create new instance of Branchpoint(id, time)
Alias for field number 0
Alias for field number 1
Inherited Members
- builtins.tuple
- index
- count
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
Create new instance of Group(id, name, children)
Alias for field number 0
Alias for field number 1
Alias for field number 2
Inherited Members
- builtins.tuple
- index
- count
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.
Create new instance of Comment(node, content)
Alias for field number 0
Alias for field number 1
Inherited Members
- builtins.tuple
- index
- count
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.
Create new instance of Volume(id, location, fallback_layer, name)
Alias for field number 0
Alias for field number 1
Alias for field number 2
Alias for field number 3
Inherited Members
- builtins.tuple
- index
- count
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
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)
XML values must not be 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)