Help with macro to batch count cells in confocal images

I used the record function to produce a macro that counts cells in multichannel confocal images. However, the macro returns a zero for the cell count for an image that produces a count of 550 when I run the same set of commands by hand. Any ideas why this is happening?

The macro produced by the recording is:

run("Make Binary", "method=Yen background=Light only black");
run("Despeckle", "slice");
run("Analyze Particles...", "size=5.22-22.00 display clear include summarize slice");

The action that I am doing by hand: Proces -> Binary-> Make Binary ( Method: Yen, Background: Light, Black background, only convert current image.

Process-> Noise-> Despeckle

Analyze-> Analyze particle
Show: Nothing
Display Results
clear results
include holes
Size: 5.22-22
Circularity: 0-1

Hi @CharlieM,

welcome to the forum! :slight_smile:

Could you provide a small example of your data (cf.


Sorry, I tried to upload sample data but it says that new users can not do so.

You are perfectly right, sorry about that! I have raised you trust level s.t. you should now be able to upload images. (15.9 MB)

Thank you! I have uploaded one of the images I want to count the cells in. There are 3 channels in this file the first channel should contain the most cells.

Dear @CharlieM,

sorry for not following up sooner.

It seems that you have hit a peculiarity of Analyze Particles. Could you check if it works when you change the first line of your macro to

run("Make Binary", "method=Yen background=Light only"); // remove the black argument

This basically inverts the output of Make Binary s.t. it should work with Analyze Particles.


Thank you for the response. The problem persists.

Could you run just the one line from a macro and run Analyze Particles manually afterwards? Does that output a count > 0?