Segmentation to measure copepod length

Hello,

I am working on a class project where I am attempting to perform segmentation on images of copepods. The ultimate goal is to measure the prosome (body) length, excluding the tail segments.

I am still pretty new to image processing in general, so I am reaching out to the community to find out if anyone has other suggestions for tools I could try before I commit more time to training in ilastik.

Things I’ve tried:
I’ve trained in ilastik on pixel classification mode. It was underestimating the size of my copepods due to uncertainty on the edges. When I upped the level of precision in my annotations, the overall improvement in the results was very minimal.
I’ve also tried the findContours and fitEllipse functions in the python cv2 package. However, this is not currently finding the right contours or fitting ellipses to the correct place on the majority of images.

I am attaching several example photos.The grid segments are each 1 mm.

Thank you for any suggestions.

Andrea

Hi @aquets21,

those are cute little fellas. The overall problem I see is that the scale of the images varies, as well as the overall appearance. Those are difficulties that make image processing in general a bit harder.

How do you account for the different scalings right now? Do you measure the grid automatically, by hand? If you know the size of the grid, already, you could first rescale the images appropriately so that that pixels all represent the same physical size.

Then I would qualitatively select a few of these images for pixel classification training (3-7) and see how the classifier performs under these different conditions.

If the segmentation is not good enough, you can always try the autocontext workflow for better results.

As for the measurements, you can probably analyse the skeleton e.g. in fiji.

Cheers
Dominik

Hi, would it be possible to have a homogeneous background (no grid) ?
Then you could have a chance to do a classic intensity-based thresholding. And then if the antennas are detected you could erode the binary image a number of times until they disappear and dilate back the same number of time to recover the initial body size.

Having the same size of images as mentioned above would also help to have one set of working parameters (number of erosions…)

Hi @k-dominik and @LThomas

Thanks for your help!

I haven’t tried anything to adjust for scale yet. I’ve been planning to do this step downstream, but I’ll give it a shot before training in ilastik. I’m currently doing this by hand, but I need to be doing it automatically because I have ~10,000 images that I’m working with.

I had been blurring but I hadn’t thought about eroding. I will look into options for doing that. I found an Erode 3D plugin in fiji, is this the function that you would recommend using? Or something else?

Andrea

Hi again,

Quick update.
I haven’t had a chance to work too hard on the issue with the scales yet, but I quickly tried out the erode and dilate functions in fiji followed by the python ellipse-fitting script that I had from before. And it’s getting 70% of a test set of images with decent accuracy!

Andrea

Dear Andrea,

is there any reason, why you have 10 000 images with one copepod each?
Is it feasible to make instead 100 images with 100 copepods each?

Kind regards

Tobias

Cool, well done !

I rather though of Process>Binary>Erode/Dilate once you have done the thresholding.

This is a good step before thresholding indeed.

You can also do the ellipse fitting in Fiji and get the ellipse dimensions. If that works this would save you switching programming environment.
Edit>Selection>Fit Ellipse
also do
Analyze>Set Measurements> Tick fit ellipse
and once you have the ellipse running measure (or pressing M) should give you the ellipse axis length and the ellipse angle.

I would like to add that there was also an R package available for Zooplankton measurements which called ImageJ and R to measure different shapes, see:

Maybe you can contact the author to get some classification tips.

Thanks for all the suggestions!

@LThomas I’ve switched to an entirely fiji pipeline and am doing the erode/dilate and using the fit ellipse and measure functions which you mentioned. Also I’ve started excluding particles which are touching the edges using the analyze particles function (which is helping with some of the more difficult images). Now fiji is fitting ellipses with over 80% accuracy and exporting measurements for each. Still working through issues of scale, but it’s overall moving in a good direction and I’m really happy with it.

@Tobias I would consider putting multiple individuals in an image in the future, but it is too late for this project because I would have had to decide to do that during the research design phase.

@Bio7 That’s really cool. I’ll keep the package in mind for future projects.

Well done !
By accuracy do you mean compared to manual length measurement ?
or that it just fails on 20% of the dataset ?
For the latter, it might be hard to have it working for each image, but then if the measured values do not make sense because the workflow fails, you can try to filter those outliers cases.
A bit like removing small debris when you segment cells, you see what I mean.