ImageJ Counting Macro for Known Field Values

Here’s a simple method to deal with varying intensities in a large run of images, assuming you have a known number of cells in a field. If I assume I should see, say, more than X cells per area, I can adjust my threshold to slowly increase it’s aggressiveness until that minimum counted value is met. The code can be downloaded as an imageJ macro here. but here’s a walk through of this simple script. My comments are preceded by a *.:

rnum = 0; *this creates a new variable, or container, for our # of regions

 tval = 2000; *this is the starting object threshold value. 
 while (rnum<500) *this is a "while" loop. The loop runs until the argument is satisfied.
 { 
 setAutoThreshold("Default"); 
 setThreshold(tval, 4095); *note that tval = the minimum threshold value
 run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Nothing display clear add"); 
 rnum = roiManager("count"); 
 tval = tval - 100; *tval continues to become more aggressive in counting objects until the argument is met. 
 }

Simple routines like these can reduce your headache factor by a large margin if you learn how to harness the power of macros!

-Austin

 

 

 

 


Posted

in

, , , , , ,

by