Extracting co-ordinates doesn't work in newer QuPath versions

Hey everyone,

I’ve been using the below code to cycle through the polygons in my image and export the co-ordinates as a .txt file. However, with the latest Qupath I can’t get it to work, I get the following error:

ERROR: Error at line 16: No signature of method: qupath.lib.roi.PolygonROI.getPolygonPoints() is applicable for argument types: () values: []

I’m not really sure how to proceed.

Any help would be greatly appreciated!

Many thanks!

// Create an empty text file
def path = buildFilePath(PROJECT_BASE_DIR, 'polygons.txt')
def file = new File(path)
file.text = ''

// Loop through all objects & write the points to the file
for (pathObject in getAllObjects()) {
    // Check for interrupt (Run -> Kill running script)
    if (Thread.interrupted())
        break
    // Get the ROI
    def roi = pathObject.getROI()
    if (roi == null)
        continue
    // Write the points; but beware areas, and also ellipses!
    file << roi.getPolygonPoints() << System.lineSeparator()
}
print 'Done!'

You can use getAllPoints() instead, but I’d strongly recommend exploring other forms of export - since a list of points is not always enough to represent a ROI. See https://qupath.readthedocs.io/en/latest/docs/advanced/exporting_annotations.html for more details and available methods.

1 Like

Thank you so so much!

1 Like