batch measurements to single data file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

batch measurements to single data file

Justin Walker-2
I have put together a simple macro to (batch) perform various
manipulations and then measure particle diameters for a series of
several hundred images of liquid droplets.  Everything works fine,
except for each image that runs, the results window discards the data
from the previous image.

I'm sure there is a simple way to change that, but I've been searching
the documentation and mailing list archives all morning and haven't been
able to find anything useful.  Is there a simple way to have the data
from previous measurements preserved when a new image is opened and
processed?  Alternatively, is there a way I can have the results dumped
to a data file (but a single data file for all the data with each
measurement on a new line?).  I tried having a save as command as part
of my macro, but it kept trying to over-write the data file on each
iteration.

I have attached my macro.

Thanks;

- Justin Walker, Ph. D. Student
University of Maryland
College Park, MD, USA
[hidden email]
301-405-1920

macro "Batch Particle Size" {
    dir = getDirectory("Choose a Directory ");
    list = getFileList(dir);
    setBatchMode(true);
    for (i=0; i<list.length; i++) {
        path = dir+list[i];
        showProgress(i, list.length);
        if (!endsWith(path,"/")) open(path);
        if (nImages>=1) {
            run("Deinterlace ");
            run("8-bit");
            setAutoThreshold();
            //run("Threshold...");
            setAutoThreshold();
            setThreshold(0, 164);
            run("Convert to Mask");
            run("Fill Holes");
            run("Watershed");
            run("Analyze Particles...", "size=0.15-Infinity circularity=0.00-1.00 show=Nothing display exclude clear");
            close();
        }
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: batch measurements to single data file

Wayne Rasband
Remove 'clear' from

   run("Analyze Particles...", "size=0.15-Infinity circularity=0.00-1.00
show=Nothing display exclude clear");

It is equivalent to checking "Clear Results" in the Analyze Particles
dialog box.

-wayne


On Nov 19, 2007, at 12:27 PM, Justin Walker wrote:

> I have put together a simple macro to (batch) perform various
> manipulations and then measure particle diameters for a series of
> several hundred images of liquid droplets.  Everything works fine,
> except for each image that runs, the results window discards the data
> from the previous image.
>
> I'm sure there is a simple way to change that, but I've been searching
> the documentation and mailing list archives all morning and haven't
> been able to find anything useful.  Is there a simple way to have the
> data from previous measurements preserved when a new image is opened
> and processed?  Alternatively, is there a way I can have the results
> dumped to a data file (but a single data file for all the data with
> each measurement on a new line?).  I tried having a save as command as
> part of my macro, but it kept trying to over-write the data file on
> each iteration.
>
> I have attached my macro.
>
> Thanks;
>
> - Justin Walker, Ph. D. Student
> University of Maryland
> College Park, MD, USA
> [hidden email]
> 301-405-1920
> macro "Batch Particle Size" {
>     dir = getDirectory("Choose a Directory ");
>     list = getFileList(dir);
>     setBatchMode(true);
>     for (i=0; i<list.length; i++) {
>         path = dir+list[i];
>         showProgress(i, list.length);
>         if (!endsWith(path,"/")) open(path);
>         if (nImages>=1) {
>             run("Deinterlace ");
>    run("8-bit");
>    setAutoThreshold();
>    //run("Threshold...");
>    setAutoThreshold();
>    setThreshold(0, 164);
>    run("Convert to Mask");
>    run("Fill Holes");
>    run("Watershed");
>    run("Analyze Particles...", "size=0.15-Infinity
> circularity=0.00-1.00 show=Nothing display exclude clear");
>             close();
>         }
>     }
> }
Reply | Threaded
Open this post in threaded view
|

Re: batch measurements to single data file

Justin Walker-2
Super!  I knew it would be something simple like that.

Thanks a ton

- Justin


Wayne Rasband wrote:

> Remove 'clear' from
>
>   run("Analyze Particles...", "size=0.15-Infinity
> circularity=0.00-1.00 show=Nothing display exclude clear");
>
> It is equivalent to checking "Clear Results" in the Analyze Particles
> dialog box.
>
> -wayne
>
>
> On Nov 19, 2007, at 12:27 PM, Justin Walker wrote:
>
>> I have put together a simple macro to (batch) perform various
>> manipulations and then measure particle diameters for a series of
>> several hundred images of liquid droplets.  Everything works fine,
>> except for each image that runs, the results window discards the data
>> from the previous image.
>>
>> I'm sure there is a simple way to change that, but I've been
>> searching the documentation and mailing list archives all morning and
>> haven't been able to find anything useful.  Is there a simple way to
>> have the data from previous measurements preserved when a new image
>> is opened and processed?  Alternatively, is there a way I can have
>> the results dumped to a data file (but a single data file for all the
>> data with each measurement on a new line?).  I tried having a save as
>> command as part of my macro, but it kept trying to over-write the
>> data file on each iteration.
>>
>> I have attached my macro.
>>
>> Thanks;
>>
>> - Justin Walker, Ph. D. Student
>> University of Maryland
>> College Park, MD, USA
>> [hidden email]
>> 301-405-1920
>> macro "Batch Particle Size" {
>>     dir = getDirectory("Choose a Directory ");
>>     list = getFileList(dir);
>>     setBatchMode(true);
>>     for (i=0; i<list.length; i++) {
>>         path = dir+list[i];
>>         showProgress(i, list.length);
>>         if (!endsWith(path,"/")) open(path);
>>         if (nImages>=1) {
>>             run("Deinterlace ");
>>         run("8-bit");
>>         setAutoThreshold();
>>         //run("Threshold...");
>>         setAutoThreshold();
>>         setThreshold(0, 164);
>>         run("Convert to Mask");
>>         run("Fill Holes");
>>         run("Watershed");
>>         run("Analyze Particles...", "size=0.15-Infinity
>> circularity=0.00-1.00 show=Nothing display exclude clear");
>>             close();
>>         }
>>     }
>> }