Define RIOs in script in QUPath

Hi

I am currently evaluating QUPath as a means to open large multi-pyramid .tifs and export specific regions to ImageJ. It looks like it is specifically designed for this kind of thing.

However, I need to specify the coordinates of ROIs in a list, preferably via a macro, then save and/or export each one. I tried drawing ROIs with the command recorder open to try and understand how to script ROI generation, however it did not seem to record the ROI commands (it recorded ‘runPlugin(…lIntensityFeaturesPlugin)’ and other commands, but not the command to draw an RIO).

How do I specify a specific ROI in a script??

Thanks

Hi,

I think you could use

roi = new RectangleROI(x , y , width, height)
pathObject = new PathAnnotationObject(roi)

// Add object to hierarchy
addObject(pathObject)

Nico

3 Likes

Thank you for the quick reply. I had to add the right imports but after that it worked like a charm…

import qupath.lib.roi.RectangleROI
import qupath.lib.objects.PathAnnotationObject

roi = new RectangleROI(x , y , width, height) 
pathObject = new PathAnnotationObject(roi) 

// Add object to hierarchy 
addObject(pathObject)

In case it helps, there is also automatic tissue detection, tiling, and classification of tiles, which can all be used together to create named tile files, fairly automatically. More on those functions here.
You can also call ImageJ(1) macros directly from the script on any tiles you create.

There are multiple scripts on my blog that could be helpful, including one to generate specific annotations:

(Accessing forum from my phone in the Scottish highlands so my answers will be somewhat lacking in detail…)

2 Likes