Skip to content

Instantly share code, notes, and snippets.

@will-moore
Created September 16, 2022 09:12
Show Gist options
  • Save will-moore/c5b379c4902ffdf62b2d7912101cb6c1 to your computer and use it in GitHub Desktop.
Save will-moore/c5b379c4902ffdf62b2d7912101cb6c1 to your computer and use it in GitHub Desktop.
rename images in a Plate in OMERO
# https://forum.image.sc/t/imports-of-tiff-to-omero/71648/9
# usage: with plate ID - You will be asked for login...
# $ python plate_rename_images.py 1234
import argparse
import sys
from omero.cli import cli_login
from omero.gateway import BlitzGateway
def rename_images(plate):
for well in plate.listChildren():
label = well.getWellPos()
for field, ws in enumerate(well.listChildren()):
img = ws.getImage()
name = f"{label} Field {field + 1}"
print(img.id, name)
img.setName(name)
img.save()
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('plate_id', help='Plate ID')
args = parser.parse_args(argv)
with cli_login() as cli:
conn = BlitzGateway(client_obj=cli._client)
plate = conn.getObject('Plate', args.plate_id)
rename_images(plate)
if __name__ == '__main__':
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment