How to export annotations with specific name

I have whole tissue annotations and rectangle ROIs under tht whole tissue annotation with specific names like ROI1,ROI2…etc

How can I selectively export the rectangle ROIs as tiff images from qupath in batch mode? I would like to exclude the whole slide export since I am planning no downsampling for the ROIs.

For M9, there is a section on exporting images here:
If your rectangle ROIs are always entirely inside a parent annotation, you could either start with the parent annotation and getChildObjects() along with .isAnnotation() (so as not to grab cells), or if I understand the project correctly, go with something more like:

annotations = getAnnotationObjects().findAll{it.getLevel() == 2}
print annotations

Level 1 would be the “top” annotation, or your whole tissue. If you have problems with the level, it may be that you have not inserted your ROIs into the hierarchy, and need a resolveHierarchy() line first.