GUI.openImage(aSubImgPath,true,true,false) returns error

In a script I want to run the GUI.openImage to open another image path, but error appears:

def GUI = QuPathGUI
def imagelist = server.getSubImageList()
//imagelist print as: [Series 0 (overview), Series 1 (20x_01), Series 2 (20x_02), Series 3 (20x_03), ...
int i_subimage = 3
def aSubImgName = imagelist.getAt(i_subimage)
def aSubImgPath = server.getSubImagePath(aSubImgName)
// aSubImgPath print as URL: file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#2
GUI.openImage(aSubImgPath,true,true,false)

ERROR: Error at line 117: No signature of method: static qupath.lib.gui.QuPathGUI.openImage() is applicable for argument types: (String, Boolean, Boolean, Boolean) values: [file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#0, …]
Possible solutions: openImage(java.lang.String, boolean, boolean, boolean), openImage(qupath.lib.gui.viewer.QuPathViewer, java.lang.String, boolean, boolean, boolean)

It seems that the 1st argument expect java.lang.String, but I send a String.
However, after I use
GUI.openImage(aSubImgPath.toString(),true,true,false)
the error is still the same.

So is there a possible command in script to open/load another NEW image path/URL at run time?

In general you should use Run → Run for Project from within the script editor, in which case opening the image and saving the resulting data is handled for you. There is no need to open it within the GUI.

The specific error you see is because you’re trying to call an instance method as a static method; if run from the script editor this might help get further

def GUI = getQuPath()

because it assigns the current QuPath instance to the GUI variable, rather than the QuPathGUI class. But you may still encounter issues connected to manipulating the GUI in the ‘wrong’ thread.

If you can describe in more detail what you want the end result to be and why then there might be a more effective way to achieve it.

(Note that If you are running the script from the command line without starting up QuPath, then the GUI effectively doesn’t exist and it doesn’t make sense to try to access it.)

I’m using script to batch convert slide files to tif tiles via windows command line in headless mode in the pattern like this:

QuPath -image imagepath -script scriptpath

This command will open the slide image, then script will load the image and save them as tif file tiles.
If the slide is whole scan image, this works well and output the whole image content to tif files.
If the slide has a image list,such as .vsi file usually has many subimages cropped from the overview, somehow this command only open a fixed image from the image list only, and export that one only.

To solve the problem, I have write code to get the image list length, each image filename, and each subimage URL path. Then I want to use for cycle to go through the entire list and do them one-by-one.

According to your suggestion, I have update the code for cycle:

def GUI = QuPathGUI // a class, not an instance, so cannot call openImage to do stuff
def myQuPath = getQuPath() // a instance. can open new image from list via openImage
println(GUI)
println(myQuPath)

for (int i_subimage = 0; i_subimage < n_subimages; i_subimage++){

    def aSubImgName = imagelist.getAt(i_subimage)
    println("aSubImgName =: " + aSubImgName)
    def aSubImgPath = server.getSubImagePath(aSubImgName)
    println("aSubImgPath = : " + aSubImgPath)

    // openImage(String pathNew, boolean prompt, boolean includeURLs, boolean rotate180)
    println("trying to open a aSubImgPath")
    // GUI.openImage(aSubImgPath.toString(),false,true,false) // not work
	myQuPath.openImage(aSubImgPath.toString(),false,true,false) // works for the 1st round, then error
    println("already opened a aSubImgPath, now sleep for 6s...")
    sleep(6000)
    
	
	// do things here...
	
	
	
}

To test it, I run in the QuPath script IDE, and found that the image switched from the default open image(6th) to the 1st image, but then it no longer switched anymore in the following cycle, but error comes, and it stucks with pop up message box.

Then I abort the script in the IDE by click “kill the running script”, however, it then goes into the next cycle and open the second image in the image list, then script stops and exit forever.

INFO: 0.2.0-m2
INFO: Version: 0.2.0-m2
Build time: 2019-03-15, 10:17
Latest commit tag: 'a3bfc7c'
INFO: server.getFile().getAbsolutePath(): D:\QMDownload\6\BatchII 24 h 6#_20190314.vsi
INFO: QP.getCurrentImageData().getServer().getPath(): file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#11
INFO: QP.getCurrentImageData().getServerPath(): file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#11
INFO: Note: .vsi image list detected. imagelist = server.getSubImageList(): [Series 0 (overview), Series 1 (20x_01), Series 2 (20x_02), Series 3 (20x_03), Series 4 (20x_04), Series 5 (20x_05), Series 6 (20x_06), Series 7 (20x_07), Series 8 (20x_08), Series 9 (20x_09), Series 10 (20x_10), Series 11 (20x_11), Series 12 (20x_12), Series 13 (20x_13)]
INFO: null
INFO: n_subimages = imagelist.size: 14
INFO: class qupath.lib.gui.QuPathGUI
INFO: qupath.lib.gui.QuPathGUI@47c0c80f
INFO: aSubImgName : Series 0 (overview)
INFO: aSubImgPath : file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#0
INFO: trying to open a aSubImgPath
WARN: Strange 'bits per sample' of 0
INFO: Returning server: Bio-Formats for file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#0
ERROR: QuPath exception
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
    at javafx.scene.Parent$3.onProposedChange(Parent.java:471)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108)
    at javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:279)
    at javafx.scene.control.skin.LabeledSkinBase.lambda$new$11(LabeledSkinBase.java:220)
    at com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
    at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:104)
    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:50)
    at javafx.beans.property.StringProperty.setValue(StringProperty.java:65)
    at javafx.scene.control.Labeled.setText(Labeled.java:147)
    at qupath.lib.gui.viewer.Scalebar.updateScalebar(Scalebar.java:171)
    at qupath.lib.gui.viewer.Scalebar.imageDataChanged(Scalebar.java:192)
    at qupath.lib.gui.viewer.QuPathViewer.fireImageDataChanged(QuPathViewer.java:1431)
    at qupath.lib.gui.viewer.QuPathViewer.setImageData(QuPathViewer.java:1392)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2460)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2369)
    at qupath.lib.gui.QuPathGUI$openImage$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:151)
    at Script2.run(Script2.groovy:123)
    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:767)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:697)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:677)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1034)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
ERROR: QuPath exception
    at com.sun.glass.ui.Application.checkEventThread(Application.java:441)
    at com.sun.glass.ui.Window.setTitle(Window.java:893)
    at com.sun.javafx.tk.quantum.WindowStage.setTitle(WindowStage.java:501)
    at javafx.stage.Stage$5.invalidated(Stage.java:736)
    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110)
    at javafx.beans.property.StringPropertyBase.access$000(StringPropertyBase.java:50)
    at javafx.beans.property.StringPropertyBase$Listener.invalidated(StringPropertyBase.java:231)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.binding.StringBinding.invalidate(StringBinding.java:169)
    at com.sun.javafx.binding.BindingHelperObserver.invalidated(BindingHelperObserver.java:52)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:106)
    at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113)
    at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
    at qupath.lib.gui.QuPathGUI.fireImageDataChangedEvent(QuPathGUI.java:4470)
    at qupath.lib.gui.QuPathGUI$MultiviewManager.imageDataChanged(QuPathGUI.java:5068)
    at qupath.lib.gui.viewer.QuPathViewer.fireImageDataChanged(QuPathViewer.java:1431)
    at qupath.lib.gui.viewer.QuPathViewer.setImageData(QuPathViewer.java:1392)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2460)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2369)
    at qupath.lib.gui.QuPathGUI$openImage$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:151)
    at Script2.run(Script2.groovy:123)
    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:767)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:697)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:677)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1034)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
INFO: Image data set to ImageData: Not set, BatchII 24 h 6#_20190314.vsi
ERROR: QuPath exception
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
    at javafx.scene.Parent$3.onProposedChange(Parent.java:471)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108)
    at javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:272)
    at javafx.scene.control.skin.LabeledSkinBase.lambda$new$11(LabeledSkinBase.java:220)
    at com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
    at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:104)
    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:50)
    at javafx.beans.property.StringProperty.setValue(StringProperty.java:65)
    at javafx.scene.control.Labeled.setText(Labeled.java:147)
    at qupath.lib.gui.viewer.QuPathViewerPlus.updateLocationString(QuPathViewerPlus.java:233)
    at qupath.lib.gui.viewer.QuPathViewerPlus.setDownsampleFactor(QuPathViewerPlus.java:273)
    at qupath.lib.gui.viewer.QuPathViewer.setDownsampleFactor(QuPathViewer.java:2034)
    at qupath.lib.gui.QuPathGUI.setInitialLocationAndMagnification(QuPathGUI.java:4086)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2461)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2369)
    at qupath.lib.gui.QuPathGUI$openImage$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:151)
    at Script2.run(Script2.groovy:123)
    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:767)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:697)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:677)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1034)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
INFO: already opened a aSubImgPath, now sleep for 6s...
INFO: aSubImgName : Series 1 (20x_01)
INFO: aSubImgPath : file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#1
INFO: trying to open a aSubImgPath
WARN: Strange 'bits per sample' of 0
INFO: Returning server: Bio-Formats for file:/D:/QMDownload/6/BatchII%2024%20h%206%23_20190314.vsi#1
ERROR: QuPath exception
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
    at javafx.scene.Parent$3.onProposedChange(Parent.java:471)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113)
    at com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108)
    at javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:279)
    at javafx.scene.control.skin.LabeledSkinBase.lambda$new$11(LabeledSkinBase.java:220)
    at com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
    at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:104)
    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
    at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:50)
    at javafx.beans.property.StringProperty.setValue(StringProperty.java:65)
    at javafx.scene.control.Labeled.setText(Labeled.java:147)
    at qupath.lib.gui.viewer.Scalebar.updateScalebar(Scalebar.java:171)
    at qupath.lib.gui.viewer.Scalebar.imageDataChanged(Scalebar.java:192)
    at qupath.lib.gui.viewer.QuPathViewer.fireImageDataChanged(QuPathViewer.java:1431)
    at qupath.lib.gui.viewer.QuPathViewer.setImageData(QuPathViewer.java:1392)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2460)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2369)
    at qupath.lib.gui.QuPathGUI$openImage$0.call(Unknown Source)
    at Script2.run(Script2.groovy:123)
    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:767)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:697)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:677)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1034)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
ERROR: QuPath exception
    at com.sun.glass.ui.Application.checkEventThread(Application.java:441)
    at com.sun.glass.ui.Window.setTitle(Window.java:893)
    at com.sun.javafx.tk.quantum.WindowStage.setTitle(WindowStage.java:501)
    at javafx.stage.Stage$5.invalidated(Stage.java:736)
    at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110)
    at javafx.beans.property.StringPropertyBase.access$000(StringPropertyBase.java:50)
    at javafx.beans.property.StringPropertyBase$Listener.invalidated(StringPropertyBase.java:231)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.binding.StringBinding.invalidate(StringBinding.java:169)
    at com.sun.javafx.binding.BindingHelperObserver.invalidated(BindingHelperObserver.java:52)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:136)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:106)
    at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:113)
    at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
    at qupath.lib.gui.QuPathGUI.fireImageDataChangedEvent(QuPathGUI.java:4470)
    at qupath.lib.gui.QuPathGUI$MultiviewManager.imageDataChanged(QuPathGUI.java:5068)
    at qupath.lib.gui.viewer.QuPathViewer.fireImageDataChanged(QuPathViewer.java:1431)
    at qupath.lib.gui.viewer.QuPathViewer.setImageData(QuPathViewer.java:1392)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2460)
    at qupath.lib.gui.QuPathGUI.openImage(QuPathGUI.java:2369)
    at qupath.lib.gui.QuPathGUI$openImage$0.call(Unknown Source)
    at Script2.run(Script2.groovy:123)
    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:767)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:697)
    at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:677)
    at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1034)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
INFO: Image data set to ImageData: Not set, BatchII 24 h 6#_20190314.vsi

%E6%97%A0%E6%A0%87%E9%A2%98

Somehow I have solved the problem by split the script to two parts, and run two rounds of QuPath scripts via command line:

The first round read the input slide file path and generate a text file with the list of paths of sub-images in a image list of that slide.

The second round read the text file and use each sub-image URL path as argument, and run a second srcipt to do the job.

It works very well, and support both single image type slide and image list type slide.

1 Like