From efdee36e97e6193daac938ce73cc2b4df387a8fa Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 13 Sep 2024 08:51:05 +0100 Subject: [PATCH 1/3] don't attempt ROI stats on big images --- omero/export_scripts/Batch_ROI_Export.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/omero/export_scripts/Batch_ROI_Export.py b/omero/export_scripts/Batch_ROI_Export.py index 75e9fad02..5b449a05f 100644 --- a/omero/export_scripts/Batch_ROI_Export.py +++ b/omero/export_scripts/Batch_ROI_Export.py @@ -41,6 +41,12 @@ def log(data): print(data) +def is_big_image(image): + """Return True if image is tiled.""" + maxSize = image._conn.getMaxPlaneSize() + return (image.getSizeX() * image.getSizeY()) > (maxSize[0] * maxSize[1]) + + def get_export_data(conn, script_params, image, units=None): """Get pixel data for shapes on image and returns list of dicts.""" log("Image ID %s..." % image.id) @@ -110,7 +116,7 @@ def get_export_data(conn, script_params, image, units=None): # get pixel intensities for z in z_indexes: for t in t_indexes: - if z is None or t is None: + if z is None or t is None or is_big_image(image): stats = None else: stats = roi_service.getShapeStatsRestricted( From d33f646628be8fa0059215e80b476f977d5af136 Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 13 Sep 2024 09:06:07 +0100 Subject: [PATCH 2/3] Call is_big_image() once per image --- omero/export_scripts/Batch_ROI_Export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/omero/export_scripts/Batch_ROI_Export.py b/omero/export_scripts/Batch_ROI_Export.py index 5b449a05f..878bce50b 100644 --- a/omero/export_scripts/Batch_ROI_Export.py +++ b/omero/export_scripts/Batch_ROI_Export.py @@ -64,6 +64,7 @@ def get_export_data(conn, script_params, image, units=None): all_planes = script_params["Export_All_Planes"] include_points = script_params.get("Include_Points_Coords", False) size_c = image.getSizeC() + big_image = is_big_image(image) # Channels index channels = script_params.get("Channels", [1]) ch_indexes = [] @@ -116,7 +117,7 @@ def get_export_data(conn, script_params, image, units=None): # get pixel intensities for z in z_indexes: for t in t_indexes: - if z is None or t is None or is_big_image(image): + if z is None or t is None or big_image: stats = None else: stats = roi_service.getShapeStatsRestricted( From d8b2bbd6f5066de883a41ba5338662d60472b0d8 Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 13 Sep 2024 09:21:07 +0100 Subject: [PATCH 3/3] Flake8 fix --- omero/export_scripts/Batch_ROI_Export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/omero/export_scripts/Batch_ROI_Export.py b/omero/export_scripts/Batch_ROI_Export.py index 878bce50b..1113f0aea 100644 --- a/omero/export_scripts/Batch_ROI_Export.py +++ b/omero/export_scripts/Batch_ROI_Export.py @@ -43,8 +43,8 @@ def log(data): def is_big_image(image): """Return True if image is tiled.""" - maxSize = image._conn.getMaxPlaneSize() - return (image.getSizeX() * image.getSizeY()) > (maxSize[0] * maxSize[1]) + max_size = image._conn.getMaxPlaneSize() + return (image.getSizeX() * image.getSizeY()) > (max_size[0] * max_size[1]) def get_export_data(conn, script_params, image, units=None):