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

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)
*

Errors-to: [log in to unmask]
Content-type: text/plain; charset=us-ascii
Message-ID:  <[log in to unmask]>
Date:         Thu, 23 May 2002 12:33:00 +0200
Reply-To:     [log in to unmask]
Sender:       ImageJ Interest Group <[log in to unmask]>
From:         Steven Driever <[log in to unmask]>
Subject:      Re: batch processing of stacks and saving results

Hi Wayne, indeed generalising a plugin is a problem. So thanks for explaining a way to do this, as I am not such an expert on Java, and perhaps many with me. But the code you generated below gives two error messages I fail to fix. The errors are: C:\ImageJ\plugins\Macro_batch.java:40: Method log(java.lang.String) not found in class ij.IJ. IJ.log((i+1)+": "+list[i]); ^C:\ImageJ\plugins\Macro_batch.java:47: Method log(java.lang.String) not found in class ij.IJ. IJ.log("path='"+directory+fileName+".txt'"); ^ It seems to be a problem with a missing method in ij.IJ class. How can this be fixed? thanks Steven -------------------------------------------------- Steven Driever Student BiologyWageningen University Horticultural Production Chains Group Marijkeweg 22, Building number 527 6709 PG Wageningen, The Netherlands tel +31.(0)317.483660 fax +31.(0)317.484709 email: [log in to unmask] -------------------------------------------------- - - - - - - - - - - - - - - Original Message - - - - - - - - - - - - - - Rachael, Your dilemma illustrates a very real problem for IJ users wishing to use a 'simple' macro level interface to IJ functions. Recording invoked functions via IJ>Plugins>Record... and Recorder and running the Java code plugin generated via Create Plugin is straightforward but generalising the resultant Java plugin can be quite problematic. Wayne has some extentions planned to make this process easier.The problem and the power of this approach to a user tailored interface both stem from the heirarchy of contexts in which various segments of the program text are interpreted. In the generated line: IJ.run("Measurements...", "path=/home/rachelb/R14002R.txt"); the text "path=/home/rachelb/R14002R.txt" is a Java String literal which is analysed for the keyword "path=" by IJ to determine that what follows is to be used as a path and filename for the save by the "Measurements..." routine MeasurementsWriter. An equivalent would be String path="path=/home/rachelb/R14002R.txt"; IJ.run("Measurements...", path); where "String path" defines a Java String object called "path" ... the text "path" is used in two different contexts. The path object is used as the second argument in the IJ.run command, the contents of which is passed to IJ for interpretation in the "Measurements..." routine context; it contains the text "path=/home/rachelb/R14002R.txt". IJ uses the keyword path= within this String to identify what follows as the file path (ie directory+name). To address your original post, IJ.run("Open...", "path=/home/rachelb/R14002R.tif"); //..........process.......... IJ.run("Measurements...", "path=/home/rachelb/R14002R.txt"); could be made more general as in the first "run" below.(commented out). The looping so that stacks are opened, processed and closed in turn (on the assumption that stacks are large so that only one is opened at a time) is done in the second version of "run". This requires considerably more Java/API. import ij.*; import ij.process.*; import ij.gui.*; import ij.io.*;//FileInfo import java.io.*;//File import java.awt.*; import ij.plugin.*; public class Macro_batch implements PlugIn { void process(){ //IJ.run("Processbugs "); //IJ.run("Custom Particle Analyzer", "minimum=4 maximum=20 bins=20 show=Nothing display clear stack"); IJ.run("Measure");// subsituted process for test } /* public void run(String arg) { IJ.run("Set Measurements...", "area centroid decimal=3"); IJ.run("Open...", ""); FileInfo fi=WindowManager.getCurrentImage().getOriginalFileInfo(); IJ.log(""+fi); process(); String fileName=fi.fileName; int dotIndex=fileName.lastIndexOf("."); if (dotIndex>=0)fileName=fileName.substring(0,dotIndex); IJ.log("path='"+fi.directory+fileName+".txt'"); IJ.run("Measurements...", "path='"+fi.directory+fileName+".txt'"); // encapsulating ' ' are necessary for blanks such as in "DeskTop Folder" } */ public void run(String arg) { IJ.run("Set Measurements...", "area centroid decimal=3"); OpenDialog od = new OpenDialog("Select a file in folder...",""); if (od.getFileName()==null) return; String directory = od.getDirectory(); String[]list = new File(directory).list(); if (list==null) return; for (int i=0;i<list.length;i++) { IJ.showStatus(i+"/"+list.length); File f = new File(directory+list[i]); if ((!f.isDirectory())&&list[i].toLowerCase().endsWith(".tif")) { IJ.log((i+1)+": "+list[i]); ImagePlus img = new Opener().openImage(directory, list[i]); if (img!=null) {img.show(); process(); String fileName=list[i]; int dotIndex=fileName.lastIndexOf("."); if (dotIndex>=0)fileName=fileName.substring(0,dotIndex); IJ.log("path='"+directory+fileName+".txt'"); IJ.run("Measurements...", "path='"+directory+fileName+".txt'"); // encapsulating ' ' are necessary for blanks such as in "Desktop Folder" IJ.run("Close"); } } } IJ.showProgress(1.0); IJ.showStatus(""); } } Greg Joss, Department of Biological Sciences, Phone: (61)(2) 9850 8212 Fax: 9850 8245 Macquarie University, Email: [log in to unmask] North Ryde, (Sydney,) NSW 2109, Australia >>> [log in to unmask] - 5/23/02 8:36 AM >>> 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. .............cut....................... - - - - - - - - - - - - End of Original Message - - - - - - - - - - - -




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