Skip to content

Instantly share code, notes, and snippets.

@sbesson
sbesson / TiledWriter.java
Last active January 23, 2017 13:51 — forked from emilroz/TiledWriter.java
Basic ome.tif tile writer
import java.io.IOException;
import loci.common.services.DependencyException;
import loci.common.services.ServiceException;
import loci.common.services.ServiceFactory;
import loci.formats.services.OMEXMLService;
import loci.formats.FormatException;
<?xml version="1.0" encoding="UTF-8"?>
<OME UUID="urn:uuid:07504f88-7bc3-11e0-b937-2faf67bc00b3"
xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06
http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd">
<Image ID="Image:0" Name="ROI with transforms">
<Pixels DimensionOrder="XYZCT" ID="Pixels:0:0" Type="uint8" SizeC="1" SizeT="2" SizeX="512" SizeY="512" SizeZ="8">
<Channel ID="Channel:0" SamplesPerPixel="1"/>
<TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1">
@sbesson
sbesson / open_czi.m
Last active December 16, 2016 09:16
A set of scripts to manipulate Zeiss CZI options in Bio-Formats
% Check Bio-Formats and initialize logging
bfCheckJavaPath();
bfInitLogging();
% Create a reader
r = bfGetReader();
values = [true false];
for autostich = values
for attachments = values
@sbesson
sbesson / check_2fa.py
Created June 29, 2016 13:02
A script identifying potential vulnerable users in a public GitHub organization
import scc.git
# Login and check the organization
gh = scc.git.get_github(scc.git.get_token())
orgs = gh.get_user().get_orgs()
def is_owner(org):
owners = [x.login for x in org.get_members(role="admin")]
return gh.get_login() in owners
@sbesson
sbesson / annotation_queries.sql
Last active May 6, 2016 09:45
A gist listing SQL queries to be run against production DBs to assess the criteria of https://github.com/openmicroscopy/openmicroscopy/pull/4608
SELECT ns, discriminator, count(*) from annotation group by ns, discriminator;
SELECT ns, discriminator, count(*) from annotation where ns = '' group by ns, discriminator;
SELECT ns, discriminator, count(*) from annotation where ns is null group by ns, discriminator;
#!/usr/bin/env python
# Copyright (C) 2016 Open Microscopy Environment & 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.
#
@sbesson
sbesson / getOMETIFFOMEXMLVersion.m
Created April 7, 2016 15:32
A simple script for extracting the OME-XML version from an OME-TIFF file - assumes valid OME-TIFF / no exception handling
parser = loci.formats.tiff.TiffParser(ometiffpath);
service = loci.formats.services.OMEXMLServiceImpl();
version = char(service.getOMEXMLVersion(parser.getComment()))
@sbesson
sbesson / scc_init_repo.py
Last active October 6, 2016 13:39
Script to initialize a snoopy fork of a new top-level repository
#! /usr/bin/env python
import scc.git
import time
# Create GitHub connection
token = scc.git.get_token()
gh = scc.git.get_github(token)
username = gh.get_user().login
print "Authenticated as %s" % username
@sbesson
sbesson / createBinaryOnlyOMEXMLMetadata.m
Created March 18, 2016 00:01
MATLAB snippet for creating an OME-XML to be used for BinaryOnly OME-TIFF (e.g. with a companion metadata file)
% Create OME-XML metadata object
OMEXMLService = loci.formats.services.OMEXMLServiceImpl();
metadata = OMEXMLService.createOMEXMLMetadata();
% Create the root object
metadata.createRoot();
% Set the UUID for the OME-TIFF
ometiff_uuid = char(java.util.UUID.randomUUID);
metadata.setUUID(ometiff_uuid);
@sbesson
sbesson / symlink_replacements
Last active December 17, 2015 20:18
A bash script to update symlinks