Created
November 20, 2017 22:30
-
-
Save will-moore/9e26659e04a8210f69488864a2c06f35 to your computer and use it in GitHub Desktop.
Set PlaneInfo with deltaT values for an Image in OMERO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import omero | |
from omero.gateway import BlitzGateway | |
from omero.model.enums import UnitsTime | |
from omero.model import PlaneInfoI | |
from omero.rtypes import rint, unwrap | |
conn = BlitzGateway("user", "password", host="eel.openmicroscopy.org", port=14064) | |
conn.connect() | |
imageId = 24552; | |
deltaT = 300 | |
image = conn.getObject("Image", imageId); | |
params = omero.sys.ParametersI() | |
params.addLong('pid', image.getPixelsId()) | |
query = "from PlaneInfo as Info where"\ | |
" Info.theZ=0 and Info.theC=0 and pixels.id=:pid" | |
info_list = conn.getQueryService().findAllByQuery( | |
query, params, conn.SERVICE_OPTS) | |
print 'info_list', len(info_list) | |
if len(info_list) == 0: | |
print "Creating info...", image.getSizeT() | |
info_list = [] | |
for t_index in range(image.getSizeT()): | |
print ' t', t_index | |
info = PlaneInfoI() | |
info.theT = rint(t_index) | |
info.theZ = rint(0) | |
info.theC = rint(0) | |
info.pixels = omero.model.PixelsI(image.getPixelsId(), False) | |
dt = t_index * deltaT | |
u = omero.model.TimeI(dt, UnitsTime.SECOND) | |
info.deltaT = u | |
info_list.append(info) | |
else: | |
for info in info_list: | |
print 'theT', unwrap(info.theT), 'theZ', unwrap(info.theZ), 'theT', unwrap(info.theT) | |
t_index = info.theT.getValue() | |
dt = t_index * deltaT | |
u = omero.model.TimeI(dt, UnitsTime.SECOND) | |
info.deltaT = u | |
print "Saving info_list", len(info_list) | |
conn.getUpdateService().saveArray(info_list) | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment