diff --git a/webknossos/Changelog.md b/webknossos/Changelog.md index 78628c5b2..3c8990235 100644 --- a/webknossos/Changelog.md +++ b/webknossos/Changelog.md @@ -60,6 +60,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 diff --git a/webknossos/webknossos/cli/export_as_tiff.py b/webknossos/webknossos/cli/export_as_tiff.py index 4904f7e52..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 + 1 - 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,