![]() | ![]() |
![]() |
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 | | ![]()
Reply
| Post a New Message |
Join or Leave IMAGEJ, or Change Options
|
Search | ![]()
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 14:23:57 -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 resultsSorry, worng file. I meant to attach this one. Rachel Bearon wrote: > I would like to process all files in a directory and record the results. I > wrote the following plugin to process one file at a time, but I would like > to be able to automatically loop through all files in the directory. In > the archives I found reference to a method for opening and processing all > files in a directory, but it didn't seem to allow one to automatically > save the results to a specified file. > > import ij.*; > import ij.process.*; > import ij.gui.*; > import java.awt.*; > import ij.plugin.*; > > public class Macro_ implements PlugIn { > > public void run(String arg) { > IJ.run("Set Measurements...", "area centroid decimal=3"); > IJ.run("Open...", "path=/home/rachelb/R14002R.tif"); > IJ.run("Processbugs "); > IJ.run("Custom Particle Analyzer", "minimum=4 maximum=20 bins=20 show=Nothing display clear stack"); > IJ.run("Measurements...", "path=/home/rachelb/R14002R.txt"); > } > > } > > (Processbugs is just a little plugin I wrote which does some image > calculations and thresholding.) > > Thanks in advance for any help! > > Rachel -- 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 ij.plugin.*; public class Macro_ implements PlugIn { public void run(String arg) { String outputFolder = "/home/rachelb/"; IJ.run("Set Measurements...", "area centroid decimal=3"); IJ.run("Image Sequence..."); processBugStack(); } public void processBugStack(){ ImagePlus imp = WindowManager.getCurrentImage(); ImageStack stack = imp.getStack(); int numSlices = imp.getStackSize(); for (int i = 1; i <= numSlices; i++){ imp.setSlice(i); String file = stack.getSliceLabel(i); int dot = file.lastIndexOf('.'); String outFile = file + ".txt"; if (dot > 0){ outFile = file.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...", outputFolder+outFile); } } }
![]() |
![]() Center for Information Technology National Institutes of Health Bethesda, Maryland 20892 301 594 6248 (v) 301 496 8294 (TDD) Comments and Assistance Accessibility ![]() |