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

implemented get_timestamps() from timeIncrement attribute #589

Merged
merged 7 commits into from
Oct 3, 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
37 changes: 30 additions & 7 deletions omero_figure/omeroutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

from omero.sys import ParametersI
from omero.gateway import PlaneInfoWrapper
from omero.model.enums import UnitsTime
from omero.model import TimeI


def get_timestamps(conn, image):
Expand All @@ -28,13 +30,34 @@ def get_timestamps(conn, image):
info_list = conn.getQueryService().findAllByQuery(
query, params, conn.SERVICE_OPTS)
timemap = {}
for info in info_list:
t_index = info.theT.getValue()
if info.deltaT is not None:
# Use wrapper to help unit conversion
plane_info = PlaneInfoWrapper(conn, info)
delta_t = plane_info.getDeltaT('SECOND')
timemap[t_index] = delta_t.getValue()
# check if any PlaneInfo was found
if len(info_list) > 0:
# get time info from the PlaneInfo
for info in info_list:
t_index = info.theT.getValue()
if info.deltaT is not None:
# Use wrapper to help unit conversion
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
time_increment = 0
converted_value = 0
try:
pixels = image.getPrimaryPixels()._obj
time_increment = pixels.getTimeIncrement()
secs_unit = getattr(UnitsTime, "SECOND")
seconds = TimeI(time_increment, secs_unit)
converted_value = seconds.getValue()

except Exception as error:
print(f"An exception occured: {error}\n"
"maybe the image has no 'timeIncrement' set")
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:
Expand Down