From 55926def3e7b2de68b4291fbda8be9dc3b9d8b7f Mon Sep 17 00:00:00 2001 From: Norman Rzepka Date: Mon, 27 Oct 2025 14:14:31 +0100 Subject: [PATCH 1/3] fix numbering in export-as-tiff CLI --- webknossos/webknossos/cli/export_as_tiff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webknossos/webknossos/cli/export_as_tiff.py b/webknossos/webknossos/cli/export_as_tiff.py index 4904f7e52..f52d03156 100644 --- a/webknossos/webknossos/cli/export_as_tiff.py +++ b/webknossos/webknossos/cli/export_as_tiff.py @@ -97,7 +97,7 @@ def export_tiff_slice( tiff_data = padded_tiff_data for slice_index in range(tiff_bbox.size.z): slice_name_number = ( - tiff_bbox_mag1.topleft.z + slice_index + 1 - start_slice_index + tiff_bbox_mag1.topleft.z + slice_index * view.mag.z - start_slice_index ) if tiling_size is None: tiff_file_name = _make_tiff_name(name, slice_name_number) From 9592524d30900803baca0635541c0fe2aff439e3 Mon Sep 17 00:00:00 2001 From: Florian M Date: Thu, 30 Oct 2025 13:34:55 +0100 Subject: [PATCH 2/3] rename some variables --- webknossos/webknossos/cli/export_as_tiff.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webknossos/webknossos/cli/export_as_tiff.py b/webknossos/webknossos/cli/export_as_tiff.py index f52d03156..e7b624659 100644 --- a/webknossos/webknossos/cli/export_as_tiff.py +++ b/webknossos/webknossos/cli/export_as_tiff.py @@ -67,12 +67,12 @@ def _slice_to_image(data_slice: np.ndarray, downsample: int = 1) -> Image.Image: return Image.fromarray(data_slice) -def export_tiff_slice( +def export_tiff_slice_batch( dest_path: UPath, name: str, tiling_size: None | tuple[int, int], downsample: int, - start_slice_index: int, + start_slice_z_mag1: int, view: View, ) -> None: tiff_bbox_mag1 = view.bounding_box @@ -97,7 +97,7 @@ def export_tiff_slice( tiff_data = padded_tiff_data for slice_index in range(tiff_bbox.size.z): slice_name_number = ( - tiff_bbox_mag1.topleft.z + slice_index * view.mag.z - start_slice_index + tiff_bbox_mag1.topleft.z + slice_index * view.mag.z - start_slice_z_mag1 ) if tiling_size is None: tiff_file_name = _make_tiff_name(name, slice_name_number) @@ -165,7 +165,7 @@ def export_tiff_stack( wait_and_ensure_success( executor.map_to_futures( partial( - export_tiff_slice, + export_tiff_slice_batch, destination_path, name, tiling_slice_size, From e1410cb5c86db02c4c96e2b3f4de4d0fc9d2cf11 Mon Sep 17 00:00:00 2001 From: Florian M Date: Thu, 30 Oct 2025 13:37:39 +0100 Subject: [PATCH 3/3] changelog --- webknossos/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/webknossos/Changelog.md b/webknossos/Changelog.md index 7c6ce9bd6..4f98e1b43 100644 --- a/webknossos/Changelog.md +++ b/webknossos/Changelog.md @@ -45,6 +45,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section ### Fixed - Fixed test.py to parse the command line arguments correctly. [#1383](https://github.com/scalableminds/webknossos-libs/pull/1383) +- Fixed a bug in the CLI tool export_as_tiff, where filenames would not match the data z position exactly. [#1387](https://github.com/scalableminds/webknossos-libs/pull/1387) ## [2.5.0](https://github.com/scalableminds/webknossos-libs/releases/tag/v2.5.0) - 2025-10-06 [Commits](https://github.com/scalableminds/webknossos-libs/compare/v2.4.12...v2.5.0)