Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query timestamps from all planes when C or Z dimensions are not filled #598

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions omero_figure/omeroutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ 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.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:
Expand All @@ -40,6 +57,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
Expand All @@ -58,8 +76,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