Cell detection error java.lang.ArrayIndexOutOfBoundsException

Hello,

I’ve encountered an odd error when using Cell Detection that led to cell detection only in small sections of my annotations (see image below). Strangely this did not occur in other images in the project.

The error message in part of the log is:

ERROR: Error running plugin: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 79
    at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
    at qupath.lib.plugins.AbstractPluginRunner.awaitCompletion(AbstractPluginRunner.java:199)
    at qupath.lib.plugins.AbstractPluginRunner.runTasks(AbstractPluginRunner.java:158)
    at qupath.lib.gui.plugins.PluginRunnerFX.runTasks(PluginRunnerFX.java:95)
    at qupath.lib.plugins.AbstractPlugin.runPlugin(AbstractPlugin.java:164)
    at qupath.lib.gui.scripting.QPEx.runPlugin(QPEx.java:307)
    at qupath.lib.gui.scripting.QPEx.runPlugin(QPEx.java:327)
    at qupath.lib.gui.scripting.QPEx$runPlugin.callStatic(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:196)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:216)
    at Script2.run(Script2.groovy:2)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:798)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:732)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:712)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1128)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
  Caused by Index -1 out of bounds for length 79        at ij.process.FloatProcessor.getf(FloatProcessor.java:316)
        at qupath.imagej.processing.MorphologicalReconstruction.dilateAndCompare(MorphologicalReconstruction.java:117)
        at qupath.imagej.processing.MorphologicalReconstruction.morphologicalReconstruction(MorphologicalReconstruction.java:292)
        at qupath.imagej.processing.MorphologicalReconstruction.findRegionalMaxima(MorphologicalReconstruction.java:639)
        at qupath.imagej.detect.cells.WatershedCellDetection$WatershedCellDetector.doDetection(WatershedCellDetection.java:662)
        at qupath.imagej.detect.cells.WatershedCellDetection$WatershedCellDetector.runDetection(WatershedCellDetection.java:1063)
        at qupath.imagej.detect.cells.WatershedCellDetection$CellDetector.runDetection(WatershedCellDetection.java:303)
        at qupath.lib.plugins.DetectionPluginTools$DetectionRunnable.run(DetectionPluginTools.java:112)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

A search of ArrayIndexOutOfBoundsException did not return any relevant posts here. Any ideas what is causing this?

Best wishes,
Yau

Which version are you using? What is the image file type?

QuPath M8 and it’s an .ndpi image.

Thanks, under the ‘Image’ tab can you check the server type and see if it is using OpenSlide or Bio-Formats to read the image?

I see an ArrayIndexOutOfBoundsException was reported with ndpi and Bio-Formats some time ago, but I don’t know if it’s relevant. If so, then you’d probably also see the error (at least in the log) when you zoom in to part of the image (presumably part close to a region that wasn’t analyzed, but should have been).

If it’s opened with OpenSlide, then there is an issue with some very large .ndpi files.

It may be something else entirely, but I haven’t seen it before. If you find a way that I could replicate it please do let me know.

It is opened with OpenSlide.

It isn’t very large at 622 MB and 19.7 GB uncompressed. Another much larger image could be opened (also with OpenSlide) and Cell Detection ran perfectly fine on it.

I have no idea how this error can be replicated on another image. This only happened on 1 of 18 slides.

Have you tried forcing it to open with BioFormats then (during import, or using the Preferences)? That seems like the next step.

1 Like

It works when I open the image with BioFormats! Thanks @petebankhead and @Research_Associate :slight_smile:

1 Like

I was about to set my QuPath to always use BioFormats until I came across this:

A example of a time when these final two options can matter: OpenSlide can generally read .ndpi images much faster than Bio-Formats.

Is the performance hit still present since that was written?