Skip to content

Instantly share code, notes, and snippets.

@will-moore
will-moore / deleteBatchImageExport.py
Created September 4, 2014 09:35
Delete OMERO file attachments created by the 'Batch Image Export' script
from omero.gateway import BlitzGateway
from omero.constants.namespaces import NSCREATED
user = 'root'
pw = 'omero'
host = 'localhost'
conn = BlitzGateway(user, pw, host=host, port=4064)
@will-moore
will-moore / invertImage.py
Created January 14, 2016 23:01
Example of how to subclass OMERO gateway to extend renderImage() as requested in http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2016-January/003560.html
# Example of how to subclass ImageWrapper to extend renderImage()
# First part of this can be placed in a different python file
# As long as it is imported before being used
import omero
import omero.gateway
import PIL.ImageOps
class NewImageWrapper (omero.gateway.ImageWrapper):
@will-moore
will-moore / channelIntensityToTable.py
Last active August 6, 2019 08:25
Python script for to generate an OMERO.table on a Plate from channel min/max values
import omero
from omero.rtypes import rstring
import omero.grid
from omero.gateway import BlitzGateway
USERNAME = "will"
PASSWORD = "ome"
HOST = "localhost"
PORT = 4064

This is how I tested the performance of OMERO.webclient paths_to_object, handling pagination of the object when in a Dataset or Orphaned collection of many images, as described ome/openmicroscopy#4511

First, I added print statements to components/tools/OmeroWeb/omeroweb/webclient/views.py to print the time that paths_to_object takes to return:

+    n = time()
     paths = paths_to_object(conn, experimenter_id, project_id, dataset_id,
                             image_id, screen_id, plate_id, acquisition_id,

well_id, group_id)

@will-moore
will-moore / reimport.py
Created March 25, 2016 11:40
Python script for downloading and re-importing an image into OMERO
import subprocess
from omero.gateway import BlitzGateway
conn = BlitzGateway("username", "passwork", port=4064, host="localhost")
conn.connect()
image = conn.getObject("Image", 54973)
dataset = image.getParent()
@will-moore
will-moore / customAnnotations.py
Created April 27, 2016 10:53
Simple python script for adding Custom Annotations to an object in OMERO
import omero
from omero.gateway import BlitzGateway
conn = BlitzGateway("ben", "ome", host='localhost', port=4064)
conn.connect()
conn.SERVICE_OPTS.setOmeroGroup('-1')
update = conn.getUpdateService()
projectId = 1
project = conn.getObject("Project", projectId)
omero=# select * from dbpatch;
id | currentpatch | currentversion | permissions | finished | message | previouspatch | previousversion | external_id
----+--------------+----------------+-------------+----------------------------+----------------------------------------------------------------------------------------------+---------------+-----------------+-------------
28 | 19 | OMERO5.1DEV | -52 | 2015-02-17 10:50:02.216445 | Database updated. | 18 | OMERO5.1DEV |
1 | 7 | OMERO5.1DEV | -52 | 2014-07-24 11:11:25.913143 | Database ready. | 0 | OMERO5.1DEV |
2 | 8 | OMERO5.1DEV | -52 | 2014-08-19 11:18:11.136204 | Database updated.
# Alternatively start with omero shell, instead of first 2 lines below, do this:
# $ bin/omero shell --login
# conn = omero.gateway.BlitzGateway(client_obj=client)
conn = BlitzGateway("will", "ome", host="localhost", port=4064)
conn.connect()
updateService = conn.getUpdateService()
roiService = conn.getRoiService()
from omero.rtypes import rstring
imageId = 3731
@will-moore
will-moore / Plot_csv.py
Last active June 1, 2016 11:31
OMERO script to download csv attached to images and upload a plot as a new image
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero.scripts as scripts
from omero.gateway import BlitzGateway
from omero.rtypes import rstring, rlong
import numpy
try:
from PIL import Image # see ticket:2597