From 231559b97cb761f0a16dd6113d0dc447d5b8e904 Mon Sep 17 00:00:00 2001 From: Pariksheet Nanda Date: Thu, 18 May 2017 13:41:54 -0400 Subject: [PATCH] ENH: Play around with ImageJ groovy opener --- src/imagej_open.groovy | 47 +++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/src/imagej_open.groovy b/src/imagej_open.groovy index 5315bfc..f5c09e4 100644 --- a/src/imagej_open.groovy +++ b/src/imagej_open.groovy @@ -1,7 +1,21 @@ +/** + * Overlay CellProfiler ROIs. + * + * Uses ImageJ2 libraries whereever possible. + */ + import groovy.io.FileType // Recurse directories per http://stackoverflow.com/a/3954639 +//import ij.io.Opener +//import io.scif.SCIFIO + +import ij.plugin.FolderOpener + +import io.scif.img.ImgOpener + +import net.imglib2.img.display.imagej.ImageJFunctions /** Path to project Git repo */ -def prefix = "/share/Pariksheet/consultations/rnai-screen-tf" +def prefix_project = "/share/Pariksheet/consultations/rnai-screen-tf" /** * Read a stack of raw images. @@ -9,13 +23,32 @@ def prefix = "/share/Pariksheet/consultations/rnai-screen-tf" * @param plate name of the plate to match * @param well name of the well in [A-P][01-24] format */ -def open = {String plate, String well -> - def dirBg = new File("$prefix/results/z_projection") - def found = [] - dirBg.eachFileMatch(FileType.FILES, ~/${plate}_${well}_.+/) { - found << it.name +def open = { String plate, String well -> + def opener = new FolderOpener() + opener.run() + + // Build a list of the relevant image files. + def dirBg = new File( "${prefix_project}/results/z_projection" ) + def files = [] + dirBg.eachFileMatch( FileType.FILES, ~/${plate}_${well}_.+/ ) { + files << it.name } - println found + paths = files.collect { "${dirBg}/${it}" } + + //def imp = new Opener().openImage("${prefix}") + + // Open the images as a stack per the scifio tutorial + // https://github.com/scifio/scifio-tutorials + //def scifio = new SCIFIO() + //def reader = scifio.initializer().initializeReader(paths[0]) + //reader.getClass().getMethods().each {println it} + + // Open using imglib2 ImgOpener() as described in wiki examples + // http://imagej.net/ImgLib2_Examples + def imgOpener = new ImgOpener() + def im = imgOpener.openImg( paths[0] ) + //ImageJFunctions.show( im ) + //println im } open("160415_015529-V", "C03")