Skip to content

Instantly share code, notes, and snippets.

@will-moore
will-moore / roi_comments_search.py
Created June 10, 2020 09:44
OMERO query for Images via Comments (or Tags) on their ROIs
# See https://forum.image.sc/t/searching-by-roi-comment-field-in-omero-web/38808
# Usage:
# $ python roi_comments_search.py my_search_term
import argparse
import sys
import omero
import omero.clients
@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 / copy_rois.py
Last active September 3, 2020 12:57
Copy ROIs from one Image to another (can be on different OMERO servers)
import argparse
import sys
import omero
import omero.clients
from omero.rtypes import unwrap, rint, rstring
from omero.cli import cli_login
from omero.api import RoiOptions
from omero.gateway import BlitzGateway
// Configure OMERO.web open_with, pointing to the script_url to this gist
// $ omero config append omero.web.open_with '["openwith_url", "https://hms-dbmi.github.io/vizarr?source=https%3A%2F%2Fs3.embassy.ebi.ac.uk%2Fidr%2Fzarr%2Fv0.1%2F$ID.zarr", {"script_url": "url/to/omero_open_with_url.js", "label":"vizarr"}]'
function getIdrIdForNode(node) {
let idrId = node.id;
// for testing IDR images imported to other OMERO.servers,
// we can rename the images to be the IDR ID
let idFromName = parseInt(node.name);
@will-moore
will-moore / dask_5d_multiscale_napari.py
Created November 13, 2020 16:36
Performance test for concatenating tiles into multi-dimensional pyramid with dask.array.stack vv map_blocks
"""
Display a 5D dask multiscale pyramid
"""
from dask import array as da
from dask import delayed
import datetime
import numpy as np
import napari
from math import ceil
@will-moore
will-moore / omezarr.json
Last active December 23, 2020 23:42
Vitessce config file for loading an OME-Zarr - Work in progress
{
"description": "test",
"layers": [
{
"name": "raster",
"type": "RASTER",
"fileType": "ome-zarr.json",
"url": "https://s3.embassy.ebi.ac.uk/idr/zarr/v0.1/179706.zarr"
}
],
@will-moore
will-moore / copy_dataset.py
Last active May 12, 2021 14:10
This script copies a Dataset or Image from one OMERO.server to another. By default it requires https://gitlab.com/openmicroscopy/incubator/omero-python-importer/-/blob/master/import.py and transfers original files. Alternative is to use --pixels to only transfer pixel data (this doesn't support big images).
# -----------------------------------------------------------------------------
# Copyright (C) 2021 University of Dundee. All rights reserved.
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@will-moore
will-moore / metadata_queries.py
Created April 1, 2021 13:36
Examples for how to query OMERO for Images based on pixel type of Map Annotations
# https://forum.image.sc/t/harmonization-of-image-metadata-for-different-file-formats-omero-mde/50827/8
import omero
from omero.gateway import BlitzGateway
conn = BlitzGateway('username', 'password', port=4064, host='omero.server.org')
conn.connect()
# current group
@will-moore
will-moore / copy_masks_2_polygons.py
Last active May 21, 2021 10:05
Copy Masks from an Image in one OMERO server and turn them into Polygons on a different OMERO server
import omero
from omero.gateway import BlitzGateway
from omero.rtypes import rint, rstring
from skimage import morphology
from skimage import measure
import argparse
import sys