DAB Intensity Histogram and Thresholding

First and foremost, happy holidays and thank you so much for all your help on this forum!

I’ve performed DAB staining and subsequently used a simple threshold on my annotations to identify the area that is positive for my protein marker of interest. However, I’m now currently trying to create histograms of DAB pixel intensities for my annotations to identify a threshold value 2 SD above the mean so that I can create a new thresholder that only identifies these areas of high expression.

Would this require scripting? If so, could you point me in the right direction on how I might achieve this?

Pretty sure that would require scripting, and the closest I have seen was Pete’s script here.

Thank you! I just tried that code and I got the following histograms (I’m assuming one is hematoxylin and the other is DAB?). However, they have negative values which I was unsure why that occurred?

I then looked back and it seems I got the following errors after the code ran:

ERROR: NegativeArraySizeException at line 14: -207209802

ERROR: java.desktop/java.awt.image.DataBufferInt.(Unknown Source)
java.desktop/java.awt.image.Raster.createPackedRaster(Unknown Source)
java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
java.desktop/java.awt.image.BufferedImage.(Unknown Source)
qupath.lib.images.servers.AbstractTileableImageServer.createDefaultRGBImage(AbstractTileableImageServer.java:211) qupath.lib.images.servers.AbstractTileableImageServer.readBufferedImage(AbstractTileableImageServer.java:250) qupath.lib.images.servers.AbstractTileableImageServer.readBufferedImage(AbstractTileableImageServer.java:56) qupath.lib.images.servers.ColorDeconvolutionImageServer.readBufferedImage(ColorDeconvolutionImageServer.java:164) qupath.lib.images.servers.ColorDeconvolutionImageServer.readBufferedImage(ColorDeconvolutionImageServer.java:57)
qupath.imagej.tools.IJTools.convertToImagePlus(IJTools.java:680)
qupath.imagej.tools.IJTools.convertToImagePlus(IJTools.java:719)
qupath.imagej.tools.IJTools$convertToImagePlus.call(Unknown Source)
Script1.run(Script1.groovy:15)
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:926)
qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:859)
qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:782)
qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1271)
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.base/java.util.concurrent.FutureTask.run(Unknown Source)
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.base/java.lang.Thread.run(Unknown Source)

Line 14 was the following command: def pathImage = IJTools.convertToImagePlus(server, region)

You would expect negative values from color deconvolved vectors, especially in cases with background correction. Check your cell measurements as well, especially min values. Negative values can show up frequently in low stain areas.

Array size might be including too many pixels. Maybe try a smaller area?

Thanks! Since I need to include a large annotation, would making tiles help bypass the error?

That was just a suggestion about the possible cause of the error. I suspect it has to do with the same Java array size restriction that prevents such images from being opened from ImageJ/FIJI in the first place. Too many pixels to fit in an array, so you can’t have an ImageJ histogram that contains that much data. You would need some other way of summarizing it. Maybe downsampling.

You could definitely try tiling if you wanted to see a lot of different histograms, but I am not sure that would help you.