Skip to content

Instantly share code, notes, and snippets.

@will-moore
will-moore / FRAP_segmentation.py
Created February 25, 2020 22:07
Draw a Polygon around FRAP bleach spot. Works with FRAP images from https://downloads.openmicroscopy.org/images/DV/will/FRAP/
import omero
from omero.gateway import BlitzGateway
from omero.rtypes import rint, rstring
from skimage import morphology
from skimage import measure
conn = BlitzGateway('user', 'password', port=4064, host='localhost')
conn.connect()
@will-moore
will-moore / add_ellipse_per_channel.py
Created February 10, 2020 15:03
Finds the brightest point in a plane and draws an ellipse around it. Useful for generating test ROIs.
import omero
from omero.rtypes import rdouble, rint
import omero.grid
from omero.gateway import BlitzGateway
import numpy as np
USERNAME = "user"
PASSWORD = "password"
HOST = "merge-ci-devspace.openmicroscopy.org"
PORT = 4064
import re
from omero.gateway import BlitzGateway, MapAnnotationWrapper, LongAnnotationWrapper
conn = BlitzGateway("user", "pass", port=4064, host="localhost")
conn.connect()
# Some example chromosome regions we want to annotate Images with...
regions = [
"hg19:chr19:15200000-15560000",
@will-moore
will-moore / pixel_size_test.py
Last active January 23, 2020 14:29
For testing images with different pixel sizes
from omero.model.enums import UnitsLength
import omero
from omero.rtypes import rstring
from omero.gateway import BlitzGateway
conn = BlitzGateway('user', 'password', port=4064, host='localhost')
conn.connect()
units = [
UnitsLength.PICOMETER,
@will-moore
will-moore / simple_FRAP.py
Created June 11, 2019 08:23
OMERO training script
# coding: utf-8
# ### Please use the following link to try out the OMERO Python language bindings
# https://docs.openmicroscopy.org/latest/omero/developers/Python.html
# ### Import Packages required to connect to OMERO
# In[1]:
import omero
from omero.gateway import BlitzGateway
# See https://www.openmicroscopy.org/community/posting.php?mode=reply&f=6&t=8736
idr_client = omero.client(host="idr.openmicroscopy.org", port=4064)
idr_client.createSession('public', 'public')
conn = BlitzGateway(client_obj=idr_client)
@will-moore
will-moore / renderingDefReset.py
Last active April 24, 2019 12:26
Reset rendering defs in OMERO, and regenerate thumbnails.
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"
@will-moore
will-moore / createImageFromTiffs.py
Last active March 18, 2019 15:35
createImageFromTiffs
# See https://www.openmicroscopy.org/community/viewtopic.php?f=4&t=8679
# and https://www.openmicroscopy.org/community/posting.php?mode=reply&f=6&t=8706
import omero
from omero.gateway import BlitzGateway
from PIL import Image
import numpy
conn = BlitzGateway("username", "password", host="localhost", port=4064)
@will-moore
will-moore / rois_to_centre_points.py
Last active February 5, 2019 05:42
Script to process OMERO Polygons, creating a Point at the centre of each Polygon (with Polygon ID as Point label)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero
from omero.rtypes import rdouble, rint, rstring, unwrap
from omero.gateway import BlitzGateway
USERNAME = 'username'
PASSWORD = 'password'
HOST = 'localhost'
@will-moore
will-moore / test_import_cli.py
Created June 19, 2018 15:00
An OMERO.script that imports an image via the CLI
import sys
import subprocess
from path import path
import omero.scripts as scripts
from omero.gateway import BlitzGateway
import omero.util.script_utils as script_utils
import omero
from omero.rtypes import rint, rlong, rstring, robject, unwrap