Skip to content

Commit faf8213

Browse files
authored
In pims tiff reader, leave chunks black that yield KeyError when accessing zarr store (#1388)
* In pims tiff reader, leave chunks black that yield KeyError when accessing zarr store * changelog * lint * Revert "lint" This reverts commit 28619db. * disable linter rule for this line
1 parent a760a09 commit faf8213

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

webknossos/Changelog.md

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

2121
### Fixed
22+
- Fixed a bug where some tiff images could not be correctly converted to wkw/zarr, yielding KeyErrors. [#1388](https://github.com/scalableminds/webknossos-libs/pull/1388)
2223

2324

2425
## [3.0.0](https://github.com/scalableminds/webknossos-libs/releases/tag/v3.0.0) - 2025-10-28

webknossos/webknossos/dataset/_utils/pims_tiff_reader.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,21 @@ def get_frame_2D(self, **ind: int) -> np.ndarray:
198198
for chunk_projection in _chunk_indexing(
199199
selection, array_shape, chunk_shape
200200
):
201-
# read data from zarr store
202-
chunk_data = (
203-
zarr_store[".".join(map(str, chunk_projection.chunk_coords))]
204-
.ravel()
205-
.reshape(chunk_shape)
206-
)
207-
# write in output array
208-
out[chunk_projection.out_selection] = chunk_data[
209-
chunk_projection.chunk_selection
210-
]
201+
try:
202+
# read data from zarr store
203+
chunk_data = (
204+
zarr_store[".".join(map(str, chunk_projection.chunk_coords))]
205+
.ravel()
206+
.reshape(chunk_shape)
207+
)
208+
# write in output array
209+
out[chunk_projection.out_selection] = chunk_data[
210+
chunk_projection.chunk_selection
211+
]
212+
except KeyError:
213+
# chunk not present in zarr_store, leave black.
214+
# ruff: noqa: PERF203 try-catch is still faster than in for the ZarrStore
215+
pass
211216

212217
return out
213218

0 commit comments

Comments
 (0)