Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

single pixel outlier #516

Open
JustineJiao opened this issue May 20, 2022 · 9 comments
Open

single pixel outlier #516

JustineJiao opened this issue May 20, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@JustineJiao
Copy link

Hi there,

When I segment polyonal cells using Cellpose, I found some single pixel outlier.
Like in this labeled image, that pixel has the same label ID that the brown big cell to the right. When I processed this labeled image in LabelsToROIs plugin (https://github.com/ariel-waisman/LabelsToROIs), this single pixel would be recognized as one cell, which will affect cell size calculation.

We suspect this is a glitch of Cellpose. Generally, it's not a big problem, but I think you should know.

Does anyone faced this situation?

Justine Jiao

image

image

@mayishazn
Copy link

On the jupyter notebook version I have a line in my code setting a minarea=100 and then
masks, flows, styles = model.eval(imgs, diameter=diam, channels=channels, do_3D=False, min_size=minarea, resample=True, progress=True)

It takes care of impossibly small cells for me. Hope this helps!

@JustineJiao
Copy link
Author

@mayishazn I tried this method but it didn't work. The single pixel belongs to the big label to the right, which means that they are one large label, so the single pixel can not filter by its size.
Thanks anyway.

@LeahdamF
Copy link

LeahdamF commented Nov 2, 2022

This is exactly the issue I'm having: single pixels belonging to a neighboring big cell. Has anyone found a solution?

@lopollar
Copy link

lopollar commented Mar 1, 2023

When segmenting nuclei, I often end up with similar issues, where one or two pixels end up outside of the shape. However, when performing segmentation on whole cells, I often get more pixels not being connected (more often=10% of the segmentation masks aren't connected).
When performing segmentation and then looking at the segmentation mask of one cell (in this case cell 3), I end up with this shape:
image
Is there any explanation on how this is possible? And how to solve it?
This greatly influences the downstream analysis.
I can give way more context, examples and example code if wanted.
In general though I am extremely happy with the results of cellpose.
Thanks a lot,

Lotte

@carsen-stringer
Copy link
Member

thanks @lopollar , can you give more context for your problem? is that in 3D or in 2D segmentation? your case seems a bit different

we can add an option to run a connected components check after the segmentation to remove single pixel outliers (cc @mrariden )

@carsen-stringer carsen-stringer added the enhancement New feature or request label May 9, 2023
@lopollar
Copy link

It is 2D segmentation using the cyto option.
The problem arises for me when creating shapes (with shapely) out of the masks after the segmentation.
However, when plotting the masks, it is clearly related to those.
A connected component analysis wouldn't be a bad thing to run I think!

@yassinharim
Copy link

As suggested by @mrariden I thought to contribute my experience with the similar issue :)

I'm experiencing an issue with a model to recognise DAPI-stained nuclei in 2D images. If a certain mask is affected, it is correctly generated to mark a nucleus - but then, there is one more pixel, completely detached from the original mask, that Cellpose considers as a part of this mask as well. The issue already happens at the standard settings of flow_threshold = 0.4 and cell_prob_threshold = 0.0, but is pronounced at settings of flow_threshold = 0.6 and cell_prob_threshold = -1.0 that generally improve detection of cells in the model.
This causes issues in my downstream analysis, as I am importing ROIs into ImageJ from label images and this situation would then generate two separate ROIs from one gray value in the label image, throwing off the ROI counting.

This issue seems to be restricted to several versions (including the most current ones) of the model - earlier versions do not have this problem.

I'm attaching some screenshots below for you, as well as attaching the model and a sample image (ZIP because the file types were not allowed).

Bug1
Bug2

Here's another example of a mask from a model with flow_threshold = 0.9 and cell_prob_threshold = -3.0 that is basically a line, and is also split in two different parts:

One-dimensional mask

DAPI_40X.zip
Sample image.zip

@yassinharim
Copy link

Hey, I just wanted to bring up this issue again and ask if there are any plans to implement this post-processing for connected components in the future?

@carsen-stringer
Copy link
Member

we can add it as an optional post-processing step, a PR is welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants