From 1043827edd5399abb01908389885264a219bb660 Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 18 Aug 2023 10:21:10 +0100 Subject: [PATCH] Check Well exists before trying to load data --- ome_zarr/reader.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ome_zarr/reader.py b/ome_zarr/reader.py index ccc4ea01..5e6fbcb6 100644 --- a/ome_zarr/reader.py +++ b/ome_zarr/reader.py @@ -537,6 +537,13 @@ def get_stitched_grid(self, level: int, tile_shape: tuple) -> da.core.Array: def get_tile(tile_name: str) -> np.ndarray: """tile_name is 'level,z,c,t,row,col'""" row, col = (int(n) for n in tile_name.split(",")) + + # check whether the Well exists at this row/column + well_path = f"{self.row_names[row]}/{self.col_names[col]}" + if well_path not in self.well_paths: + LOGGER.debug("empty well: %s", well_path) + return np.zeros(tile_shape, dtype=self.numpy_type) + path = self.get_tile_path(level, row, col) LOGGER.debug("LOADING tile... %s with shape: %s", path, tile_shape)