Manual TMA Dearrayer script

Hi,
Occasionally the TMA dearrayer doesn’t work on a pale slide and I have been using the manual script from the Google forum (#77) for this (which worked fine). I have recently switched to the m3 version for some positive pixel detection and see this script no longer seems to work.

I presume there is some minor change in the code that has affected things. Can someone suggest a fix?

Many thanks.

The error is:

ERROR: Error at line 11: No signature of method: qupath.lib.images.servers.bioformats.BioFormatsImageServer.getAveragedPixelSizeMicrons() is applicable for argument types: () values:

ERROR: Script error
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
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:119)
at Script1.run(Script1.groovy:12)
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: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)
ERROR: Error at line 11: No signature of method: qupath.lib.images.servers.bioformats.BioFormatsImageServer.getAveragedPixelSizeMicrons() is applicable for argument types: () values:

ERROR: Script error
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
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:119)
at Script3.run(Script3.groovy:12)
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: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)

From the error, it looks like you now need

server.getPixelCalibration().getAveragedPixelSizeMicrons()

or something similar around line 11. If that’s not enough to solve things, could you link to the exact script you’re using?

Thanks for the quick reply. I pretty much use the exact script from issue #77 on the Google forums.
Script as below (sorry about the format). I have added your line in around line 11 (begins double diameterPixels…) in what (to a non-computer person) looks like a few likely spots. But no success yet.

import qupath.lib.objects.TMACoreObject
import qupath.lib.objects.hierarchy.DefaultTMAGrid

// Enter the number of horizontal & vertical cores here
int numHorizontal = 6
int numVertical = 6
// Enter the core diameter, in millimetres
double diameterMM = 2

// Convert diameter to pixels
double diameterPixels = (1.2 * 1000) / getCurrentImageData().getServer().getAveragedPixelSizeMicrons()

// Get the current ROI
def roi = getSelectedROI()

// Create the cores
def cores =
double xSpacing = roi.getBoundsWidth() / numHorizontal
double ySpacing = roi.getBoundsHeight() / numVertical
for (int i = 0; i < numVertical; i++) {
for (int j = 0; j < numHorizontal; j++) {
double x = roi.getBoundsX() + xSpacing / 2 + xSpacing * j
double y = roi.getBoundsY() + ySpacing / 2 + ySpacing * i
cores << new TMACoreObject(x, y, diameterPixels, false)
}
}

// Create & set the grid
def tmaGrid = new DefaultTMAGrid(cores, numHorizontal)
getCurrentHierarchy().setTMAGrid(tmaGrid)
relabelTMAGrid(“1-6”,“A-F”, true)

Here’s an updated version:

import qupath.lib.objects.PathObjects
import qupath.lib.objects.hierarchy.DefaultTMAGrid

// Enter the number of horizontal & vertical cores here
int numHorizontal = 6
int numVertical = 6
// Enter the core diameter, in millimetres
double diameterMM = 2

// Convert diameter to pixels
double diameterPixels = (1.2 * 1000) / getCurrentImageData().getServer().getPixelCalibration().getAveragedPixelSizeMicrons()

// Get the current ROI
def roi = getSelectedROI()

// Create the cores
def cores = []
double xSpacing = roi.getBoundsWidth() / numHorizontal
double ySpacing = roi.getBoundsHeight() / numVertical
for (int i = 0; i < numVertical; i++) {
        for (int j = 0; j < numHorizontal; j++) {
        double x = roi.getBoundsX() + xSpacing / 2 + xSpacing * j
        double y = roi.getBoundsY() + ySpacing / 2 + ySpacing * i
        cores << PathObjects.createTMACoreObject(x, y, diameterPixels, false)
    }
}

// Create & set the grid
def tmaGrid = new DefaultTMAGrid(cores, numHorizontal)
getCurrentHierarchy().setTMAGrid(tmaGrid)
relabelTMAGrid("1-6","A-F", true)

PERFECT!

Thanks so much.

Adding the link to the original since it wasn’t included and this combines the references to the two scripts in one thread.

Also, this was not the Google forum, it is the issues page for the GitHub site!