Login  Register

Re: Only count cells that contain nuclei (or holes in the binarized image)

Posted by G. Esteban Fernandez on Oct 15, 2015; 8:59pm
URL: http://imagej.273.s1.nabble.com/Only-count-cells-that-contain-nuclei-or-holes-in-the-binarized-image-tp5014654p5014657.html

newImage("Outlines with holes", "8-bit black", x, y, 1);

for(i = 0; i < roiManager("count"); i++){
a = holes[i] - noHoles[i];
        if(a > 0){
              roiManager("Select", i);
              roiManager("Draw");
        }
}

On Thu, Oct 15, 2015 at 1:53 PM, G. Esteban Fernandez
<[hidden email]> wrote:

> You can try the "Add to Manager" option in Analyze Particles, then go
> through the list of ROIs and draw only those with holes onto a new
> blank image.
>
> -Esteban
>
> On Thu, Oct 15, 2015 at 12:11 PM, kirbyfloss <[hidden email]> wrote:
>> Thanks so much! I tested the code and it runs perfectly - the solution of
>> using include/exclude to distinguish the two populations is great.
>>
>> Just one more thing, is it possible to show outlines for just the particles
>> that contained holes? So I know which particles were counted.
>>
>> This is the macro I have set up so far with the helpful suggestions of the
>> community:
>> // run on the original image
>> run("Duplicate...", "title=workingCopy.png");
>> selectWindow("workingCopy.png");
>> run("Colour Deconvolution", "vectors=[H&E 2]");
>> selectWindow("workingCopy.png-(Colour_2)");
>> setAutoThreshold("Minimum");
>> run("Convert to Mask");
>> run("Set Measurements...", "area redirect=None decimal=5");
>> run("Analyze Particles...", "size=100-Infinity display exclude clear");
>> noHoles = newArray(nResults);
>> holes = newArray(nResults);
>> for (i = 0; i < nResults; i++) noHoles[i] = getResult("Area", i);
>> run("Analyze Particles...", "size=100-Infinity display exclude clear
>> include");
>> print("Particles Containing Holes");
>> for (i = 0; i < nResults; i++) {
>>         n = i+1;
>>         holes[i] = getResult("Area", i);
>>         a = holes[i] - noHoles[i];
>>         if(a > 0) print(n + " area of hole = " + a);
>> }
>>
>>
>>
>>
>> --
>> View this message in context: http://imagej.1557.x6.nabble.com/Only-count-cells-that-contain-nuclei-or-holes-in-the-binarized-image-tp5014654p5014655.html
>> Sent from the ImageJ mailing list archive at Nabble.com.
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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