Count annotations script not working


I am new to QuPath and I am hoping to batch process some whole side images that I have annotated manually with different features.
I was hoping to use the count annotations in project script on Pete’s very helpful blog:

I have changed the import on line 15 from
import qupath.lib.scripting.QPEx to import qupath.lib.gui.scripting.QPEx suggested by another user’s question but I seem to get a script error that I can’t figure out at line 35 -
No signature of method: static qupath.lib.gui.QuPathGUI.getImageDataFile() is applicable for argument types: (qupath.lib.projects.DefaultProject, qupath.lib.projects.DefaultProject$DefaultProjectImageEntry) values: (project, entry)

I am using QuPath version 0.2.0-m2, the images are .czi

Any advice would be greatly appreciated.

I’m afraid more changes are needed to that script. In general v0.1.2 won’t necessarily work with v0.2.0-m2 (or the next milestone as the software is further developed/stabilized).

However, in this case the change looks pretty small. Try replacing the line where the hierarchy is read to

// Read the hierarchy, but *not* anything else (don't need a full ImageData)
def hierarchy = entry.readHierarchy()

Then you can delete the lines above relating to ‘fileData’ - everything up to (but not including)

sb << entry.getImageName() << System.lineSeparator()`

The idea underlying the change is that projects need to become more flexible to support new features… and relying on a local file containing all the hierarchy stuff is too restrictive.

Thanks so much for your prompt reply - this worked great!