NIH LISTSERV
NIH LISTSERV
IMAGEJ archives -- May 2002 (#137)

Go to: Previous Message | Next Message
Previous in Topic | Next in Topic
Previous by Same Author | Next by Same Author
Previous Page (May 2002) | Back to Main IMAGEJ Page


Options: Reply | Post a New Message | Join or Leave IMAGEJ, or Change Options | Search
View: Chronologically | Most Recent First | Wrap Text (Proportional Font) | Don't Wrap Text (Non-proportional Font)
*

Delivered-To: [log in to unmask]@fixme
References: <[log in to unmask]>
Content-Type: multipart/mixed;
Message-ID:  <[log in to unmask]>
Date:         Wed, 22 May 2002 22:32:49 -0700
Reply-To:     [log in to unmask]
Sender:       ImageJ Interest Group <[log in to unmask]>
From:         Bob Dougherty <[log in to unmask]>
Organization: OptiNav, Inc.
Subject:      Re: batch processing of stacks and saving results

Rachel, Yes, I assumed that the files are just images. Here is a version that is intended to work for stacks or images. I adapted engineered Wayne's FolderOpener.java. There are probably ways to do this with scripts, but they would be OS dependent. Bob Rachel Bearon wrote: > Thanks for your help Bob! However the plugin you attatched acts in some > rather strange ways. Reading through it, I realised that perhaps I didn't > make myself clear. The plugin I have written opens up a file (which is a > movie so itself is a stack), analyzes the stack, and writes the results of > the whole stack to a specfied file. What I am hoping to do is analyze a > collection of such files using some kind of for loop in the plugin. The > specific problem I came across was how to specify the filename path > outside the IJ.run command. Eg. you can write > IJ.run("Measurements...", "path=/home/rachelb/R14002R.txt"); > > but I couldn't work out how to do something like > > path= "/home/rachelb/R14002R.txt" > IJ.run("Measurements...", path); > > which would be a necessary step in the loop. > -- Robert Dougherty President, OptiNav, Inc. (425) 467-1118 [log in to unmask] http://www.optinav.com


import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import java.io.*; import ij.plugin.*; import ij.io.*; public class Macro_ implements PlugIn { public void run(String arg) { IJ.run("Set Measurements...", "area centroid decimal=3"); OpenDialog od = new OpenDialog("Choose a file in the directory... ", arg); String directory = od.getDirectory(); String name = od.getFileName(); if (name==null) return; String[] list = new File(directory).list(); if (list==null) return; //IJ.register(Macro_.class); //ij.util.StringSorter.sort(list); try { for (int i=0; i<list.length; i++) { if (list[i].endsWith(".txt")) continue; ImagePlus imp = new Opener().openImage(directory, list[i]); if (imp==null) IJ.write(list[i] + ": unable to open"); else { imp.show(); ImageWindow iw = imp.getWindow(); IJ.showStatus((i+1)+"/"+list.length); IJ.showProgress((double)(i+1)/list.length); int dot = list[i].lastIndexOf('.'); String outFile = list[i] + ".txt"; if (dot > 0){ outFile = list[i].substring(0,dot) + ".txt"; } IJ.run("Processbugs "); IJ.run("Custom Particle Analyzer", "minimum=4 maximum=20 bins=20 show=Nothing display clear stack"); IJ.run("Measurements...", directory+outFile); //System.out.println(directory+outFile); iw.close(); } //System.gc(); } } catch(OutOfMemoryError e) { IJ.outOfMemory("Macro_"); } } }



Back to: Top of message | Previous page | Main IMAGEJ page

NIH LISTSERV Home Page

CIT
Center for Information Technology
National Institutes of Health
Bethesda, Maryland 20892
301 594 6248 (v) 301 496 8294 (TDD)
Comments and Assistance
Accessibility wheelchair icon