Last active
April 24, 2019 12:26
-
-
Save will-moore/7a37a2c48bbfc5a247cb54c2d876c79c to your computer and use it in GitHub Desktop.
Reset rendering defs in OMERO, and regenerate thumbnails.
This file contains 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 | |
# See https://www.openmicroscopy.org/community/viewtopic.php?f=4&t=8728 | |
conn = BlitzGateway("username", "password", host="localhost", port=4064) | |
conn.connect() | |
# Supports "Project", "Dataset" or "Image" | |
obj_type = "Project" | |
obj_ids = [18759, 18760] | |
# get the first object and set the group to match | |
conn.SERVICE_OPTS.setOmeroGroup('-1') | |
o = conn.getObject(obj_type, obj_ids[0]) | |
if o is not None: | |
gid = o.getDetails().group.id.val | |
conn.SERVICE_OPTS.setOmeroGroup(gid) | |
# Reset rendering settings | |
rss = conn.getRenderingSettingsService() | |
rv = rss.resetDefaultsInSet(obj_type, obj_ids, conn.SERVICE_OPTS) | |
# Recreate Thumbnails | |
def getDatasetThumbs(dataset_id): | |
dataset = conn.getObject("Dataset", dataset_id) | |
image_ids = [i.id for i in dataset.listChildren()] | |
conn.getThumbnailSet(image_ids, max_size=96) | |
if obj_type == "Project": | |
for pid in obj_ids: | |
project = conn.getObject("Project", pid) | |
for ds in project.listChildren(): | |
getDatasetThumbs(ds.id) | |
elif obj_type == "Dataset": | |
for did in obj_ids: | |
getDatasetThumbs(did) | |
elif obj_type == "Image": | |
conn.getThumbnailSet(obj_ids, max_size=96) | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment