From f0caad760ba899f3e97a51607df3db0131945859 Mon Sep 17 00:00:00 2001 From: MatthisCl <76970409+MatthisCl@users.noreply.github.com> Date: Fri, 6 Dec 2024 12:42:39 +0100 Subject: [PATCH] fix buffer_bbox offset (#1209) * fix buffer_bbox offset * Add assertion to check means after upsampling * formatting * add changelog entry --- webknossos/Changelog.md | 1 + webknossos/tests/dataset/test_upsampling.py | 2 ++ webknossos/webknossos/dataset/_upsampling_utils.py | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/webknossos/Changelog.md b/webknossos/Changelog.md index 8702f34aa..7e4d877bc 100644 --- a/webknossos/Changelog.md +++ b/webknossos/Changelog.md @@ -35,6 +35,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section ### Fixed - Fixed unpickling of the SSL_Context to allow for a second or third pickling. [#1223](https://github.com/scalableminds/webknossos-libs/pull/1223) +- Fixed offset error in upsample_cube job [#1209](https://github.com/scalableminds/webknossos-libs/pull/1209) diff --git a/webknossos/tests/dataset/test_upsampling.py b/webknossos/tests/dataset/test_upsampling.py index 0879703bc..687395264 100644 --- a/webknossos/tests/dataset/test_upsampling.py +++ b/webknossos/tests/dataset/test_upsampling.py @@ -45,6 +45,8 @@ def test_upsampling(tmp_path: Path) -> None: args=None, ) + assert layer.get_mag("2").read().mean() == layer.get_mag("1").read().mean() + def test_upsample_cube() -> None: buffer = np.zeros(BUFFER_SHAPE, dtype=np.uint8) diff --git a/webknossos/webknossos/dataset/_upsampling_utils.py b/webknossos/webknossos/dataset/_upsampling_utils.py index eaa551ace..8d5fa731d 100644 --- a/webknossos/webknossos/dataset/_upsampling_utils.py +++ b/webknossos/webknossos/dataset/_upsampling_utils.py @@ -74,7 +74,7 @@ def upsample_cube_job( data_cube = upsample_cube(cube_buffer, inverse_factors) buffer_bbox = target_view.bounding_box.with_topleft_xyz( - target_offset + target_offset * inverse_factors ).with_size_xyz(data_cube.shape) data_cube = buffer_bbox.xyz_array_to_bbox_shape(data_cube) file_buffer[(channel_index,) + buffer_bbox.to_slices_xyz()] = (