Re: roiManager and Batch mode

Posted by Wayne Rasband on
URL: http://imagej.273.s1.nabble.com/roiManager-and-Batch-mode-tp3696401p3696402.html

In the ImageJ 1.41b daily build, the particle analyzer, when run from a
batch mode macro, no longer opens the ROI Manager window when "Add to
Manager" is enabled, resulting in faster and more reliable operation.

-wayne

On Apr 28, 2008, at 8:01 PM, Luciano Marpegan wrote:

> Hi everybody,
>
> I'm writing a macro to remove big particles from my images. Most of
> these particles have irregular shapes, are over twice bigger than the
> particles I'm interested in and their intensity is
> homogeneous although sometimes they overlap with the particles I'm
> measuring. I need to do batch processing because I usually work with
> image sequences with over 10k frames and it is very time consuming to
> do it manually.
> The macro is based on the "BatchProcessFolders" macro from the ImageJ
> macros web page and works fine as far as I don't use the setBatchMode
> function. When I use it, the roiManager doesn't reset and seems to
> keep adding the selections instead of deleting the ones of the
> previous cycle. making it short, does the roiManager("reset") function
> work while in batch mode?
> I will really appreciate any help Best.
> Luciano
>
> Following is the macro script:
>
> {
> requires("1.33s");
> dir = getDirectory("Choose a Directory ");
>    setBatchMode(true);
>    count = 0;
>    countFiles(dir);
>    n = 0;
>    processFiles(dir);
>    //print(count+" files processed");
>
>    function countFiles(dir) {
>       list = getFileList(dir);
>       for (i=0; i<list.length; i++) {
>           if (endsWith(list[i], "/"))
>               countFiles(""+dir+list[i]);
>           else
>               count++;
>        setBatchMode(false);
>         }
> }
>
>    function processFiles(dir) {
>       list = getFileList(dir);
>       for (i=0; i<list.length; i++) {
>           if (endsWith(list[i], "/"))
>               processFiles(""+dir+list[i]);
>           else {
>              showProgress(n++, count);
>              path = dir+list[i];
>              processFile(path);
>           }
>       }
> }
>
>   function processFile(path) {
>        if (endsWith(path, ".tif")) {
>            open(path);
>            run("Divide...", "value=1023");
>            run("8-bit");
>            setThreshold(1, 255);
>            run("Analyze Particles...", "size=250-Infinity
> circularity=0.00-1.00 show=Nothing add");
>            roiManager("Combine");
>            run("Subtract...", "value=1");
>            roiManager("Reset");
>            setThreshold(1, 255);
>            run("Analyze Particles...", "size=125-Infinity
> circularity=0.03-1.00 show=Nothing add");
>            roiManager("Combine");
>            run("Subtract...", "value=1");
>            roiManager("Reset");
>     subdir=getDirectory ("image");
>     newdir=subdir+"Filtered"+File.separator;
>     File.makeDirectory(newdir);
>     fname=File.getName(path) ;
>     saveAs("tiff", newdir+ "filtered"+getTitle);
>            close();
>
>       }
>   }
>
>
>
>
>
>
>
> Luciano Marpegan, Ph. D.,
> Postdoctoral Fellow,
> Biology Department, Washington University,
> PO Box 1137,1 Brookings Drive, St. Louis,MO 63130
> Office Phone: 314-935-5214
> Email: [hidden email]
>