Delete original annotation-border (but not area) after expanding the area by script

after working a lot of hours figuring this out I seek now help from the developer himself.
I wanted to write a script which does following: expand the area of the original annotation and delete the original annotation (but not the area of it!)
Right now the script does: expanding the annotation area with the expand plugin from workflow history (which is what i want), but its not able to delete the original border within the newly created one.
How do I do it?
I would be grateful for a hint or help!

You will want to store the original annotation using something like

stuff = getAnnotationObjects()
before you perform the expansion, and then remove “stuff” after the expansion. If you have a bunch of other annotations, this could get trickier as you will need a more complicated set of instructions to keep track of the annotation you want to remove.
A bit of scripting information here on removing objects in the “Removing things” section, but depending on your version, many bits of the code may have changed. It is always important to mention the version when asking for scripting information.

@Fledermaus12 Does this do what you need?

def annotation = getSelectedObject()
runPlugin('qupath.lib.plugins.objects.DilateAnnotationPlugin', '{"radiusMicrons": 100.0,  "lineCap": "Round",  "removeInterior": false,  "constrainToParent": true}');
removeObject(annotation, true)

It can be adapted to work on all current annotations like this:

def annotations = getAnnotationObjects()
runPlugin('qupath.lib.plugins.objects.DilateAnnotationPlugin', '{"radiusMicrons": 100.0,  "lineCap": "Round",  "removeInterior": false,  "constrainToParent": true}');
removeObjects(annotations, true)
1 Like

Hey guys!
Thank you so much for the help!
This is exactly what I wanted.
I checked it, it works perfectly.

1 Like