Skip to content

Instantly share code, notes, and snippets.

@will-moore
will-moore / TagEverything.py
Created March 12, 2013 16:57
Script for adding a load of Tags, ROIs, Comments etc.
#!/usr/bin/env python
import sys
import omero
import omero.cli
from omero.gateway import BlitzGateway
from omero.rtypes import wrap, rlong, rdouble, rint, rstring
from omero.model import DatasetI, ProjectI, TagAnnotationI
@will-moore
will-moore / Copy_And_Paste_Tags.py
Created June 13, 2013 22:31
OMERO.script to copy Tags from Datasets or Images and apply them to the child images of the Dataset and/or other Datasets / Images
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copy Tags from Datasets or Images and apply them to the
child images of the Dataset and/or other Datasets / Images
"""
import omero.scripts as scripts
from omero.gateway import BlitzGateway
from omero.rtypes import rstring, rlong
@will-moore
will-moore / Metadata_Search.py
Last active September 28, 2021 09:20
OMERO script for searching based on Size Z/CT, Channel Names, Excitation Wavelength, Objective Model, Magnification or Lens NA.The script finds images and Tags them with a new "Search Results" tag.
"""
This script searches for Images, using database queries queries generated
from a number of parameters.
"""
import omero.scripts as scripts
from omero.gateway import BlitzGateway
from omero.rtypes import *
from datetime import datetime
@will-moore
will-moore / omero_public_url_tool.py
Last active January 2, 2016 14:19
Tool for developing regexes to use with OMERO.web to exclude urls from public access
# Tool for developing regexes to use with OMERO.web to exclude blockedUrls from public access.
# To use, edit the regex.
# Add or remove urls you want to test from the list then run...
# It will print a statement you can use to configure OMERO with the regex you've used
# You may also want to remove the ability of visitors to switch user in the drop-down menu
# $ bin/omero config set omero.web.ui.menu.dropdown '{}'
import re
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2013-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2013-06 http://www.openmicroscopy.org/Schemas/OME/2013-06/ome.xsd">
<Instrument ID="Instrument:0">
<Objective Correction="PlanApo" ID="Objective:12003" Immersion="Oil" LensNA="1.4" Manufacturer="Nikon" Model="93110" NominalMagnification="100.0" WorkingDistance="130.0"/>
</Instrument>
<Image ID="Image:0" Name="IN-GFP01_03_R3D.dv">
<AcquisitionDate>2006-08-29T19:26:52</AcquisitionDate>
<InstrumentRef ID="Instrument:0"/>
<ObjectiveSettings ID="Objective:12003"/>
<Pixels DimensionOrder="XYZCT" ID="Pixels:0" PhysicalSizeX="0.050801798701286316" PhysicalSizeY="0.050801798701286316" PhysicalSizeZ="0.20000000298023224" SizeC="4" SizeT="1" SizeX="552" SizeY="552" SizeZ="60" Type="uint16">
@will-moore
will-moore / Setup_test_users.py
Created April 25, 2014 14:21
Python script I use for populating my OMERO DB with users
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 / Invert_Datasets.py
Created April 30, 2014 23:02
OMERO.script takes a list of Datasets and puts the first image from each Dataset into a new Dataset, the second image of each into a new Dataset etc.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Script takes a list of Datasets and puts the first image from each Dataset
into a new Dataset, the second image of each into a new Dataset etc.
"""
import omero.scripts as scripts
from omero.gateway import BlitzGateway
import omero
from omero.gateway import *
from omero.model import *
from omero.rtypes import *
from omero.util.tiles import *
from numpy import fromfunction
user = 'will'
pw = 'ome'
host = 'localhost'
@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()
@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()