ariel-waisman / LabelsToROIs

A Fiji/ImageJ plugin to generate ROIs from label images, allowing ROI erosion and quantification
GNU General Public License v3.0
21 stars 9 forks source link

remove small lables #9

Closed JustineJiao closed 2 years ago

JustineJiao commented 2 years ago

Hi there, It's me again^_^

I tried to precess labeled images generated by Cellpose with LabelsToROIs, but I constantly found some small labels/particles that equels to 1 pixel, which affect cell size calculation.

When I "Analyze Regions" in MorpholibJ, there is no such small labels shown, so I suspect that this is caused by LabelsToROIs.

Do you have any idea to remove these small lables?

Thanks a lot!

Justine

CT4-1-1 1_cp_masks_Erosion_0px_Outlines

ariel-waisman commented 2 years ago

Hi Justine,

Could you send the original label image for this example? By hovering with the mouse on that pixel you can check the label value (or Id), which appears at the bottom left of imageJ main window. This will tell if the problem is with CellPose segmentation or further down the line.

Cheers, Ariel

El jue., 19 may. 2022 01:08, JustineJiao @.***> escribió:

Hi there, It's me again^_^

I tried to precess labeled images generated by Cellpose with LabelsToROIs, but I constantly found some small labels/particles that equels to 1 pixel, which affect cell size calculation.

When I "Analyze Regions" in MorpholibJ, there is no such small labels shown, so I suspect that this is caused by LabelsToROIs.

Do you have any idea to remove these small lables?

Thanks a lot!

Justine

[image: CT4-1-1 1_cp_masks_Erosion_0px_Outlines] https://user-images.githubusercontent.com/58281975/169202279-5617deb3-188e-45f7-8961-36eb9bf5c4c7.png

— Reply to this email directly, view it on GitHub https://github.com/ariel-waisman/LabelsToROIs/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFAA54CKNPJOGCC2R6ZQ6ADVKW5DZANCNFSM5WK2YYFA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ariel-waisman commented 2 years ago

Hi Justine,

Just saw that you had already sent the original image :D I just saw that the problem lies in the original label image. That pixel has the same label ID (8) that the brown big cell to the right

labels2

Is this the result of Cellpose's segmentation just as it comes from the software? If this s the case, it must be a glitch of Cellpose, maybe you can generate an issue showing this in Cellpose's github page.

For some "cells" as the one shown, the label also includes a disconnected pixel. Since the overall label (extra pixel + cell) has a large area, you cannot size filter it using MorpholibJ/Label Images/Label Size Filtering.

But there is a small trick that you could use to circumvent this:

1) Based on Cellpose's label image, you can generate a "re-mapped" one with new labels using the "Connected components labeling" plugin from Fiji, with options 16 bit and connectivity of 4. (bare in mind, there are two similar connected components labeling plugins, use the one that says componentS in plural. This will generate a similar label image, but with a unique label ID for all the "connected" label pixels. This means that the "extra pixel" will now have a different ID than the remaining on the cell. Now, you can size filter it to exclude small labels or single pixels using MorpholibJ/Label Images/Label Size Filtering

See how now that pixel is not included in the final label. Thus, LabelsToROIs will not identify it as a ROi. I also show you how you can change the color of the gray scale labels, which are not that confortable to see.

label3

Hope this helps! Cheers, Ariel

JustineJiao commented 2 years ago

Great thanks! It's very helpful. You are right, this maybe a glitch of Cellpose. Again, thank you so much! Justine Jiao