Skip to content

Commit 0881e93

Browse files
Fix mag and attachment paths in Zarr annotation volume layer export (#1401)
* Update mag and attachment paths in volume layer export * Update Changelog
1 parent cc30bdc commit 0881e93

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1919
### Changed
2020

2121
### Fixed
22+
- Fix mag and attachment paths in Zarr annotation volume layer export. [#1401](https://github.com/scalableminds/webknossos-libs/pull/1401)
2223

2324

2425
## [3.0.4](https://github.com/scalableminds/webknossos-libs/releases/tag/v3.0.4) - 2025-11-26

webknossos/webknossos/annotation/volume_layer.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121

2222
from webknossos.dataset_properties import (
2323
SEGMENTATION_CATEGORY,
24+
AttachmentProperties,
2425
DataFormat,
2526
DatasetProperties,
27+
MagViewProperties,
28+
SegmentationLayerProperties,
2629
get_dataset_converter,
2730
)
2831

@@ -283,10 +286,38 @@ def export_to_dataset(
283286
assert len(datasource_properties.data_layers) == 1, (
284287
f"Volume data zip must contain exactly one layer, got {len(datasource_properties.data_layers)}"
285288
)
286-
layer_properties = datasource_properties.data_layers[0]
289+
layer_properties = cast(
290+
SegmentationLayerProperties, datasource_properties.data_layers[0]
291+
)
287292
internal_layer_name = layer_properties.name
288293
layer_properties.name = layer_name
289294

295+
def replace_property_path(
296+
layer_property: AttachmentProperties | None,
297+
) -> None:
298+
if layer_property:
299+
layer_property.path = layer_property.path.replace(
300+
internal_layer_name, layer_name
301+
)
302+
303+
def replace_properties_path(
304+
properties: Sequence[AttachmentProperties | MagViewProperties]
305+
| None,
306+
) -> None:
307+
if properties:
308+
for layer_property in properties:
309+
if layer_property.path:
310+
layer_property.path = layer_property.path.replace(
311+
internal_layer_name, layer_name
312+
)
313+
314+
replace_properties_path(layer_properties.mags)
315+
replace_properties_path(layer_properties.attachments.meshes)
316+
replace_properties_path(layer_properties.attachments.agglomerates)
317+
replace_property_path(layer_properties.attachments.segment_index)
318+
replace_property_path(layer_properties.attachments.cumsum)
319+
replace_properties_path(layer_properties.attachments.connectomes)
320+
290321
_extract_zip_folder(
291322
data_zip, dataset.path / layer_name, f"{internal_layer_name}/"
292323
)

0 commit comments

Comments
 (0)