Skip to content

Instantly share code, notes, and snippets.

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.
@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)
@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()

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 / 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
@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 / 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 / Metadata_Query.py
Created August 13, 2014 22:36
Using the OMERO query service to search for images based on metadata.
# DEMO of how to use code example at https://gist.github.com/will-moore/5782494#file-metadata_search-py-L13
import omero
from omero.rtypes import rint, wrap, rdouble, unwrap
from omero.gateway import BlitzGateway
conn = BlitzGateway('will', 'ome', host='localhost', port=4064)
conn.connect()
@will-moore
will-moore / OMERO_search_5.0.3.py
Created July 25, 2014 11:16
Examples of using the OMERO BlitzGateway search API following updates in 5.0.3.
from omero.gateway import BlitzGateway
from datetime import datetime
import time
conn = BlitzGateway('will', 'ome', host="localhost")
conn.connect()