Search bug in Script "Cut Annotation ROI into many sparated ROI"

I use the following script from Pete and Svidro to cut a multipatch-ROI of one class, consisting of many patches that are combined into one ROI, to cut it into separated ROIs.

The script runs in QuPath v0.1.2 without complain, but allways misses some ROIs that will appear as rectangle without area in the upper left corner of the image, having an area of “0”.

Does anybody have an idea, why that happens?
Thank you for any ideas.

import qupath.lib.roi.*
import qupath.lib.objects.*
selectObjects {
    return it.isAnnotation() && it.getPathClass() == getPathClass('ZNS')
}

def areaAnnotations = getSelectedObjects().findAll {it.getROI() instanceof AreaROI}
areaAnnotations.each { selected ->
    def polygons = PathROIToolsAwt.splitAreaToPolygons(selected.getROI())
    def newPolygons = polygons[1].collect {
        updated = it
        for (hole in polygons[0])
            updated = PathROIToolsAwt.combineROIs(updated, hole, PathROIToolsAwt.CombineOp.SUBTRACT)
    return updated
    }

// Remove original annotation, add new ones
annotations = newPolygons.collect {new PathAnnotationObject(it)}
    resetSelection()
    removeObject(selected, true)
    addObjects(annotations)
}

I would guess this is it.

If it doesn’t have an area, it isn’t considered. I would look into why you have annotations that don’t have areas, or remove annotations that don’t have areas ahead of time.

I have only one large merged annotation that will be cut. Isn´t all parte then automatically an AreaAWT?
Most skipped ROIs are rather large areas.

You first stated that the script is missing ROIs during the run, and later said that you only have one ROI. Please clarify.

sorry, if my description is misleading.
I start with a huge merged ROI of one class. It is spreaded across the image and i want to cut it into spearated ROIs. Running the script will cut the large ROI into separated ones.

The large ROI is created by subtraction of two other annotations before. The subtraction will cut the backround into separated areas. Then I want to separate the areas by the listed script.

The script seems to work correctly on the annotations I just tested. If you are observing any odd behavior, it likely has to do with the annotations that exist prior to running the script.

I do not think I can help with the problem without seeing the input or playing with the file. I can’t reproduce any 0 area annotations in a corner with sample images.

ok,
this is the script that is used to subtract in the step before:

In 30 min i could also send exported annotations with the problem.

//set class name that shall be substracted: 
substractorROI = 'AnnotationThatIsSubstracted'
nameOfROIthatIsReduced = 'AnnotationThatIsReducedBySubtractor'

import qupath.lib.roi.*
import qupath.lib.objects.*
  
def imageData = getCurrentImageData()
def hierarchy = imageData.getHierarchy()
selectAnnotations()
def classToSubstract=getAnnotationObjects().find{p -> (p.getPathClass()==getPathClass(nameOfROIthatIsReduced) && (p.isAnnotation() == true))}
def classToBeSubstracted=getAnnotationObjects().find{p -> (p.getPathClass()==getPathClass(substractorROI) && (p.isAnnotation() == true))}

//selectObjects {it.getPathClass() == getPathClass('Membrane') && it.getROI()};
//classToSubstract = getSelectedObjects() && getPathClass('Membrane')
print(classToSubstract)
print(classToBeSubstracted)
getCurrentHierarchy().getSelectionModel().setSelectedObject(classToBeSubstracted)

newAnnotation =  PathROIToolsAwt.combineROIs(classToSubstract.getROI(), classToBeSubstracted.getROI(), PathROIToolsAwt.CombineOp.SUBTRACT)
def newAnnotation = new PathAnnotationObject(newAnnotation, classToSubstract.getPathClass())
//newAnnotation.setName("newZNS")
def toAdd = []
def toRemove = []
toAdd << newAnnotation
toRemove << classToSubstract
hierarchy.addPathObjects(toAdd,false)
hierarchy.removeObjects(toRemove,true)

print("Done")

it.getROI() instanceof AreaROI doesn’t look right to me… maybe it should be it.getROI() instanceof PathArea…?

In v0.1.2 AreaROI was a specific type of ROI, whereas PathArea was an interface that multiple ROIs implement (including AreaROI, PolygonROI, RectangleROIandEllipseROI`) to indicate that the ROI encloses an area (in contrast to a line or a point). This has all been rather simplified in v0.2.0…

Anyhow, I have vague recollections of a bug where ‘empty’ ROIs would still be added sometimes in v0.1.2 and then end up in the top left corner. This could happen, for example, if you compute the intersection of two non-overlapping regions.

Testing for ‘emptiness’ before deciding to add the annotation might help, i.e.

if (!newAnnotation.getROI().isEmpty())
   toAdd << newAnnotation
1 Like

Sounds right! And resulting from the previous step, mostly :slight_smile:

I ran the script without the “isinstanceof AreaROI”.
The problem keeps the same.

import qupath.lib.roi.*
import qupath.lib.objects.*
selectObjects {
    return it.isAnnotation() && it.getPathClass() == getPathClass('ZNS')
}


def areaAnnotations = getSelectedObjects().findAll {it.getROI() }
areaAnnotations.each { selected ->
    def polygons = PathROIToolsAwt.splitAreaToPolygons(selected.getROI())
    def newPolygons = polygons[1].collect {
        updated = it
        for (hole in polygons[0])
            updated = PathROIToolsAwt.combineROIs(updated, hole, PathROIToolsAwt.CombineOp.SUBTRACT)
    return updated
    }

// Remove original annotation, add new ones
annotations = newPolygons.collect {new PathAnnotationObject(it)}
    resetSelection()
    removeObject(selected, true)
    addObjects(annotations)
}

yes probably from the previous steps. Would be nice to get to know the critical step.
Maybe something with the hierarchy.
The subtracting annotation is descendent of a parent on. But it will subtract not the parent but another annotations.
Maybe a fire hierarchy update helps

Pete’s recommendation should have covered it here:

Which, to be specific, is in the script you linked above his response. Not the splitting script.

I included

if (!newAnnotation.getROI().isEmpty())
   toAdd << newAnnotation

in the subtract script without effect.

Hmm, odd. Maybe .getROI().getArea() > 0 instead? Or run one of the other script that removes objects below a certain area. That is built into the splitting script here:
https://gist.github.com/Svidro/33558ac3bd9f68a5ec2428f74550831f#file-removing-small-annotation-bits-groovy

ok, sounds for some hope. Thank you. I gonna try next week.
have a good weekend.

1 Like

Still no progress.
I tried several different things to look if the problem disappears.

  1. Use another script to convert a positive pixel count into the ROI that can not be splitted later on.

Using

/*
* Convert annotation objects to detections.
* Warning! This may be very slow, and a bad idea!
* It is intended to show the different behavior between 
* detection & annotation objects.
*/

import qupath.lib.objects.PathAnnotationObject

// Create new annotations with the same ROIs and classifications as the detections
def detections = getDetectionObjects()
def newAnnotations = detections.collect {detection -> new PathAnnotationObject(detection.getROI(), detection.getPathClass())}

// Remove the detections, add the annotations
removeObjects(detections, false)
addObjects(newAnnotations)

But still the same Problem.

Then I had the idea that the positive pixel count may generate pixels /ROIs that are shifted compared to the “real” pixels:

Shift of PositivePixel_Vs_RealPixelPositions

I eliminated the overlapping part by the “intersect” function. But still the same. Empty rectangles are generated and large parts of the original ROI disappear.

Here is a before image of the ROI:

Here an afterwardas image of the ROI:
lost ROIs after Separation Script

ROI parts that are lost are not small at all. It seems to be independent of the ROI size.

I looked again at the original script, and some of the indentation is confusing. This is a slightly clearer version:

import qupath.lib.roi.*
import qupath.lib.objects.*
selectObjects {
    return it.isAnnotation() && it.getPathClass() == getPathClass('ZNS')
}

def areaAnnotations = getSelectedObjects().findAll {it.getROI() instanceof AreaROI}
areaAnnotations.each { selected ->
    def polygons = PathROIToolsAwt.splitAreaToPolygons(selected.getROI())
    def newPolygons = polygons[1].collect {
        updated = it
        for (hole in polygons[0])
            updated = PathROIToolsAwt.combineROIs(updated, hole, PathROIToolsAwt.CombineOp.SUBTRACT)
        return updated
    }

    // Remove original annotation, add new ones
    annotations = newPolygons.collect {new PathAnnotationObject(it)}
    resetSelection()
    removeObject(selected, true)
    addObjects(annotations)
}

From that I can see that objects are added/removed within the each closure, which becomes rather hard to follow. And the use of selections makes it even more difficult.

Here’s a version of the script that uses loops a bit more and aims to be a bit easier to trace. I don’t know if it will resolve the issues you’ve seen, but it may be worth a try.

import qupath.lib.roi.*
import qupath.lib.objects.*

def areaAnnotations = getAnnotationObjects().findAll {it.getPathClass() == getPathClass('ZNS') &&
    it.getROI() instanceof AreaROI}
    
def annotations = []

for (selected in areaAnnotations) {
print selected
    def polygons = PathROIToolsAwt.splitAreaToPolygons(selected.getROI())
    def newROIs = polygons[1].collect {
        updated = it
        for (hole in polygons[0])
            updated = PathROIToolsAwt.combineROIs(updated, hole, PathROIToolsAwt.CombineOp.SUBTRACT)
        return updated
    }

    // Remove original annotation, add new ones
    for (tempROI in newROIs) {
        if (!tempROI.isEmpty())
            annotations << new PathAnnotationObject(tempROI)
    }
}

removeObjects(areaAnnotations, true)
addObjects(annotations)

Hi Pete,

thank you for the 2 scripts.
Both did not bring any change.
I assume that the problem might arise before in the conversion of the positive pixelcount into Annotation-ROIs.

I tried with two scripts. Both do not show the same behavior.

selectObjects {
    return it.getPathClass() == getPathClass('Positive')
}

/* Author: Micros in QuPath Forum
 * A script to create annotation object(s) having the same ROI as any
 * (other) currently selected object(s).
 */


import qupath.lib.objects.PathAnnotationObject
import qupath.lib.roi.RectangleROI
import qupath.lib.scripting.QP

// Set this to true to use the bounding box of the ROI, rather than the ROI itself
boolean useBoundingBox = false

// Get the current hierarchy
def hierarchy = QP.getCurrentHierarchy()

// Get the select objects
def selected = hierarchy.getSelectionModel().getSelectedObjects()

// Check we have anything to work with
if (selected.isEmpty()) {
    print("No objects selected!")
    return
}

// Loop through objects
def newAnnotations = new ArrayList<>()
for (def pathObject in selected) {

    // Unlikely to happen... but skip any objects not having a ROI
    if (!pathObject.hasROI()) {
        print("Skipping object without ROI: " + pathObject)
        continue
    }

    // Don't create a second annotation, unless we want a bounding box
    if (!useBoundingBox && pathObject.isAnnotation()) {
        print("Skipping annotation: " + pathObject)
        continue
    }

    // Create an annotation for whichever object is selected, with the same class
    // Note: because ROIs are (or should be) immutable, the same ROI is used here, rather than a duplicate
    def roi = pathObject.getROI()
    if (useBoundingBox)
        roi = new RectangleROI(
                roi.getBoundsX(),
                roi.getBoundsY(),
                roi.getBoundsWidth(),
                roi.getBoundsHeight(),
                roi.getC(),
                roi.getZ(),
                roi.getT())
    def annotation = new PathAnnotationObject(roi, pathObject.getPathClass())
    newAnnotations.add(annotation)
    print("Adding " + annotation)
}

// Actually add the objects
hierarchy.addPathObjects(newAnnotations, false)
if (newAnnotations.size() > 1)
    print("Added " + newAnnotations.size() + " annotation(s)")

and

/*
* Convert annotation objects to detections.
* Warning! This may be very slow, and a bad idea!
* It is intended to show the different behavior between 
* detection & annotation objects.
*/

import qupath.lib.objects.PathAnnotationObject

// Create new annotations with the same ROIs and classifications as the detections
def detections = getDetectionObjects()
def newAnnotations = detections.collect {detection -> new PathAnnotationObject(detection.getROI(), detection.getPathClass())}

// Remove the detections, add the annotations
removeObjects(detections, false)
addObjects(newAnnotations)

surprisingly also a simple operation like subtract annotations does not work with the resulting Annotation ROI from the Positive Pixel-Count.

this is the ouput of the script editor window on the bottom:
the problematic ROIs are added as rectangle with not area - even if they are very large.
Can this be connected with the bioformats-extension and bioformats_packeges.jar?
I dont use them, because it will lead to a wrong image in the viewer with a pink layer infront of the real image.

INFO: Starting script at Sun Dec 15 15:02:19 CET 2019
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Rectangle to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Adding Area (AWT) to hierarchy
INFO: Adding Polygon to hierarchy
INFO: Result: [Area (Positive)]

The first script in my last post should be identical to the one you first posted in this thread. The way it is written looks potentially error-prone to me (with closures inside closures that have side-effects, in addition to misleading indentation) which is why I edited slightly for readability, but it does the same thing - and so will have the same problems.

The second script is slightly different, and aims to do the same as what I think the first script is intended to do, in a simpler way. But I wrote it quickly without proper testing as in general I don’t entirely understand the purpose or problems and don’t have any easy way to replicate the issues you describe. I am afraid I would really need step-by-step guide to generate the problem from opening a common image to help further.

Recent v0.2.0 milestone releases have a specific ‘split annotations’ command but v0.1.2 does this very differently. Therefore my understanding is that any problems should already be resolved in v0.2.0-m8 (and possibly a bit sooner), but I understand you may not be able to move to this as the split annotations would not be backwards compatible with v0.1.2.

The BioFormats extension shouldn’t affect this.

1 Like