Batch macro processing gives different values than individual macro processing

imagej
macro
#1

I am trying to batch process images that were acquired using a Carl Zeiss fluorescent microscope. They are in .czi format (Carl Zeiss format), and Fiji is able to identify this as a multi-channel file. The macro I have written is intended to convert the fluorescent images to grayscale and count the particles. I have two channels (one is for live cells, the other for dead). When running the macro on an individual .czi file, I get particle counts that are way lower than the counts when running in batch mode even though I am using the same macro. I have reproduced the code below. If anyone has any thoughts please let me know.

Thank you!

imageTitle=getTitle();
run(“Split Channels”);
selectWindow(“C1-”+imageTitle)
run(“RGB Color”);
selectWindow(“C2-”+imageTitle)
run(“RGB Color”);
run(“Subtract Background…”, “rolling=10”);
selectWindow(“C1-”+imageTitle)
run(“Subtract Background…”, “rolling=20”);
run(“Brightness/Contrast…”);
setMinAndMax(7, 186);
selectWindow(“C2-”+imageTitle)
run(“Brightness/Contrast…”);
setMinAndMax(36, 163)
selectWindow(“C1-”+imageTitle)
run(“8-bit”);
selectWindow(“C2-”+imageTitle)
run(“8-bit”);
selectWindow(“C1-”+imageTitle)
setAutoThreshold(“Default”);
run(“Threshold…”);
setThreshold(9, 255);
setOption(“BlackBackground”, false);
run(“Convert to Mask”);
selectWindow(“C2-”+imageTitle)
setAutoThreshold(“Default”);
run(“Threshold…”);
setThreshold(18, 255);
setOption(“BlackBackground”, false);
run(“Convert to Mask”);
run(“Watershed”);
selectWindow(“C1-”+imageTitle)
run(“Watershed”);
selectWindow(“C1-”+imageTitle)
run(“Analyze Particles…”, “size=20-Infinity summarize”);
selectWindow(“C2-”+imageTitle)
run(“Analyze Particles…”, “size=20-Infinity summarize”);

#2

I would suggest to proof which particles are counted. Since your individual counting is lower generate an outline to see visually which particles are counted. Hard to recognize selections or particle restrictions in the particle analyzer (roudness, particle size) can alter the results if not careful considered.

By the way for the forum it would be helpful if you post somewhere an example image so that the members of the forum can reproduce the measurements and help more efficiently.