Cell counts- different results macro vs manual operations

Hi all,

I am trying to write a macro for cell counts, but I keep getting different results when I perform the functions manually vs when I run the same images in the macro. I have tried this several times, and on two different computers and the results are reproducible.

Here is my macro, along with a sample image. When I run each function manually I count 373 cells, when I run the macro I get 916 cells.

Thanks in advance!

//run("Brightness/Contrast...");
run("Enhance Contrast", "saturated=0.35");
setAutoThreshold("Default dark");
//run("Threshold...");
//setThreshold(47, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Watershed");
run("Analyze Particles...", "size=0.10-2.00 show=Outlines exclude summarize");

1 ul Tyramide_A_05 - C1.tif (1.0 MB)

@prichards

Your threshold method is grabbing too much background… try using ‘Moments’ instead of ‘Default’.

Does this help?

Thanks etarena,

I’m not sure if this helps. I used the macro recorder to generate this script. When I open the threshold feature, it automatically goes to ```setAutoThreshold(“Default dark”);

My last comment was cut short,

When I open the image, it defaults to setAutoThrehold (default dark), but then I adjust the threshold manually (setThreshold(47,255). Is the macro reverting to the auto threshold after I set it manually?

Thanks!

@prichards

You shouldn’t adjust the threshold manually… it’s more reproducible to use an automated method… and Moments seemed to do the trick. Did you test it?

Hi @prichards,

The reason why your 2 methods differ probably lie in the manual modification of the threshold.
In the macro, there is a // before the setThreshold, so it is not performed.
I agree with @etadobson that manual delineation of the threshold has to be avoided because it is very user dependant, not reproducable and may intriduce a bias. You should investigate the various thresholding methods available, because each one has its specificities and is designed for a specific application.

Nico

1 Like