Exporting an image with measurement map attached

139 views
Skip to first unread message

nicholas...@gmail.com

unread,
Sep 19, 2018, 11:47:08 AM9/19/18
to QuPath users
Hi! 
I have a question regarding an automated export of an image with a measurement map on it. Essentially, I want to visualize the location of more or less intense staining, for presentation purposes etc. Because I am comparing multiple images to each other, all of which went through identical analysis, I would like to show images of the slides with the same measurement map settings on them (settings of lower and upper color range kept consistent). Is there a way to automate this? I cannot seem to export the image region with the measurement map on them. 
Let me know if this is possible! Thanks in advance for your time. 

Nick
Example Image w Measurement Map.JPG

micros...@gmail.com

unread,
Sep 19, 2018, 12:37:46 PM9/19/18
to QuPath users
It may be possible through scripting, though I have not had any luck manually adjusting the map settings.  The closest I could suggest would be the creation of two "dummy" cells where you edit the values you are interested in directly.  As long as those two dummy values bracketed your entire set of data/images (they were the lowest and highest values of any cell), and were present in each image, you would end up with the same color map in each image.  

I am not sure about compressing the Measurement Map colors afterwards, however.  That may have to be done manually.  I would love to see it as a script though!

Pete

unread,
Sep 19, 2018, 2:09:10 PM9/19/18
to QuPath users
I've just written a script to show how to set a measurement map with specified ranges: https://gist.github.com/petebankhead/3dd03008570ee3e4ae6c449aba209a5d

To export the image for the current viewer, you could use one of the methods to export snapshots or send a snapshot to ImageJ: https://github.com/qupath/qupath/wiki/Exporting-results#exporting-snapshots

Alternatively, if you want to script this part as well, this recent discussion could help: https://groups.google.com/d/msg/qupath-users/FiQ6FuEMORQ/m-04ZcirBQAJ

nicholas...@gmail.com

unread,
Sep 20, 2018, 9:08:15 AM9/20/18
to QuPath users
Hi Pete, 

I've been plugging along with this method but I think I made it more complex then necessary. It turns out that with the CellIntensity thresholds, all I really need to do is export the image region with the objects on top. I can do this manually very easily (include overlays), but I wonder if there is a script so that I can do so by batches, as it will get tedious doing so for hundreds of images. 

Currently my exported JPEG looks like the attached file, which is fine for what I am looking for.

Thanks for your help, 

Nick
Brain with Objects.jpg

Pete

unread,
Sep 20, 2018, 9:26:02 AM9/20/18
to QuPath users
Hi Nick,

From the screenshots you're still using the measurement map (right?), so it sounds a bit like a combination of the first and third scripts from my last post - although I'm not sure if this would be best.

You mention visualizing areas of more/less intense staining.  What do you gain from doing this kind of export compared to just exporting a low resolution version of the raw image, or perhaps the image of the 'brown' channel after color deconvolution (https://github.com/qupath/qupath/wiki/Changing-colors#applying-color-transforms)?  Is it important to see individual detected cells as well?

Definitely doing such an export manually hundreds of times would be a miserable task, but once you get into scripting the a lot more options become available.... like creating completely different kinds of density maps or pseudocolor visualizations.  In the screenshot, I find the QuPath objects kind of distracting because they obscure my view of the original image - but I don't know what the purpose of the visualization should be.  Can you say more about this, and what the ideal display would look like (ignoring what QuPath can currently give you)?

Pete

nicholas...@gmail.com

unread,
Sep 20, 2018, 9:34:18 AM9/20/18
to QuPath users
On further thought I think you are completely right in simply exporting the DAB stained image- while it will be useful to have a few images with the Qupath objects on them, those are not the primary concern apart from demonstrating our methods. 
The purpose of the visualization is twofold- one, showing the methodology for actual quantification of DAB staining intensity, but that can probably just be a few representative images, so I am less concerned about scripting. Two, we want to be able to have images of consistent brightness/contrast/intensity to compare for all slides we analyze, as there is a lot of qualitative or semi-quantitative analysis still in the field, and this would leave open the option for densitometry analysis after the original analysis, using only the raw pixel information in the exported JPEG.
So to simplify even more- a scripted method for exporting the DAB channel at a consistent brightness and contrast would be ideal, preferably similarly to how annotation level measurements can be exported. 
 Thank you!!

Nick

Pete

unread,
Sep 20, 2018, 10:08:31 AM9/20/18
to QuPath users
Ah, the DAB export is a bit tricky as the image is 32-bit in QuPath - and this generally won't display very nicely in any other software, so you'll be left unable to view it easily.  Also attempting to measure intensities for DAB from color deconvolved images isn't really a good idea - there's more explanation at http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html

If you need a low-resolution overview, I'd strongly prefer to export the original image - without color transforms first.  That should still give you a decent impression of the overall staining, and you've the option of doing batch analysis/conversion using Fiji later (http://fiji.sc - I believe the author of the link above wrote the original color deconvolution plugin available in Fiji).  For this, you'll likely need to detect the tissue... for which having the DAB information alone won't be enough anyway.

If your images are in a QuPath project, you already get low resolution images 'for free' - just take the images inside the 'thumbnails' sub-folder within the project folder.  But this doesn't give you any control about the export resolution, which could vary for each image.

We could create a script to export the low-resolution images more consistently... but if it's for future-proofing in case you want to do other analysis later, is it needed?  In that case it would be preferable to then return to the original (whole slide?) images, and depending on how much later 'later' is, there may already be updates to QuPath that could make subsequent analysis easier and better using the whole slide image directly...
Reply all
Reply to author
Forward
0 new messages