Count new/old bacteria from an image sequence

Hi everyone,
I’m new on ImageJ. Now I have an image sequence of 61 images obtained from 30 min of bacterial adhesion. So, the purpose is to count the bacteria on each image (I got this already, as shown on code 1) and after that I want to quantify during the process how many bacteria are new, still attached or detached to the surface. I am trying to make the quantification with the bellow code 2, subtracting the images and at the end obtain different colors in order to know how many new and old cells I have on my images. Unfortunatly this is not working. Can you please help?
In attach I send also 3 images.
Thank you in advance.

CODE 1:

run("Specify...", "width=1000 height=1000 x=648 y=486 slice=1");
run("Crop");
rename("Original");
run("32-bit");
run("Subtract Background...", "rolling=20 light stack");
//run("Brightness/Contrast...");
run("Set Scale...", "distance=1000 known=110 unit=um");
setAutoThreshold("Default");
//run("Threshold...");
setOption("BlackBackground", false);
run("Convert to Mask", "method=Default background=Light calculate");
run("Analyze Particles...", "size=1-Infinity show=Outlines display exclude clear summarize stack")

CODE 2:

run("Specify...", "width=1000 height=1000 x=648 y=486 slice=1");
run("Crop");
rename("Original");
run("32-bit");
run("Subtract Background...", "rolling=20 light stack");
//run("Brightness/Contrast...");
run("Set Scale...", "distance=1000 known=110 unit=um");
setAutoThreshold("Default");
//run("Threshold...");
setOption("BlackBackground", false);
run("Convert to Mask", "method=Default background=Light calculate");
run("Analyze Particles...", "size=1-Infinity show=Outlines display exclude clear summarize stack");
rename("Cells");
run("Fill Holes", "stack");
run("32-bit");
run("Duplicate...", "title=Cells-tmin1 duplicate range=2-61");
selectWindow("Cells");
run("Duplicate...", "title=Cells-t duplicate range=1-60");
imageCalculator("Subtract create stack", "Cells-tmin1","Cells-t");
selectWindow("Result of Cells-tmin1");
//run("Brightness/Contrast...");
run("Analyze Particles...", "size=1-Infinity show=Outlines display exclude clear summarize stack");
run("8-bit");
run("Analyze Particles...", "size=1-Infinity show=Outlines display exclude clear summarize stack");

Hi @Patricialves, and welcome!

When I make a stack of your 3 images and run Code 2 (adjusting slice numbers accordingly in the macro) I get this error:

Is that what you are getting, or do you have some other problem?

Also, what are the 2 successive “Analyze Particles” commands at the end of Code 2 supposed to be measuring?

Thanks – hope this helps.

1 Like

Hi @tswayne, thanks!

Yes, I had this problem also.
The other trouble that I found is that I can´t obtain yet the best results when I run the code 2. After I run this, I obtain an image from the subtraction process and the cells appear white and black with the gray background (image attached). Maybe I am thinking wrong but I thought that regulating the minimum/maximum selecting: Image > Adjust > contrast, I would obtain only the black (old bacteria, that still attached to the surface) and only white cells (new ones). I think the error is because the cells had holes when I use the tool “fill holes”, as you can see in the image attached.

Thank you so much.

Hi @Patricialves,

Brightness/Contrast adjustment doesn’t affect the pixel values, unless you Apply the changes. And it seems like the macro code does not make any change to the pixel values. So the thresholding is not affected.

It’s important to know that the macro recorder doesn’t always capture every manipulation. Sometimes it will record a line like //run("Brightness/Contrast..."); that does nothing in your code; anything preceded by // is a comment and is ignored by the macro interpreter – it is included for information only.

Maybe a better way to approach the thresholding is to change this line:

run("Convert to Mask", "method=Default background=Light calculate");

to use another method (use the pull-down in the Convert To Mask dialog) that captures your cells better.

Hope this helps.