Re: macro threshold values

Posted by Ewing James on
URL: http://imagej.273.s1.nabble.com/macro-threshold-values-tp5015759p5015771.html

From a statistics point of view, measures based on ranges (i.e., maximum values) are often not recommended because sample ranges depend on sample sizes.  You might be able to parameterize your distribution via its moments, and then take the predicted 98% upper confidence interval as a threshold.

- Jim


> On Mar 2, 2016, at 10:28 AM, Swayne, Theresa C. <[hidden email]> wrote:
>
> Hi Natalie,
>
>
> If you want to get the top 2% of the pixel population, there is a possibly related thread on the forum, where the poster is trying to get the top 2% of the pixel population using a cumulative sum.
> http://forum.imagej.net/t/thresholding-as-a-percentage-of-intensity-histogram-in-a-macro/923/
>
> However, I agree with Jeremy that differing amounts of positive staining per image will change the shape of the histogram, so the population approach may not be robust.
>
> Philippe’s solution gives you a threshold = 98% of the maximum value in the image, which would seem to be robust to differing amounts of positive signal per image, as well as to inconsistent staining levels.
>
> Hope this helps,
> Theresa
>
> On Mar 2, 2016, at 3:19 AM, Philippe CARL <[hidden email]<mailto:[hidden email]>> wrote:
>
> Dear Natalie,
> I guess you are looking for a code like this:
> nBins = 256;
> ratio = 0.5;
> run("Blobs (25K)");
> getHistogram(values, counts, nBins);
> Array.getStatistics(values, valuesMin, valuesMax, valuesMean, valuesStdDev);
> setThreshold(0, ratio * valuesMax );
> setOption("BlackBackground", true);
> run("Convert to Mask");
> with in your case ratio = 0.98;
> My best regards.
> Philippe
>
> Philippe CARL
> Laboratoire de Biophotonique et Pharmacologie
> UMR 7213 CNRS - Université de Strasbourg
> Faculté de Pharmacie
> 74 route du Rhin
> 67401 ILLKIRCH
> Tel : +33(0)3 68 85 41 84
>
> -----Message d'origine-----
> De : ImageJ Interest Group [mailto:[hidden email]] De la part de Natalie M
> Envoyé : lundi 29 février 2016 18:43
> À : [hidden email]<mailto:[hidden email]>
> Objet : macro threshold values
>
> Hi all,
> I am writing a macro to count cells in images I've taken of slides. Does anyone know what code I could use to have the macro threshold each image at the top 2% of each histogram, rather than at a set number value on each histogram?
> Thanks in advance,
> Natalie Morel
> University of Wisconsin
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> ------------------------------------
> Theresa Swayne, Ph.D.
> Manager
> Confocal and Specialized Microscopy Shared Resource<http://hiccc.columbia.edu/research/sharedresources/confocal>
>
> Herbert Irving Comprehensive Cancer Center
> Columbia University Medical Center
> 1130 St. Nicholas Ave., Room 222A
> New York, NY 10032
> Phone: 212-851-4613
> [hidden email]<mailto:[hidden email]>
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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