Skip to content

Instantly share code, notes, and snippets.

@will-moore
will-moore / Connection.py
Created September 22, 2011 23:31
Tutorial sample file for OMERO training workshop
# This script shows a simple connection to OMERO, printing details of the connection.
# NB: You will need to edit the 'host', 'user' and 'password' fields before running.
# Connect to the Python Blitz Gateway
# See OmeroPy/Gateway for more info
# import the libraries we need
from omero.gateway import BlitzGateway
from omero.rtypes import *
@will-moore
will-moore / perms_setup.py
Created May 7, 2012 19:24
Script to create Groups & Users for 4.4 Permissions testing
from omero.gateway import BlitzGateway
import omero
from omero.rtypes import rtime, rlong, rstring, rlist, rint
from omero_model_ExperimenterI import ExperimenterI
from omero_model_ExperimenterGroupI import ExperimenterGroupI
from omero_model_PermissionsI import PermissionsI
conn = BlitzGateway('root', 'omero', host='localhost');
print conn.connect()
@will-moore
will-moore / addAnnotations.py
Created May 22, 2012 14:52
Python example for adding various annotations to a Project.
#!/usr/bin/env python
"""
Script for adding annotations to Project.
"""
import omero.clients
from omero import client_wrapper
from omero.rtypes import *
import random
from datetime import datetime
#!/usr/bin/env python
"""
Script for switching rows / columns of wells in plate. See https://www.openmicroscopy.org/community/posting.php?mode=reply&f=4&t=1211
"""
import omero
import omero.clients
from omero.gateway import BlitzGateway
from omero.rtypes import rint
@will-moore
will-moore / Flip_Plate.py
Created June 28, 2012 10:26
Flip the coordinates of a Plate in OMERO.
#!/usr/bin/env python
"""
Script for switching rows / columns of wells in plate. See https://www.openmicroscopy.org/community/posting.php?mode=reply&f=4&t=1211
"""
import omero
import omero.clients
from omero.gateway import BlitzGateway
from omero.rtypes import rint
@will-moore
will-moore / Search_Orig_Metadata.py
Created July 2, 2012 20:55
Search for OMERO Images with key-value pairs in Original Metadata
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Sript to look for images with key-value pairs in Original Metadata
# See https://www.openmicroscopy.org/community/viewtopic.php?f=4&t=1226
import omero
import omero.scripts as scripts
from omero.gateway import BlitzGateway
from omero.rtypes import *
@will-moore
will-moore / Rename_Channels.py
Created November 1, 2012 22:10
OMERO script to rename Image Channels
import omero.scripts as scripts
from omero.gateway import BlitzGateway
from omero.rtypes import rstring, rlong
def renameChannels(conn, parameterMap):
updateService = conn.getUpdateService()
@will-moore
will-moore / createImageFromNumpySeq.py
Created November 24, 2012 22:46
createImageFromNumpySeq in OMERO Python Blitz Gateway, updated to work in the non-default group (adding self.SERVICE_OPTS to all server calls)
def createImageFromNumpySeq (self, zctPlanes, imageName, sizeZ=1, sizeC=1, sizeT=1, description=None, dataset=None):
"""
Creates a new multi-dimensional image from the sequence of 2D numpy arrays in zctPlanes.
zctPlanes should be a generator of numpy 2D arrays of shape (sizeY, sizeX) ordered
to iterate through T first, then C then Z.
Example usage:
original = conn.getObject("Image", 1)
sizeZ = original.getSizeZ()
sizeC = original.getSizeC()
sizeT = original.getSizeT()
@will-moore
will-moore / psql OMERO: add user to group
Created January 16, 2013 16:45
Using psql to add a user to a group in OMERO
Get the ID of the 'user' group:
omero=# select * from experimentergroup where name='user';
id | description | permissions | name | version | external_id
----+-------------+-------------+------+---------+-------------
1 | | -52 | user | 0 |
Get the ID of the Experimenter you want, using login name:
@will-moore
will-moore / Restore_colors.py
Created January 28, 2013 09:55
This is the OMERO script that is discussed on the forum at https://www.openmicroscopy.org/community/viewtopic.php?f=16&t=920, written by Pierre Pouchin.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
This script tries to restore the colors for the selected LIF/LSM images.
@author Pierre Pouchin
<a href="mailto:pierre.pouchin@u-clermont1.fr">pierre.pouchin@u-clermont1.fr</a>
@version 4.3
"""