Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions webknossos/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
### Changed

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


## [3.0.4](https://github.com/scalableminds/webknossos-libs/releases/tag/v3.0.4) - 2025-11-26
Expand Down
33 changes: 32 additions & 1 deletion webknossos/webknossos/annotation/volume_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

from webknossos.dataset_properties import (
SEGMENTATION_CATEGORY,
AttachmentProperties,
DataFormat,
DatasetProperties,
MagViewProperties,
SegmentationLayerProperties,
get_dataset_converter,
)

Expand Down Expand Up @@ -283,10 +286,38 @@ def export_to_dataset(
assert len(datasource_properties.data_layers) == 1, (
f"Volume data zip must contain exactly one layer, got {len(datasource_properties.data_layers)}"
)
layer_properties = datasource_properties.data_layers[0]
layer_properties = cast(
SegmentationLayerProperties, datasource_properties.data_layers[0]
)
internal_layer_name = layer_properties.name
layer_properties.name = layer_name

def replace_property_path(
layer_property: AttachmentProperties | None,
) -> None:
if layer_property:
layer_property.path = layer_property.path.replace(
internal_layer_name, layer_name
)

def replace_properties_path(
properties: Sequence[AttachmentProperties | MagViewProperties]
| None,
) -> None:
if properties:
for layer_property in properties:
if layer_property.path:
layer_property.path = layer_property.path.replace(
internal_layer_name, layer_name
)

replace_properties_path(layer_properties.mags)
replace_properties_path(layer_properties.attachments.meshes)
replace_properties_path(layer_properties.attachments.agglomerates)
replace_property_path(layer_properties.attachments.segment_index)
replace_property_path(layer_properties.attachments.cumsum)
replace_properties_path(layer_properties.attachments.connectomes)

_extract_zip_folder(
data_zip, dataset.path / layer_name, f"{internal_layer_name}/"
)
Expand Down
Loading