Skip to content

Create volume annotations #1318

@normanrz

Description

@normanrz

Detailed Description

It would be nice, if the webknossos package could be used to create volume annotations, which can later be uploaded to WK. The volume layer could be backed by either by a temporary directory or by the memory:// kvstore in tensorstore. Memory would be more lightweight and would self-cleanup, but temporary directory might be better for multiprocessing.

ann = Annotation(
    name="my_annotation",
    dataset_name="sample_dataset", voxel_size=(11.2, 11.2, 25.0), # better: dataset=Dataset.open_remote("...")
)
# with memory backing
volume_layer = ann.add_volume_layer(name="segmentation")
assert isinstance(volume_layer, SegmentationLayer)
mag = volume_layer.add_mag(1)
mag.write(data, absolute_offset=(0, 0, 0))
volume_layer.downsample()
ann.save("...") # or ann.upload()

# or with a temp directory
volume_layer = ann.add_volume_layer(name="segmentation")
with volume_layer.edit() as seg_layer:
    assert isinstance(seg_layer, SegmentationLayer)
    mag = seg_layer.add_mag(1)
    mag.write(data, absolute_offset=(0, 0, 0))
    seg_layer.downsample()
    ann.save("...") # or ann.upload()

I think I would ignore the fallback_layer scenario for this issue, i.e. only support it for new volume annotation layers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions