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

Segmenting cytoplasm with S3 and Mesmer #479

Closed
aandytu opened this issue Feb 16, 2023 · 11 comments
Closed

Segmenting cytoplasm with S3 and Mesmer #479

aandytu opened this issue Feb 16, 2023 · 11 comments

Comments

@aandytu
Copy link

aandytu commented Feb 16, 2023

Hi, I'm testing using mcmicro to do some segmentation on some Akoya Phenocycler produced images. I would love to compare several different methods. Some of the documentation around using cytoplasm/membrane stains are a bit unclear:

  1. For segmenting cytoplasm with S3, there seems to be an option to pass multiple channels to --CytoMaskChan, from reading some of the examples people have posted here. What does S3 do with the multiple channels? are they summed across pixels?
  2. For running Mesmer, the docker file provided by the vanvalenlab/deepcell-application indicates several additional membrane related options (such as --membrane-image and --membrane-channel) that are not included in the mcmicro documentation. Can those parameters be passed via the params.yml file?
@clarenceyapp
Copy link
Collaborator

Hi @aandytu ,
I can answer question 1. The channels are max projected.

@ArtemSokolov
Copy link
Collaborator

For question 2, the image gets staged inside a work/ folder for Mesmer, so you can reference it directly in your params.yml. For example:

workflow:
  segmentation: mesmer
options:
  mesmer: --membrane-image myimage.ome.tif --membrane-channel 5

Important caveats:

  • This assumes that you have a single myimage.ome.tif in your registration folder, and that you want to use the same image (but different channels) for nuclear and membrane information.
  • Mesmer uses 0-based channel indexing.

@marcovarrone
Copy link

Hi @aandytu , I can answer question 1. The channels are max projected.

Max projection sounds much more reasonable than summing!
Then I think the documentation on s3seg as some outdated parts, as in here, where it says "To combine and sum the 10th and 11th channels, use --CytoMaskChan 10 11"

@clarenceyapp
Copy link
Collaborator

@marcovarrone Thanks for the catch! We'll get that sorted out as soon as possible.

@MiTPenguin
Copy link

Hi @clarenceyapp and @ArtemSokolov,

Thanks for your help! I was able to get it to work. There are a couple of outstanding small issues:

  1. The deepcell container doesn't take in LZW compressed images, which is the default coming out of Akoya. I've looked at the dockerfile and seems like an easy fix (will test later).
  2. There's no qc when segementation is done with mesmer. Is there a way to add this in (or could you point me to where I could modify this part of the pipeline)?

@ArtemSokolov
Copy link
Collaborator

Hi @MiTPenguin,

For 1, I would ping the Mesmer developers in this thread: vanvalenlab/deepcell-applications#26 They just need to add imagecodecs to their pip install directive in the Dockerfile, and the method should be able to read LZW-compressed images without any other changes.

For 2, can you try doing the following in your params.yml:

modules:
  segmentation:
    -
      name: mesmer
      watershed: bypass

This will tell MCMICRO to pass the output of mesmer through s3seg, which will generate a QC outlines file without any additional processing of the output mask. Let me know if this doesn't work, and we can brainstorm another solution.

@clarenceyapp
Copy link
Collaborator

@MiTPenguin @ArtemSokolov S3segmenter will not outline mesmer masks properly as discussed towards the bottom of this thread here. The outlining code assumes a 0-intensity line between objects. Since mesmer masks do not have this, only cells that are next to background areas get outlined properly but not inner edges between other cells. There are ways to address this and I am experimenting with edge detectors. These won't give identical results but should give enough visual aid to QC segmentation accuracy.

@MiTPenguin
Copy link

@clarenceyapp @ArtemSokolov Thanks for the info! these things always have such intricacies in them.

I was looking to see if there's an imageJ solution to this, and came across a discussion on image.sc somewhat recently. Have you guys tried it?

@ArtemSokolov
Copy link
Collaborator

@clarenceyapp You shouldn't need an edge detector. How are you generating the QC images? skimage.segmentation.find_boundaries() should correctly produce outlines even if neighboring cells touch. If you run the function before any relabeling, that should do the trick.

Also, could the user not prevent relabeling by setting the logSigma range to [0, <really big number>], so that nothing gets excluded from the original mask?

@aandytu
Copy link
Author

aandytu commented Feb 24, 2023

deepcell.utils.plot_utils provides make_outline_overlay that draws outline from prediction mask from mesmer. I've used it sucessfully (though it's a bit limiting). Perhaps that's useful?

@aandytu
Copy link
Author

aandytu commented Mar 1, 2023

For 1, I would ping the Mesmer developers in this thread: vanvalenlab/deepcell-applications#26 They just need to add imagecodecs to their pip install directive in the Dockerfile, and the method should be able to read LZW-compressed images without any other changes.

@ArtemSokolov
Not sure what's the process on maintenance of deepcell-applications, but I added imagecodecs vanvalenlab/deepcell-applications#35 and it seems to be working now with compressed images. Do I just reference the docker image tag in the params.yml file to get mcmicro to pull that version?

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

No branches or pull requests

5 participants