Skip to content

Commit 1202254

Browse files
authored
SegmentationLayer attachments (#1312)
* wip attachments * py3.10 * implement fixes for symlinks etc * changelog * add Dataset.get_segmentation_layer * add test for upload * add name to attachments * pr feedback * tests + docs * add Dataset.fs_copy_dataset * fixes for shallow_copy_dataset * more work on shallow and remote copies * threadpool for copytree * resolved path * add add_attachments * types * add test for add_attachments * detect_legacy_attachments * make dataset_path optional in Attachment.from_path_and_name * imports * alter the filenames based on the attachment name in add_copy_attachments and add_symlink_attachments * variadic
1 parent efbc32c commit 1202254

File tree

13 files changed

+1304
-117
lines changed

13 files changed

+1304
-117
lines changed

webknossos/Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616

1717
### Added
18+
- Added a feature to track attached files of a segmentation layer. Previously, these files were only auto-detected by WEBKNOSSOS based on the location in special folders. Attachments can be added, e.g. `dataset.get_segmentation_layer("segmentation").attachments.add_mesh('path/to/meshfile.hdf5')`. [#1312](https://github.com/scalableminds/webknossos-libs/pull/1312)
19+
- Added a `with_attachments` parameter to `Dataset.copy_dataset` to copy attachments. [#1312](https://github.com/scalableminds/webknossos-libs/pull/1312)
20+
- Added a `get_segmentation_layer` method to `Dataset` to get a correctly-typed segmentation layer by name. [#1312](https://github.com/scalableminds/webknossos-libs/pull/1312)
1821

1922
### Changed
2023
- When adding a layer, the used dtype is only valid if it is supported by webknossos. [#1316](https://github.com/scalableminds/webknossos-libs/pull/1316)

webknossos/examples/apply_merger_mode.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from pathlib import Path
2-
from typing import cast
32

43
import fastremap
54

@@ -26,7 +25,7 @@ def main() -> None:
2625
bbox=wk.BoundingBox((3457, 3323, 1204), (40, 10, 10)),
2726
path="testoutput/l4_sample",
2827
)
29-
in_layer = cast(wk.SegmentationLayer, dataset.get_layer("segmentation"))
28+
in_layer = dataset.get_segmentation_layer("segmentation")
3029
in_mag1 = in_layer.get_mag("1")
3130

3231
##############################

webknossos/examples/download_segments.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import webknossos as wk
55

66
ANNOTATION_ID = "634e8fe1010000b4006f3cf4"
7+
SEGMENTATION_LAYER_NAME = "segmentation"
78
SEGMENT_IDS = [32, 667325]
89
MAG = wk.Mag("8-8-2")
910

@@ -12,7 +13,7 @@ def main() -> None:
1213
dataset = wk.Annotation.open_as_remote_dataset(
1314
ANNOTATION_ID, webknossos_url="https://webknossos.org"
1415
)
15-
mag_view = dataset.get_segmentation_layers()[0].get_mag(MAG)
16+
mag_view = dataset.get_segmentation_layer(SEGMENTATION_LAYER_NAME).get_mag(MAG)
1617

1718
z = mag_view.bounding_box.topleft.z
1819
with mag_view.get_buffered_slice_reader() as reader:

0 commit comments

Comments
 (0)