Change name existing annotation class

Hello everyone,

I have a pretty simple question that I can’t seem to find the answer to in the wiki pages. We have made annotations using two annotation classes: tumour and stroma. However, we found that the term ‘stroma’ does not really cut the annotations we are making within this class, so we would like to change this name to something that fits us better. Is there any way to do this?

The alternative would be to add a new class, but then we would have to manually change hundreds of annotation’s classes, which we would like to avoid…

Thanks in advance for your help!


Hi @Sineadjm,

An easy solution would be to use the following script and Run > Run for project to select all the images that you want it applied to:

// Written in QuPath 0.2.0-m11
def newClass = getPathClass("NewClass")   // Your new class here
def stroma = getPathClass("Stroma")

getAnnotationObjects().each { annotation ->
    if (annotation.getPathClass().equals(stroma))
//fireHierarchyUpdate() // If you want to update the count in the Annotation pane

print "Done!"

Does that answer your question?


This worked perfectly, thank you very much!!