Export results of nucleus and membrane segmentation

415 views
Skip to first unread message

Stephen Yip

unread,
Sep 20, 2017, 8:30:31 AM9/20/17
to QuPath users
Hi,

I used the cell detection function to segment individual nucleus and cell membrane on a HE slide. The results look great. However, I can't find the option which allows me to export the segmentation results (nucleus and membrane).

Does anyone know how to do that?

Thank you very much!
Stephen

P.S. I found a script that export the annotation (user defined region-of-interest), but NOT the individual nucleus or cell segmentations.

micros...@gmail.com

unread,
Sep 20, 2017, 8:48:00 AM9/20/17
to QuPath users
I'm not 100% sure what you mean, but have you tried saving the detection measurements to a tab delimited file in the Measure-> Show Detection Measurements?  It's frequently too large to copy and paste into an Excel file, but it should get you all of the measurements listed for each cell that was generated.

Also that command can be duplicated in script with a variant of   saveTMAMeasurements(string, ) saveAnnotationMeasurements(string, ) saveDetectionMeasurements(string,)
where string is the file location.  There are some tricks to this though, like Windows requires two slashes for the folder structure.

Stephen Yip

unread,
Sep 20, 2017, 9:46:21 AM9/20/17
to QuPath users
Hi, 

Not exporting the measurements. I want to export only the red contours (as mask) within the green region of interest. Do you know how I can do that? Thank you!




Message has been deleted

Pete

unread,
Sep 20, 2017, 12:59:46 PM9/20/17
to QuPath users
There are a couple of ways you could approach this, but I'm not sure exactly what the result should be.

I guess this is probably the annotation export that you saw:

That could also be a starting point; in the simplest case you'd just have to change getAnnotationObjects() to become getDetectionObjects()... however then there are a few more things to consider:
  • You'd probably want to set the downsample to be 1, since cells are small.  But this would only work if you have a small image; if you have a whole slide image, you wouldn't be able to export the whole thing at this resolution.  Therefore you'd need to restrict the export to only part of the image.  Is there always a 'parent annotation' object that should be used to define this region?
  • In addition to drawing the main cell ROI (accessed using getROI() - exactly as in the annotation case), you'd also need to call getNucleusROI() to get the nucleus, and paint it as well.
  • If you want to just draw the ROI outlines, then you should use g2d.draw(shape) instead of g2d.fill(shape).  However, if you want to fill the ROIs then you have the problem that the cell ROI would overwrite the nucleus ROI.  So you'd have to either export them in two separate images, or else paint the nuclei using a different color.  In the second case, you will have to paint the cell first and nucleus second.
An alternative is to use Extensions -> ImageJ -> Send region to ImageJ.  This will also send the ROIs to ImageJ as part of an overlay - and even set the offset information in the image properties so that it's possible to calculate from where in the image the ROIs originally came.

If you do this, you then have an ImageJ painting problem to solve, rather than a straight Java one.  You can begin to address it by using (within ImageJ) Image -> Overlay -> To Roi Manager.  Then under the More button in the ROI Manager there are Draw and Fill options (or also ImageJ macro functions roiManager("draw") and roiManager("fill")).  You could paint the background black and set the color to be whatever you want for the cells.... and convert the image to 8-bit if needed.

I'm not sure what the aim is or which way you'd want to go (pure Java/Groovy or ImageJ), but hopefully this gives a starting point.
Reply all
Reply to author
Forward
0 new messages