Skip to content

Merge Trees of two NML filesΒΆ

This example opens two NML files and copies the trees from the NML A to B and saves the output to a new NML (that includes the trees of both input NMLs). This example opens two NML files and copies the trees from the NML A to B and saves the output to a new NML (that includes the trees of both input NMLs).

import webknossos as wk


def main() -> None:
    skeleton_a = wk.Skeleton.load("./a.nml")
    skeleton_b = wk.Skeleton.load("./b.nml")

    for tree in skeleton_a.flattened_trees():
        skeleton_b.add_tree(tree)

    skeleton_b.save("./c.nml")


if __name__ == "__main__":
    main()