Script of the Day: Count annotations in a project
For every image in a project, count the total number of objects, the total number of annotations, & the number of annotations split by classification - quickly.
This Script of the Day looks at projects - specifically, how to peek into the data files associated with every image in a project to quickly check what they contain.
Problem
When annotating images in a project, it can be helpful to know which images were annotated - and with which classifications.
Usually this involves opening each image individually and checking.
But that is slow, especially if the files are large and/or many.
Solution
The script below checks all the images in the project in one go.
Along the way, it demonstrates a few of useful tricks for the QuPath script-er:
- How to loop through the entries in a project
- How to programmatically find the data file for each entry in the project
- How to read objects from a .qpdata file quickly
It also introduces a nice Groovy
countBy
method… which is new to me.