Error importing PathROIToolsAwt

Hello all,

I want to use a groovy script in QuPath to apply it on annotated H&E images. When trying to import qupath.lib.roi.PathROIToolsAwt, I have the following error:

ERROR: Script error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:311)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:980)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:647)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:596)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:390)
at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:89)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:330)
at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:327)
at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:325)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:251)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:331)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:153)
at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:766)
at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:696)
at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:676)
at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1033)
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)

With a description “unable to resolve class qupath.lib.roi.PathROIToolsAwt”

Any help on how to solve it is appreciated.

The script was written using an earlier version of QuPath, and that particular class has been largely replaced by RoiTools as part of a move to simplify the scripting overall. If you are using v0.2.0-m5 you might simply be able to replace all references to PathROIToolsAwt with RoiTools but it’s quite possible other changes are needed.

I would suggest using the version of QuPath for which the script was written (probably v0.1.2). Otherwise if you want to use it with m5 and simply replacing the names doesn’t work I’d need to have the full script to be able to help any further.

1 Like

Keeping the m4, the change into RoiTools helped with having the script running.

I had to also do the following change:
import qupath.lib.scripting.QPEx -> import qupath.lib.gui.scripting.QPEx

Thank you.

1 Like

Somewhat unrelated (and most m4 projects should work in m5), here is a list of some of the benefits of switching to m5


and here are some of the coding changes when upgrading to M4

1 Like