Export annotations question

Hello,

Using QuPath-0.2.0-m10, we’re hoping to export our annotated regions into “labeled images” as demonstrated in https://qupath.readthedocs.io/en/latest/docs/advanced/exporting_annotations.html.

I copied the code into the script editor, with lines 7-8:

def pathOutput = buildFilePath('C:\Users\14257\Desktop\Mcc', 'export', name) mkdirs(pathOutput)
which produces error:

ERROR: MultipleCompilationErrorsException at line 7: startup failed:
Script1.groovy: 8: Missing ')' @ line 8, column 32.
   def pathOutput = buildFilePath('C:\Users\14257\Desktop\Mcc', 'export', name)
                                  ^

1 error


ERROR: Script error (MultipleCompilationErrorsException)
    at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
    at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:143)
    at org.apache.groovy.parser.antlr4.AstBuilder.collectSyntaxError(AstBuilder.java:4544)
    at org.apache.groovy.parser.antlr4.AstBuilder.createParsingFailedException(AstBuilder.java:4527)
    at org.apache.groovy.parser.antlr4.AstBuilder.convertException(AstBuilder.java:416)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildCST(AstBuilder.java:389)
    at org.apache.groovy.parser.antlr4.AstBuilder.buildAST(AstBuilder.java:424)
    at org.apache.groovy.parser.antlr4.Antlr4ParserPlugin.buildAST(Antlr4ParserPlugin.java:58)
    at org.codehaus.groovy.control.SourceUnit.convert(SourceUnit.java:244)
    at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$1(CompilationUnit.java:191)
    at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:880)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:650)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:627)
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389)
    at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332)
    at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163)
    at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:314)
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:257)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getScriptClass(GroovyScriptEngineImpl.java:336)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:153)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:893)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:827)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:754)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1223)
    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)

The error persists after several attempts.

I’m unfamiliar with scripting using QuPath and Groovy is also new to me. I’ve attempted to search the forum, youtube channel, and documentation. Your help is much appreciated!

Thank you,

Mike

Hi @Mike1, it looks like in your file path you’ll need to replace \ with either \\ or /.
This is a general Java/Groovy thing, not QuPath specific.

However, if you are using v0.2.0-m12 you can also copy a file/folder from Windows Explorer and paste it into the script editor - QuPath with automatically convert it to the path, and also handle the slashes for you.

3 Likes

Thank you very much for pointing out that syntax, I didn’t notice that difference. It worked!

1 Like