Login  Register

Re: Calculating mean and standard deviation from a summary

Posted by Stoyan Pavlov on Jul 07, 2015; 11:51am
URL: http://imagej.273.s1.nabble.com/Calculating-mean-and-standard-deviation-from-a-summary-tp5013398p5013452.html

Hello,
I had similar problem - I needed to count particles in multiple RoIs, some
of them located on one slice. I've managed to compose a crude yet effective
macro for my needs. You are free to modify it as needed:

// This Macro counts particles inside specific Roi and otputs the number to
TAB separated Log window which after saving can be imported to excel.
print ("RoiNumber","    ","SliceLabel","    ","RoIName","    ","Count","
","RoIArea","    ","RoIPerimeter","    "," ParticlesCoveredArea","
","AreaFraction") ;
setAutoThreshold("Default dark");
 n = roiManager("count");
        for (i=0; i<n; i++)  {
        roiManager("select", i);
        run("Set Measurements...", "area perimeter redirect=None
decimal=4");
    run("Measure");
    r=getResult("Area");
    u=getResult("Perim.");
run("Set Measurements...", "area area_fraction limit display redirect=None
decimal=4");
run("Measure");
s=getResult("Area");
t=getResult("%Area");
run("Analyze Particles...", "size=0-infinity circularity=0.00-1.00
show=Nothing display clear ");
    m=nResults;
     q=getInfo("slice.label");
    print (i,"    ",q,"    ",call("ij.plugin.frame.RoiManager.getName",
i),"    ",m,"    ",r,"    ",u,"    ",s,"    ",t) ;
}

What the macro does is - it runs the Measure and Analyze  Particles
commands for each RoI and then gets the needed results and plots them in a
Log window, after which it moves to the next RoI.
I hope it'll be helpful.

Stoyan Pavlov
On Jul 2, 2015 7:11 PM, "Jeremy Goodwin" <[hidden email]> wrote:

> Hi,
>
>
>
> Is it possible to write a macro (or is there a macro0 which will calculate
> the mean particle count, the standard deviation and the min and max counts,
> after processing a batch of images?
>
>
>
> I’m a bit lost on how to approach this.  Is easy to do in Excel, but I’d
> like to automate it during batch processing.
>
>
>
> This is the batch macro that I’m using - saves all my output images and the
> summary file.
>
>
>
> macro "Batch" {
>
> dir1 = getDirectory("Choose Source Directory ");
>
> dir2 = getDirectory("Choose Destination Directory ");
>
> list = getFileList(dir1);
>
> setBatchMode(true);
>
> for (i=0; i<list.length; i++) {
>
>  showProgress(i+1, list.length);
>
>  open(dir1+list[i]);
>
>
>
> run("8-bit");
>
> run("Bandpass Filter...", "filter_large=100 filter_small=10 suppress=None
> tolerance=5 autoscale saturate");
>
> run("Auto Threshold...", "method=Mean white");
>
> run("Analyze Particles...", "size=200-Infinity show=Outlines clear
> summarize in_situ");
>
> saveAs("TIFF", dir2+list[i]);
>
> selectWindow("Summary");
>
> saveAs("Text", dir2+"Summary.xls");
>
> close();
>
> }
>
>
>
> Yours
>
>
>
> jez
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html