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

Extract coordinates of nuclei in image #12

Closed
hossam-zaki opened this issue Jun 11, 2021 · 4 comments
Closed

Extract coordinates of nuclei in image #12

hossam-zaki opened this issue Jun 11, 2021 · 4 comments

Comments

@hossam-zaki
Copy link

Hello!

Hope all is well. I have two images. One with the H+E staining, and another one, which is the exact same, but is colored by cell label. I'm wondering if it is possible to extract the coordinates of each nuclei in the input image? I would like to go from the nuclei in one picture to its label in the other using the coordinates. Is this possible?

See the two images below (this is from an open source dataset):

Screen Shot 2021-06-10 at 11 40 33 PM

Screen Shot 2021-06-10 at 11 40 48 PM

@guillaumejaume
Copy link
Contributor

guillaumejaume commented Jun 11, 2021

Hi,

I guess you can try something like that:

from histocartography.preprocessing import NucleiExtractor
from PIL import Image
import numpy as np

# 1. load image 
image = np.array(Image.open(image.png)) # or whatever your image name is 

# 2. extract nuclei as an instance map & centroids (coords)
extractor = NucleiExtractor(pretrained_data='monusac')  # you can try another checkpoint with 'pannuke'
instance_map, instance_centroids = extractor.process(image)  # instance_centroids is what you look for     

Keeping in mind that Monusac and PanNuke datasets include mostly high magnification images. Your image seems to be at low magnification, so maybe try to run the algo with a better resolution, if possible.

@hossam-zaki
Copy link
Author

hossam-zaki commented Jun 17, 2021

Hi! Thanks a lot for the response..

I ended up trying this out, but it outputted some centroids that were outside of the image, as seen in this screenshot.

Screen Shot 2021-06-18 at 2 09 35 AM

Any advice with this? Am I getting the centroids properly? Really appreciate your help and love the package

@guillaumejaume
Copy link
Contributor

Can you print the image size?

Numpy and image-based packages use different indexing conventions, (row,col) for numpy and (x,y) for PIL, cv2 etc.

@hossam-zaki
Copy link
Author

Sure. Check this out.

I was thinking it could be reversed, but wanted to double check. Really appreciate your help!
Screen Shot 2021-06-18 at 2 59 04 AM

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

2 participants