Skip to content

NML File Format

WEBKNOSSOS stores skeleton annotations in the NML format, an XML-based, human-readable file format. You can download NML files and upload them again. Advanced users process the skeleton data in their own analysis workflows and scripts, e.g., node positions that mark objects or tree groups that cluster cells. The WEBKNOSSOS Python library reads and writes NML files.

When an annotation also contains volume layers, the download is a ZIP archive with an NML file and the volume data. The NML file then also describes the volume layers and their segments (see Import and Export Volume Annotations).

Example

<things>
  <parameters>
    <experiment name="great_dataset" organization="my_org" datasetId="abc123" description="My annotation" wkUrl="https://webknossos.org" />
    <scale x="11.24" y="11.24" z="25.0" unit="nanometer" />
    <offset x="0" y="0" z="0" />
    <time ms="1534787309180" />
    <editPosition x="1024" y="1024" z="512" />
    <editRotation xRot="0.0" yRot="0.0" zRot="0.0" />
    <zoomLevel zoom="1.0" />
    <activeNode id="1" />
    <userBoundingBox id="1" name="My Box" isVisible="true" color.r="1.0" color.g="0.0" color.b="0.0" color.a="1.0"
      topLeftX="0" topLeftY="0" topLeftZ="0" width="512" height="512" depth="512" />
    <taskBoundingBox topLeftX="0" topLeftY="0" topLeftZ="0" width="512" height="512" depth="512" />
    <additionalAxes>
      <additionalAxis name="t" index="0" start="0" end="10" />
    </additionalAxes>
  </parameters>
  <thing id="1" groupId="2" color.r="0.0" color.g="0.0" color.b="1.0" color.a="1.0" name="explorative_2018-08-20_Example" isVisible="true">
    <nodes>
      <node id="1" radius="120.0" x="1475" y="987" z="512" rotX="0.0" rotY="0.0" rotZ="0.0" inVp="0" inMag="0" bitDepth="8" interpolation="false" time="1534787309180" />
      <node id="2" radius="120.0" x="1548" y="1008" z="512" rotX="0.0" rotY="0.0" rotZ="0.0" inVp="0" inMag="0" bitDepth="8" interpolation="false" time="1534787309180" />
    </nodes>
    <edges>
      <edge source="1" target="2" />
    </edges>
    <metadata>
      <metadataEntry key="comment" stringValue="interesting tree" />
    </metadata>
  </thing>
  <branchpoints>
    <branchpoint id="1" time="1534787309180" />
  </branchpoints>
  <comments>
    <comment node="2" content="This is a really interesting node" />
  </comments>
  <groups>
    <group id="1" name="Axon 1" isExpanded="true">
        <group id="2" name="Foo" isExpanded="false" />
    </group>
  </groups>
  <volume id="0" name="Volume Layer" location="data.zip" format="zip"
    fallbackLayer="segmentation" largestSegmentId="1000" mappingName="agglomerate_view" mappingIsLocked="false">
    <segments>
      <segment id="1" name="Cell 1" isVisible="true" created="1534787309180"
        anchorPositionX="1475" anchorPositionY="987" anchorPositionZ="512"
        color.r="1.0" color.g="0.0" color.b="0.0" color.a="1.0" groupId="1">
        <metadata>
          <metadataEntry key="score" numberValue="0.95" />
          <metadataEntry key="reviewed" boolValue="true" />
        </metadata>
      </segment>
    </segments>
    <groups>
      <group id="1" name="Group A" />
    </groups>
  </volume>
</things>

<parameters> Section

Holds global metadata for the annotation.

  • <experiment>: Dataset reference and annotation context.

    • name (required): The dataset name.
    • organization (optional): The organization the dataset belongs to.
    • datasetId (optional): Unique identifier of the dataset.
    • description (optional): A free-text description of the annotation.
    • wkUrl (optional): URL of the WEBKNOSSOS instance that created this annotation.
  • <scale>: The real-world voxel size of the dataset.

    • x, y, z: Voxel size in the given unit.
    • unit (optional): Physical unit string (e.g., nanometer). Defaults to nanometer if omitted.
  • <offset>: A global offset applied to all node positions (usually 0, 0, 0). Attributes: x, y, z.

  • <time>: Creation timestamp. Attribute: ms (Unix timestamp in milliseconds).

  • <editPosition>: The viewport position when the annotation was last saved.

    • x, y, z: Position in voxel coordinates.
    • additionalCoordinate-<name> (optional, multiple): Position along each additional axis (e.g., additionalCoordinate-t="3").
  • <editRotation>: The viewport rotation when last saved. Attributes: xRot, yRot, zRot.

  • <zoomLevel>: The zoom level when last saved. Attribute: zoom.

  • <activeNode> (optional): The node that was selected when the annotation was last saved. Attribute: id.

  • <userBoundingBox> (optional, multiple): User-defined bounding boxes for regions of interest.

    • id (required): Unique integer ID.
    • name (optional): Display name.
    • isVisible (optional): Boolean visibility flag.
    • color.r, color.g, color.b, color.a (optional): RGBA color (floats 0.0–1.0).
    • topLeftX, topLeftY, topLeftZ, width, height, depth: Bounding box geometry in voxels.
  • <taskBoundingBox> (optional): The task bounding box (present only for task-based annotations). Same geometry attributes as userBoundingBox but without id, name, isVisible, or color.

  • <additionalAxes> (optional): Declares additional coordinate axes for n-dimensional datasets.

    • <additionalAxis> child elements with:
      • name: Axis name (e.g., "t").
      • index: Sort order index.
      • start: Lower bound (inclusive).
      • end: Upper bound (exclusive).

<thing> Elements (Skeleton Trees)

Each <thing> element represents one skeleton tree.

  • id (required): Unique integer tree ID.
  • name (required): Display name of the tree.
  • color.r, color.g, color.b, color.a (optional): RGBA color (floats 0.0–1.0).
  • isVisible (optional): Boolean visibility flag.
  • groupId (optional): ID of the tree group this tree belongs to.
  • type (optional): Tree type string (e.g., "NORMAL", "AGGLOMERATE").
  • <nodes>: Contains <node> child elements.
  • <edges>: Contains <edge> child elements.
  • <metadata> (optional): Contains <metadataEntry> child elements (see Metadata Entries).

<node> Elements

  • id, radius, x, y, z, rotX, rotY, rotZ: Basic node properties.
  • inVp: Viewport index the node was created in.
  • inMag: Magnification step at time of creation.
  • bitDepth: Bit depth of the data at time of creation.
  • interpolation: Boolean, whether the node position was interpolated.
  • time: Unix timestamp (ms) of creation.
  • additionalCoordinate-<name> (optional, multiple): Coordinate along an additional axis (e.g., additionalCoordinate-t="3").

<edge>, <branchpoint>, and <comment> Elements

  • <edge>: An edge of a tree, nested in the <edges> element of its <thing>.
    • source, target: Node IDs of the connected nodes.
  • <branchpoint>: A branch point, nested in the top-level <branchpoints> element.
    • id: Node ID of the branch point.
    • time: Unix timestamp (ms).
  • <comment>: A node comment, nested in the top-level <comments> element.
    • node: Node ID.
    • content: Free-text content of the comment.

<group> Elements (Tree Groups)

Tree groups are nested under the top-level <groups> element.

  • id (required): Unique integer group ID.
  • name (required): Display name.
  • isExpanded (optional): Boolean, whether the group is expanded in the UI (default: true).
  • Child <group> elements for nesting.

<volume> Elements

Represents a volume annotation layer.

  • id (required): Layer index (integer).
  • name (required): Layer name.
  • location (optional): Path to the volume data ZIP file within the annotation ZIP archive.
  • format (optional): Format of the volume data ZIP (e.g., "zip", "nmlV4").
  • fallbackLayer (optional): Name of a dataset segmentation layer to use as read-only fallback.
  • largestSegmentId (optional): The highest segment ID currently used.
  • mappingName (optional): Name of the active agglomerate mapping.
  • mappingIsLocked (optional): Boolean, whether the active mapping is locked.
  • editedMappingEdgesLocation (optional): Path to the editable mapping edges ZIP (present only for editable mappings).
  • editedMappingBaseMappingName (optional): The underlying mapping name for editable mappings.
  • <segments>: Contains <segment> child elements.
  • <groups>: Contains <group> child elements for segment groups.

<segment> Elements

  • id (required): Segment ID.
  • name (optional): Display name.
  • isVisible (optional): Boolean visibility flag.
  • created (optional): Unix timestamp (ms) of creation.
  • anchorPositionX, anchorPositionY, anchorPositionZ (optional): Anchor voxel position.
  • additionalCoordinate-<name> (optional, multiple): Anchor position along additional axes.
  • color.r, color.g, color.b, color.a (optional): RGBA color (floats 0.0–1.0).
  • groupId (optional): ID of the segment group this segment belongs to.
  • <metadata> (optional): Contains <metadataEntry> child elements.

Segment <group> elements (inside <volume>/<groups>) have id, name, and support recursive nesting, but no isExpanded attribute.

Metadata Entries

Both <thing> (tree) and <segment> elements may contain a <metadata> child with <metadataEntry> elements. Each entry has a key and exactly one value attribute:

  • stringValue: A string value.
  • numberValue: A floating-point number.
  • boolValue: A boolean (true or false).
  • stringListValue-0, stringListValue-1, … : A string array stored as indexed attributes.

<bookmarks> Section

Annotations downloaded from WEBKNOSSOS contain their bookmarks in an optional <bookmarks> element at the end of <things>. When an NML with bookmarks is uploaded as a single file, its bookmarks are restored. When several files are merged during upload, their bookmarks are dropped.

<bookmarks>
  <bookmark id="3" name="Interesting synapse" description="Check again" created="1730000000000">
    <thumbnail size="small" viewport="xy" location="bookmark_thumbnails/3_small.jpg" />
    <thumbnail size="large" viewport="xy" location="bookmark_thumbnails/3_large.jpg" />
    <metadata>
      <metadataEntry key="reviewed" boolValue="true" />
    </metadata>
    <state mode="orthogonal" zoomStep="1.3" clippingDistance="50.0" clipSkeletonToCurrentSection="false" activeNodeId="2" showSkeletons="true">
      <position x="1024" y="1024" z="512" additionalCoordinate-t="3" />
      <rotation xRot="0.0" yRot="0.0" zRot="0.0" />
      <nativelyRenderedLayer datasetLayer="color" />
      <tdCamera left="-500.0" right="500.0" top="400.0" bottom="-400.0">
        <position x="1024.0" y="1024.0" z="2000.0" />
        <up x="0.0" y="0.0" z="-1.0" />
      </tdCamera>
      <layer datasetLayer="color" isDisabled="false" isInverted="false" gammaCorrectionValue="1.0">
        <intensityRange min="0.0" max="255.0" />
        <color r="255.0" g="255.0" b="255.0" />
      </layer>
      <layer volumeLayer="Volume Layer" meshFileName="meshfile">
        <mapping editableMappingOfVolumeLayer="Volume Layer" mappingType="AGGLOMERATE" />
        <mesh segmentId="1" isPrecomputed="true" meshFileName="meshfile">
          <seedPosition x="1475" y="987" z="512" />
        </mesh>
      </layer>
    </state>
  </bookmark>
</bookmarks>
  • <bookmark>: One bookmark.
    • id (required): Unique integer bookmark ID.
    • created (required): Unix timestamp (ms) of creation.
    • name, description (optional): Free text.
    • <thumbnail> (optional, up to two): A small or large JPEG thumbnail. location is the path of the image within the annotation ZIP archive. Missing thumbnails are ignored on upload. viewport (optional) is the viewport the thumbnail shows: xy, yz, xz, 3d or flight. All thumbnails of a bookmark show the same viewport.
    • <metadata> (optional): Contains <metadataEntry> child elements.
    • <state> (required): The view that the bookmark restores.
  • <state> attributes:
    • mode (required): orthogonal or flight.
    • zoomStep, clippingDistance (required): Floats.
    • clipSkeletonToCurrentSection (required): Boolean.
    • activeNodeId (optional): The active skeleton node.
    • showSkeletons (optional): Boolean.
    • <position> (required): x, y, z in voxels, plus additionalCoordinate-<name> attributes for additional axes.
    • <rotation> (required): xRot, yRot, zRot.
    • <nativelyRenderedLayer> (optional): A layer reference (see below). If set, this layer is rendered without transforms.
    • <tdCamera> (optional): The camera of the 3D viewport, with left, right, top, bottom and <position>, <up> vectors.
    • <layer> (optional, multiple): Settings of one layer, identified by a layer reference. Optional attributes isDisabled, isInverted, gammaCorrectionValue, meshFileName and optional children <intensityRange min max>, <color r g b> (0–255), <mapping> (the active mapping) and <mesh> (visible meshes).
    • <mapping>: A mapping reference (see below) and mappingType (JSON or AGGLOMERATE).
    • <mesh>: segmentId, isPrecomputed, <seedPosition x y z>, and optionally meshFileName (precomputed meshes) or a mapping reference with mappingType (ad-hoc meshes).
  • Layers are referenced by exactly one of datasetLayer="<name>" (a layer of the dataset), volumeLayer="<name>" (a <volume> of this NML, by its name) or skeletonLayer="true".
  • Mappings are referenced by mappingName="<name>", or by editableMappingOfVolumeLayer="<name>" for the editable mapping (proofreading) of a <volume> of this NML.