Skip to content

Commit 0fc495a

Browse files
erjelnormanrzhotzenklotz
authored
Fix merging annotations with compressed fallback layers (#1191)
* tests: Add failing test * bugfix: Extend output layer bounding box to prevent concurrent writes to properties * doc: Add changelog message * rf: Change formatting --------- Co-authored-by: Norman Rzepka <[email protected]> Co-authored-by: Tom Herold <[email protected]>
1 parent 4a21fbd commit 0fc495a

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

webknossos/Changelog.md

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

2222
### Fixed
23+
- Fixed an issue with merging annotations with compressed fallback layers.
2324

2425

2526
## [0.15.6](https://github.com/scalableminds/webknossos-libs/releases/tag/v0.15.6) - 2024-10-16

webknossos/tests/test_cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,10 @@ def test_export_tiff_stack_tiles_per_dimension(tmp_path: Path) -> None:
542542
)
543543

544544

545-
def test_merge_fallback_no_fallback_layer(tmp_path: Path) -> None:
545+
@pytest.mark.parametrize("use_compression", [True, False])
546+
def test_merge_fallback_no_fallback_layer(
547+
tmp_path: Path, use_compression: bool
548+
) -> None:
546549
from zipfile import ZIP_DEFLATED, ZipFile
547550
from zlib import Z_BEST_SPEED
548551

@@ -558,7 +561,12 @@ def test_merge_fallback_no_fallback_layer(tmp_path: Path) -> None:
558561
SEGMENTATION_CATEGORY,
559562
dtype_per_channel=fallback_layer_data.dtype,
560563
)
561-
.add_mag(1, chunk_shape=(32,) * 3, chunks_per_shard=(1,) * 3)
564+
.add_mag(
565+
1,
566+
chunk_shape=(32,) * 3,
567+
chunks_per_shard=(1,) * 3,
568+
compress=use_compression,
569+
)
562570
)
563571

564572
fallback_mag.write(absolute_offset=(0,) * 3, data=fallback_layer_data)

webknossos/webknossos/dataset/mag_view.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,13 @@ def merge_with_view(
491491
bboxes, Mag(self.info.shard_shape * self.mag)
492492
)
493493

494+
new_bbox = self.bounding_box
495+
for shard_bbox in shards_with_bboxes.keys():
496+
new_bbox = new_bbox.extended_by(shard_bbox)
497+
498+
logging.info(f"Set mag layer bounding box to {new_bbox}")
499+
self.layer.bounding_box = new_bbox
500+
494501
args = [(other, shard, bboxes) for shard, bboxes in shards_with_bboxes.items()]
495502

496503
logging.info("Merging %s shards.", len(args))

0 commit comments

Comments
 (0)