overlay mask of cells

905 views
Skip to first unread message

Niki

unread,
May 31, 2018, 10:29:39 AM5/31/18
to QuPath users
thanks to amazing scripts available in this googlegroup and Pete's blog, i was able to export object masks and measurements to apply my own analytic method. 
now i want to import the result and check whether it worked well or not.
With CellProfiler, it was quite straightword to produce a result image like the first picture using a mask like the second picture. but now i'm stuck.. for example, opening a mask file in ImageJ and run 'send overlay to QuPath' ends up with a weird result like the third picture attached. any help or hint would be appreciated! thanks in advance!!



1.PNG
2_2.png
3.PNG

Niki

unread,
May 31, 2018, 10:34:26 AM5/31/18
to QuPath users
i guess it might be related to the fact that the original image (to be overlaid by object boundaries) is .tiff format ... see what i've found. but i don't know what to do any more! 
4.PNG

Pete

unread,
May 31, 2018, 10:35:54 AM5/31/18
to QuPath users
The Send overlay to QuPath relies heavily on the image properties in ImageJ (under Image -> Properties...).  That's where the origin and scaling information is found - and is needed to figure out where to bring back the ImageJ rois into QuPath.

By default, QuPath will set the properties appropriately when extracting a region and sending it to ImageJ.  But it's possible to run commands in ImageJ that might create duplicate images and lose this info.  Or if you save images as PNG (or really anything other than TIFF) then the properties can be lost too.

Could this be the explanation?  Can you describe in more detail the processing steps involved?

micros...@gmail.com

unread,
May 31, 2018, 10:38:35 AM5/31/18
to QuPath users
It looks like you lost your downsample ratio somewhere along the way.  Without knowing more about what and how you were doing the manipulation outside of QuPath, I don't really have much to go on.  Normally when you send a region from QuPath to ImageJ through the ImageJ extension, it keeps track of the size and position for you.  If you are doing things some other way, you will have to keep track of all of the relative pixel information yourself. 

micros...@gmail.com

unread,
May 31, 2018, 10:39:11 AM5/31/18
to QuPath users
Whoops, I was slow! :)

Niki

unread,
May 31, 2018, 10:58:13 AM5/31/18
to QuPath users
I created a project and added an original image and a mask image file.
i ran 'send region to imageJ' with downsize = 1 on the mask image. in ImageJ, I ran 'select all > create selection > overlay (add selection) > send overlay to QuPath'. 

attached is a sample original image and mask image file..


TA1526A_001.png
TA1526A_001.tif

Niki

unread,
May 31, 2018, 11:00:12 AM5/31/18
to QuPath users
or is it possible to produce the overlaid image in ImageJ?? but I'm an extreme newbie to ImageJ... 

micros...@gmail.com

unread,
May 31, 2018, 11:10:55 AM5/31/18
to QuPath users
Ah, I was going to say, it sounded like you were skipping a step since the selection in ImageJ requires a mask.  If you use the threshold tool in ImageJ to generate the mask within the image you have sent to ImageJ, the returned objects work (see image).  The fact that your mask is a png is probably the problem if you are trying to return that.  Maybe convert it into a .tif file and use the Image/Properties in ImageJ to make sure it has the same pixel size as your original image.
Auto Generated Inline Image 1

micros...@gmail.com

unread,
May 31, 2018, 11:15:21 AM5/31/18
to QuPath users
It actually looks like what you are ending up with, though, might be replicated entirely within QuPath using the Analyze/Region Identification/Tiles and superpixels/SLIC superpixel segmentation.  You would need to add some measurements and create a classifier, but I think you could end up with the same sort of result.

On the other hand, there does not appear to be anything relevant to the mask within the same region of the .tif file, despite having the same name, so I am not sure what you are detecting.  Is there any chance that your other process is generating a file name mismatch when generating the mask?

Niki

unread,
May 31, 2018, 9:09:07 PM5/31/18
to QuPath users
thanks to your hint, i was finally able to create the overlaid image on ImageJ (attached). and i realized that i don't need to bring the ROI back to QuPath. All I need is to save this image... thanks again! 

Pete

unread,
Jun 1, 2018, 2:19:29 AM6/1/18
to QuPath users
It looks like the TIFF was written by ImageScope and not QuPath (right?).  If you do your tiling in QuPath, saving ImageJ TIFFs, then it should be possible to get any regions back from your masks and into QuPath - in the right locations within the whole slide image.

In this case, it's being confused because there pixel size information in the TIFF that is inconsistent with the (lack of) pixel size information in the PNG.

To get it to work, you'd either need to 
1. transfer your ImageJ ROIs to the image with the pixel size information (i.e. TIFF) before sending them back to QuPath, or
2. copy the pixel size information to the binary image in ImageJ (which means setting the Calibration on an ImagePlus)

I remain a bit confused by where QuPath fits into all this, but if it's resolved that's good :)
Reply all
Reply to author
Forward
0 new messages