Skip to content

Instantly share code, notes, and snippets.

@will-moore
will-moore / plate_rename_images.py
Created September 16, 2022 09:12
rename images in a Plate in OMERO
# https://forum.image.sc/t/imports-of-tiff-to-omero/71648/9
# usage: with plate ID - You will be asked for login...
# $ python plate_rename_images.py 1234
import argparse
import sys
from omero.cli import cli_login
from omero.gateway import BlitzGateway
@will-moore
will-moore / ngff_plate_segment_add_labels.py
Created April 27, 2022 15:00
process all the images in an OME-NGFF plate, segmenting them and adding OME-NGFF labels to each image
import os
import zarr
from skimage.filters import threshold_otsu
from skimage.segmentation import clear_border
from skimage.measure import label
from skimage.morphology import closing, square
from ome_zarr.io import parse_url
@will-moore
will-moore / max_intensity_projection.py
Created March 21, 2022 15:50
Python script to create a Max Intensity Projection for an OMERO Image
# see https://forum.image.sc/t/maximum-intensity-projection-feature-in-omero-web/54392/5
import argparse
import sys
import omero.clients
from omero.cli import cli_login
from omero.rtypes import wrap
from omero.gateway import BlitzGateway
import numpy as np
@will-moore
will-moore / Rename_Images.py
Last active December 20, 2021 10:27
OMERO.server script to rename Images e.g. myimage_s1.tif to myimage_s001.tif to fix ordering in the clients.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# See https://forum.image.sc/t/omero-screens-data-import/33466/10
# and https://forum.image.sc/t/upload-issue-with-metadata-ome-xml-companion-file/59290/9
import omero.scripts as scripts
from omero.gateway import BlitzGateway
import omero
@will-moore
will-moore / omero_rois.csv
Created October 30, 2021 22:07
Batch_ROI_Export from OMERO
We can't make this file beautiful and searchable because it's too large.
image_id,image_name,roi_id,shape_id,type,text,z,t,channel,area (µm),length (µm),points,min,max,sum,mean,std_dev,X,Y,Width,Height,RadiusX,RadiusY,X1,Y1,X2,Y2,Points
806,"Centrin_PCNT_Cep215_20110506_Fri-1545_0_SIR_PRJ.dv",179764,179764,polygon,"0001-0001-0125",1,1,CENT2,0.15367967833454133,,98,631.5927124023438,2212.172119140625,103127.09680175781,1052.317314303651,409.68381187031326,,,,,,,,,,,"130,117 131,117 131,126 130,126 130,134 128,134 128,133 127,133 127,132 124,132 124,133 123,133 123,132 122,132 122,130 123,130 123,128 122,128 122,127 121,127 121,126 123,126 123,125 124,125 124,124 125,124 125,123 127,123 127,124 128,124 128,122 127,122 127,117 128,117 128,116 130,116"
806,"Centrin_PCNT_Cep215_20110506_Fri-1545_0_SIR_PRJ.dv",179765,179765,polygon,"0001-0002-0127",1,1,CENT2,0.015681599830055237,,10,656.56787109375,877.3853759765625,7558.601013183594,755.8601013183594,74.44378384463185,,,,,,,,,,,"134,126 135,126 135,129 133,129 133,128 132,128 132,125 134,125"
806,"Centrin_PCNT_Cep215_20110506_Fri-1545_
import argparse
import json
import sys
from omero.gateway import BlitzGateway
from omero.cli import cli_login
from omero.model import StatsInfoI
from omero.rtypes import rdouble
@will-moore
will-moore / Attach_Original_Metadata.py
Last active September 28, 2021 09:33
OMERO.script that loads Original Metadata (read via BioFormats) and saves this as a text file on the Image so that this becomes indexed by the search engine.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Create File Annotations from Original Metadata.
See https://www.openmicroscopy.org/community/viewtopic.php?f=4&t=1226
"""
import omero
@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 / 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()