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

Nuclear size modification in script #672

Open
megleila opened this issue Jul 6, 2023 · 4 comments
Open

Nuclear size modification in script #672

megleila opened this issue Jul 6, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@megleila
Copy link

megleila commented Jul 6, 2023

I am trying out using Mesmer for segmentation through the Bodenmiller steinbock/IMCRtools pipeline and applying it on human kidney tissue samples. I am finding that using the default training data for Mesmer is resulting in very small (1-2 pixel in size) debris being identified as nuclei. This happens both for cell segmentation and for nuclear segmentation. Looking at the source code available online (https://deepcell.readthedocs.io/en/latest/_modules/deepcell/applications/mesmer.html), I wondered whether you would recommend adjusting any of these parameters (ie nuclear radius) for this issue, or if you had another suggestion I could try? Is this a common issue?

Wondered if you had a suggested alteration to source code or training data to use to improve inappropriate labeling of debris as nuclei. We previously segmented using Ilastik/CellProfiler, but are looking for a more streamlined approach -- and additionally the segmentation of true nuclei does appear more accurate in DeepCell than it does in our former approach.

Deepcell segmentation including many very small debris identified as cells/nuclei

Nuclear marker only

@megleila megleila added the bug Something isn't working label Jul 6, 2023
@ngreenwald
Copy link
Collaborator

Hey @megleila, I would first try submitting the same image to deepcell.org/predict. The issue you're raising should be addressed by the default parameters, so I want to check and see if something specific about how the model is being run within steinbock

@megleila
Copy link
Author

When I submit my image for Mesmer on deepcell.org/predict setting the resolution appropriately to be 10x 1um/pixel, it seems to be the same result or at least definitely the same issue — although I’ve tried everything and I can only see segmentation of the very top ribbon of the image using this site. The size of the image is 1500x700, so not bigger than allowed by the site.
image

I tried running the program at 20x (0.5um/pixel) which is not the accurate resolution, and the smaller nuclei are fewer in number but some of the other segmentation looks a little off. Nuclear outlines still cut off or incompletely done for whatever reason as you can see.
image

Raw image I imported to deepcell.org/predict:
image

@ngreenwald
Copy link
Collaborator

Got it, thanks for the detailed response.

I'm not sure why the display is only loading the first set of segmentations, perhaps someone else (@rossbar?) could chime in. I remember this issue popped up before when there was a limit set on the number of segmentations that could be displayed at once, since they're numbered sequentially from the top.

I think I figured out the issue with small cells. The post-processing function we use for mesmer is here. There's an argument, small_objects_threshold, which controls the minimum size of a cell in order to be included. This is set in the kwargs dict here. However, I think these settings apply to the resized image, not the input image. So the default of 15 pixels becomes 4 pixels when resized from 20X (what the model is run at) to 10X (what is being returned). Hence you end up getting cells which are much smaller than desired. You should be able to change this default setting if you're calling the function directly.

@megleila
Copy link
Author

megleila commented Jul 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants