TKS Batch Count Colonies
//11/19/12 TKS Batch Count Colonies
// Size of colonies
// If you want to change the minimum or maximum size for considering a
// colony, change the size parameters in the run("Analyze... line below.
// Circularity of colonies
// If you want to change the circularity requirements, change the parameters
// in the run("Analyze... line below.
// Macro "Count colonies"
// To run this macro, put copies of all your files to be analyzed in a single folder
// IMPORTANT: This macro will change the images, so do not use original images.
// Invoke the macro and then choose the folder where your file copies are located
// The actual colony counting commands are found at the bottom of the
// macro where it says Start your function here and End your function.
// This is the place where you need to adjust any parameters.
// After this macro runs, you will see a summary window that reports the
// colony count for each image, average size of colonies, and total colonies.
// You can also have the summary window show other measurements that
// you set in the Analyze -> Set Measurements... function.
macro "Count colonies [c]"
{
dir = getDirectory("Choose a Directory ");
setBatchMode(true);
count = 0;
countFiles(dir);
n = 0;
processFiles(dir);
print(count+" files processed");
function countFiles(dir)
{
list = getFileList(dir);
for (i=0; i<list.length; i++)
{
if (endsWith(list[i], "/"))
countFiles(""+dir+list[i]);
else
count++;
}
}
function processFiles(dir)
{
list = getFileList(dir);
for (i=0; i<list.length; i++)
{
if (endsWith(list[i], "/"))
processFiles(""+dir+list[i]);
else
{
showProgress(n++, count);
path = dir+list[i];
processFile(path);
}
}
}
function processFile(path)
{
if (endsWith(path, ".tiff"))
{
open(path);
// Start your processing function here
run("8-bit");
setThreshold(0, 200);
run("Make Binary", "thresholded remaining black");
run("Analyze Particles...", "size=150-Infinity circularity=0.5-1.00 show=Nothing exclude clear summarize");
// End your processing function here
save(path);
close();
}
}
}