From 8bdfad09cb6d87b96e62351b8852bad01a493b39 Mon Sep 17 00:00:00 2001 From: David Ackerman Date: Fri, 13 Mar 2026 10:54:30 -0400 Subject: [PATCH] Handle multichannel metadata by stripping channel dimensions from voxel_size and adjusting ROI and offset accordingly. --- src/cellmap_analyze/util/image_data_interface.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cellmap_analyze/util/image_data_interface.py b/src/cellmap_analyze/util/image_data_interface.py index d5d472b..d98e951 100644 --- a/src/cellmap_analyze/util/image_data_interface.py +++ b/src/cellmap_analyze/util/image_data_interface.py @@ -288,6 +288,14 @@ def __init__( self.roi = self.ds.roi self.offset = self.ds.roi.offset + # Handle multichannel metadata: if funlib parsed >3D voxel_size + # (e.g. from 4D OME-Zarr metadata with channel axis), strip channel dims + if len(self.voxel_size) > 3: + n_extra = len(self.voxel_size) - 3 + self.voxel_size = Coordinate(self.voxel_size[n_extra:]) + self.roi = Roi(self.roi.begin[n_extra:], self.roi.shape[n_extra:]) + self.offset = self.roi.offset + if "voxel_size" in self.ds.data.attrs: voxel_size = Coordinate(self.ds.data.attrs["voxel_size"]) if self.voxel_size != voxel_size: