From 3c170054f782fb9ac230c740c32dceac9e50c618 Mon Sep 17 00:00:00 2001 From: Tom-TBT Date: Fri, 11 Oct 2024 11:38:48 +0200 Subject: [PATCH 1/2] wider timestamp query when C or Z dim not filled --- omero_figure/omeroutils.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/omero_figure/omeroutils.py b/omero_figure/omeroutils.py index 279d08882..aeed7f0d7 100644 --- a/omero_figure/omeroutils.py +++ b/omero_figure/omeroutils.py @@ -29,6 +29,24 @@ def get_timestamps(conn, image): " Info.theZ=0 and Info.theC=0 and pixels.id=:pid" info_list = conn.getQueryService().findAllByQuery( query, params, conn.SERVICE_OPTS) + + if len(info_list) < image.getSizeT(): + # C & Z dimensions are not always filled + # Remove restriction on c0 z0 to catch all timestamps + params = ParametersI() + params.addLong('pid', image.getPixelsId()) + query = """ + from PlaneInfo Info where Info.pixels.id=:pid + and Info.id in ( + select min(subInfo.id) + from PlaneInfo subInfo + where subInfo.pixels.id=:pid + group by subInfo.theT + ) + """ + info_list = conn.getQueryService().findAllByQuery( + query, params, conn.SERVICE_OPTS) + timemap = {} # check if any PlaneInfo was found if len(info_list) > 0: @@ -40,6 +58,7 @@ def get_timestamps(conn, image): plane_info = PlaneInfoWrapper(conn, info) delta_t = plane_info.getDeltaT('SECOND') timemap[t_index] = delta_t.getValue() + # double check to see if timemap actually got populated if len(info_list) == 0 or len(timemap) == 0: # get time info from the timeIncrement of the Pixels @@ -58,8 +77,14 @@ def get_timestamps(conn, image): if converted_value != 0: for i in range(image.getSizeT()): timemap[i] = i*converted_value + time_list = [] for t in range(image.getSizeT()): if t in timemap: time_list.append(timemap[t]) + else: + # Hopefully never gets here, but + # time_list length MUST match image.sizeT + time_list.append(0) + return time_list From 69b42637f74e4caf1feab8af6faae3757be92525 Mon Sep 17 00:00:00 2001 From: Tom Boissonnet Date: Tue, 19 Nov 2024 15:10:09 +0100 Subject: [PATCH 2/2] simplified timestamp query --- omero_figure/omeroutils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/omero_figure/omeroutils.py b/omero_figure/omeroutils.py index aeed7f0d7..a37041d2e 100644 --- a/omero_figure/omeroutils.py +++ b/omero_figure/omeroutils.py @@ -36,8 +36,7 @@ def get_timestamps(conn, image): params = ParametersI() params.addLong('pid', image.getPixelsId()) query = """ - from PlaneInfo Info where Info.pixels.id=:pid - and Info.id in ( + from PlaneInfo Info where Info.id in ( select min(subInfo.id) from PlaneInfo subInfo where subInfo.pixels.id=:pid