Skip to content

Commit a760a09

Browse files
normanrzfm3
andauthored
fix numbering in export-as-tiff CLI (#1387)
* fix numbering in export-as-tiff CLI * rename some variables * changelog --------- Co-authored-by: Florian M <[email protected]> Co-authored-by: Florian M <[email protected]>
1 parent 1ed362f commit a760a09

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

webknossos/Changelog.md

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

6161
### Fixed
6262
- Fixed test.py to parse the command line arguments correctly. [#1383](https://github.com/scalableminds/webknossos-libs/pull/1383)
63+
- 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)
6364

6465

6566
## [2.5.0](https://github.com/scalableminds/webknossos-libs/releases/tag/v2.5.0) - 2025-10-06

webknossos/webknossos/cli/export_as_tiff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ def _slice_to_image(data_slice: np.ndarray, downsample: int = 1) -> Image.Image:
6767
return Image.fromarray(data_slice)
6868

6969

70-
def export_tiff_slice(
70+
def export_tiff_slice_batch(
7171
dest_path: UPath,
7272
name: str,
7373
tiling_size: None | tuple[int, int],
7474
downsample: int,
75-
start_slice_index: int,
75+
start_slice_z_mag1: int,
7676
view: View,
7777
) -> None:
7878
tiff_bbox_mag1 = view.bounding_box
@@ -97,7 +97,7 @@ def export_tiff_slice(
9797
tiff_data = padded_tiff_data
9898
for slice_index in range(tiff_bbox.size.z):
9999
slice_name_number = (
100-
tiff_bbox_mag1.topleft.z + slice_index + 1 - start_slice_index
100+
tiff_bbox_mag1.topleft.z + slice_index * view.mag.z - start_slice_z_mag1
101101
)
102102
if tiling_size is None:
103103
tiff_file_name = _make_tiff_name(name, slice_name_number)
@@ -165,7 +165,7 @@ def export_tiff_stack(
165165
wait_and_ensure_success(
166166
executor.map_to_futures(
167167
partial(
168-
export_tiff_slice,
168+
export_tiff_slice_batch,
169169
destination_path,
170170
name,
171171
tiling_slice_size,

0 commit comments

Comments
 (0)