Counting Fluorescent Bacterial Cells in a Flow


I’m an undergraduate student and I am trying to use ImageJ to count the number of fluorescent bacteria cells flowing into and out of a device in a microfluidic channel.

Attached below is a movie file of the inlet of the device that I have converted into an 8-bit TIF format. The device is out of frame just on the right side of this image sequence.

My goal is to be able to count the number of fluorescent bacteria cells that are flowing into and out of the device (movie above only shows the inlet flow).

Right now, I’m relying on the plugin called ‘Mosaic’ that allows for particle trajectory tracking and counting. Basically, I am currently relying on counting the number of trajectories. However, I find that this method gives inaccurate results as there are problems with trajectory linking.

What is the best way about doing this?

Thanks in advance!

Hi @Johanes and welcome to the Forum!

If your final goal is just counting, a very simple approach is to reslice the image using a line profile and counting the spots in the resulting image.

The image below represents such a reslice using a line across your data orthogonal to the flow of bacteria. The time is in the X direction.

Counting local maxima yields this

Which is the number of bacteria that have crossed the line profile.

If you need more information regarding the bacteria, like speed or velocity or position, then this will not be sufficient.

To try it yourself, you can run this macro on the image you uploaded within Fiji. It will open a results table with the count of bacteria that passed through the line profile.

makeLine(118, 3, 118, 97);
run("Reslice [/]...", "output=1.000 slice_count=1 rotate avoid");
run("Find Maxima...", "prominence=10 exclude output=Count");

Here is the documentation on the reslice function

Kudos to @oburri for a very elegant solution.

Just to add, you may have problems with track linkage as the stack you uploaded appears to have a ‘jump’ every 18 frames.

Just be aware that because of this, using the above method would likely underestimate the count (if bacteria ‘jumped’ across the line profile).


1 Like

Good catch, @dnmason!

There seems to be a problem with the acquisition, so this should definitively be adressed before doing any analysis…

Sorry for the delayed response guys!

@oburri thank you so much! This worked flawlessly! Such an elegant solution to this problem.

@dnmason Good catch! Thank you for this. I think the problem with my image acquisition was the fact that I formatted the output file as .avi

I’ve fixed this by just outputting an image sequence instead.

Thank you guys once again!