Skip to content

Instantly share code, notes, and snippets.

@jurgenizer
Created March 4, 2022 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurgenizer/93816d828cb7c6605c439595fc13d3e3 to your computer and use it in GitHub Desktop.
Save jurgenizer/93816d828cb7c6605c439595fc13d3e3 to your computer and use it in GitHub Desktop.
A very simple script to add a name to each annotation in an image in QuPath. Each name is suffixed with an incrementing number.
/*
Probably based on something from here: https://forum.image.sc/tag/qupath
OR
something from here: https://gist.github.com/Svidro
Thank You!
*/
hierarchy = getCurrentHierarchy()
def imageName = getProjectEntry().getImageName()
int annotationNumber = 1
for (annotation in getAnnotationObjects()) {
hierarchy.getSelectionModel().clearSelection();
selectObjects{p -> p == annotation}
// name your annotation anything you like
def annotationName = 'TISSUE-'
// add the annotation's number as a suffix
annotation.setName(imageName + ' ' + annotationName + annotationNumber)
annotationNumber += 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment