I have this Script to create the heatmaps which are calculated by deep learning network. This script is in Qupath 0.2.0 but I need to run this for the Qupath 1.2.0. I am not familiar with Qupath scripting, Can you please help me to convert this script to the older version of Qupath?
import qupath.lib.roi.ROIs
import qupath.lib.objects.PathObjects
import qupath.lib.regions.ImagePlane
// Define data file, delimiter & tile size (in pixels)
def path = 'example.csv'
def delim = ';'
def tileWidth = 1024 // Should this be 512? Depends on export resolution
def tileHeight = 1024
// Get the current image data
def imageData = getCurrentImageData()
// Get the image name
def server = imageData.getServer()
def name = server.getMetadata().getName()
if (name.endsWith('.svs'))
name = name.substring(0, name.length()-4)
// Find the relevant lines containing the image name
def lines = new File(path).readLines()
def header = lines.remove(0).split(delim)
// Parse the tile location
def tiles = []
for (line in lines.findAll{it.contains(name)}) {
// Parse coordinates
def split = line.split(delim)
def coordsString = split[0].substring(split[0].lastIndexOf('_(')+2, split[0].lastIndexOf(').'))
def coords = coordsString.split(',')
def x = coords[0] as int
def y = coords[1] as int
// Create objects
def roi = ROIs.createRectangleROI(x, y, tileWidth, tileHeight, ImagePlane.getDefaultPlane())
def tile = PathObjects.createTileObject(roi)
def ml = tile.getMeasurementList()
for (int i = 1; i < header.size(); i++) {
ml.putMeasurement(header[i], split[i] as double)
}
ml.close()
tiles.add(tile)
}
// Remove any existing objects & add the tiles
clearAllObjects()
addObjects(tiles)
print 'Tiles added for ' + name + ':\t' + tiles.size()
// set extreme colors
def min = PathObjects.createDetectionObject(ROIs.createEmptyROI())
min.getMeasurementList().putMeasurement('cancer', 0)
min.getMeasurementList().putMeasurement('nonCancer', 0)
def max = PathObjects.createDetectionObject(ROIs.createEmptyROI())
max.getMeasurementList().putMeasurement('c'ancer, 1)
max.getMeasurementList().putMeasurement('nonCancer', 1)
addObjects([min, max])
fireHierarchyUpdate()
def toRemove = getDetectionObjects().findAll {it.getROI().isEmpty()}
removeObjects(toRemove, true)