From a2feaf0ef246703de14aecb32faa02f06b44687a Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 13 Dec 2023 10:55:54 +0000 Subject: [PATCH 1/2] Ensure correct numpy dtype: f4 instead of f8 for 'float' --- src/omero_zarr/raw_pixels.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/omero_zarr/raw_pixels.py b/src/omero_zarr/raw_pixels.py index c49d987..1f424c1 100644 --- a/src/omero_zarr/raw_pixels.py +++ b/src/omero_zarr/raw_pixels.py @@ -33,6 +33,16 @@ write_well_metadata, ) from omero.model import Channel +from omero.model.enums import ( + PixelsTypedouble, + PixelsTypefloat, + PixelsTypeint8, + PixelsTypeint16, + PixelsTypeint32, + PixelsTypeuint8, + PixelsTypeuint16, + PixelsTypeuint32, +) from omero.rtypes import unwrap from zarr.hierarchy import Group, open_group @@ -99,7 +109,18 @@ def add_raw_image( tile_height: Optional[int] = None, ) -> List[str]: pixels = image.getPrimaryPixels() - d_type = image.getPixelsType() + pixelTypes = { + PixelsTypeint8: ["b", np.int8], + PixelsTypeuint8: ["B", np.uint8], + PixelsTypeint16: ["h", np.int16], + PixelsTypeuint16: ["H", np.uint16], + PixelsTypeint32: ["i", np.int32], + PixelsTypeuint32: ["I", np.uint32], + PixelsTypefloat: ["f", np.float32], + PixelsTypedouble: ["d", np.float64], + } + pixelType = pixels.getPixelsType().value + d_type = pixelTypes[pixelType][1] size_c = image.getSizeC() size_z = image.getSizeZ() size_x = image.getSizeX() From d1bb6e2633fb4e7da72b325a65a76d51e35eedec Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 13 Dec 2023 11:09:45 +0000 Subject: [PATCH 2/2] get omero_dtype in one line --- src/omero_zarr/raw_pixels.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/omero_zarr/raw_pixels.py b/src/omero_zarr/raw_pixels.py index 1f424c1..4054609 100644 --- a/src/omero_zarr/raw_pixels.py +++ b/src/omero_zarr/raw_pixels.py @@ -109,6 +109,7 @@ def add_raw_image( tile_height: Optional[int] = None, ) -> List[str]: pixels = image.getPrimaryPixels() + omero_dtype = image.getPixelsType() pixelTypes = { PixelsTypeint8: ["b", np.int8], PixelsTypeuint8: ["B", np.uint8], @@ -119,8 +120,7 @@ def add_raw_image( PixelsTypefloat: ["f", np.float32], PixelsTypedouble: ["d", np.float64], } - pixelType = pixels.getPixelsType().value - d_type = pixelTypes[pixelType][1] + d_type = pixelTypes[omero_dtype][1] size_c = image.getSizeC() size_z = image.getSizeZ() size_x = image.getSizeX()