Exporting measurements in QuPath 0.2.0 with a script

I am having troubles exporting my measurments after I run a cell detection with a script.
This is my script:

runPlugin('qupath.imagej.detect.tissue.SimpleTissueDetection2', '{"threshold": 255,  "requestedPixelSizeMicrons": 20.0,  "minAreaMicrons": 10000.0,  "maxHoleAreaMicrons": 1.0E10,  "darkBackground": false,  "smoothImage": false,  "medianCleanup": false,  "dilateBoundaries": false,  "smoothCoordinates": false,  "excludeOnBoundary": false,  "singleAnnotation": true}');
setColorDeconvolutionStains('{"Name" : "H-DAB stain_sep_batch_job", "Stain 1" : "Hematoxylin", "Values 1" : "0.631 0.664 0.401 ", "Stain 2" : "DAB", "Values 2" : "0.36 0.5925 0.7137 ", "Background" : " 234 226 223 "}');
runPlugin('qupath.imagej.detect.nuclei.WatershedCellDetection', '{"detectionImageBrightfield": "Hematoxylin OD",  "requestedPixelSizeMicrons": 0.5,  "backgroundRadiusMicrons": 0.0,  "medianRadiusMicrons": 0.0,  "sigmaMicrons": 1.5,  "minAreaMicrons": 10.0,  "maxAreaMicrons": 300.0,  "threshold": 0.04,  "maxBackground": 2.0,  "watershedPostProcess": true,  "excludeDAB": false,  "cellExpansionMicrons": 0.0,  "includeNuclei": true,  "smoothBoundaries": true,  "makeMeasurements": true}');
saveDetectionMeasurements('/media/Seagate Expansion Dr/Image_files/results/', 'Centroid X µm', 'Centroid Y µm')

The file gets created, and the newlines are inserted, but otherewise the file is completely empty. I also tried implementing pete’s script (https://gist.github.com/petebankhead/a473b817eac36caabdffc21daf93231d) but it didnt work.
If I export it manually it works fine.

Has anyone else experienced this problem?

It looks like the script was generated with v0.1.2.

Oops, posted that a bit early…
The cell segmentation has changed slightly, and older scripts won’t work directly to reduce the chances of accidentally switching between versions.

You can change
to get things working… but be warned the results of the cell segmentation will not be identical across versions (although in this case they are probably very similar).

I will try this!
I also tried my script (posted above) in QuPath 0.1.2 and it worked.

I implemented the change and now it doesn’t detect anything and is done in less than a second

If you don’t see any error messages, try View → Show log for error messages.

Note that you need ‘nuclei’ for v0.1.2 and ‘cells’ for v0.2.0-m2. It works for me…

ERROR: Error running plugin qupath.imagej.detect.cells.WatershedCellDetection
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at qupath.lib.gui.scripting.QPEx.runPlugin(QPEx.java:244)
at qupath.lib.gui.scripting.QPEx.runPlugin(QPEx.java:276)
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 Script4.run(Script4.groovy:6)
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:770)
at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:700)
at qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:680)
at qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1037)
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)

This is the error I get…

Are you using the first or second milestone release (v0.2.0-m1 or v0.2.0-m2)? I’ve checked it only with the second.

That’s the error you’d see if the classname is wrong (but it looks correct in your error for m2).

An additional space would also cause the error, e.g.
'qupath.imagej.detect.cells.WatershedCellDetection '

Ill just reinstall it and try again

If you can run cell detection through the GUI of the version causing you trouble, then it should log the appropriate script line that you need in the workflow (which is I guess how you created the script in v0.1.2 already).