TopologyException: found non-noded intersection between LINESTRING

Hi all,
could maybe someone explain me the following error message, which I get from a script to calculate differences/intersections of given annotations:

ERROR: TopologyException at line 128: found non-noded intersection between LINESTRING ( 24357.0 13689.0, 24321.334462364495 13653.334462364497 ) and LINESTRING ( 24317.0 13649.0, 24321.334462364495 13653.334462364497 ) [ (24321.334462364495, 13653.334462364497, NaN) ]

ERROR: org.locationtech.jts.noding.FastNodingValidator.checkValid(FastNodingValidator.java:140)
    org.locationtech.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:81)
    org.locationtech.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:46)
    org.locationtech.jts.operation.overlay.OverlayOp.computeOverlay(OverlayOp.java:231)
    org.locationtech.jts.operation.overlay.OverlayOp.getResultGeometry(OverlayOp.java:183)
    org.locationtech.jts.operation.overlay.OverlayOp.overlayOp(OverlayOp.java:86)
    org.locationtech.jts.operation.overlay.snap.SnapIfNeededOverlayOp.getResultGeometry(SnapIfNeededOverlayOp.java:75)
    org.locationtech.jts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(SnapIfNeededOverlayOp.java:37)
    org.locationtech.jts.geom.Geometry.difference(Geometry.java:1416)
    org.locationtech.jts.geom.Geometry$difference.call(Unknown Source)
    org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
    Script1.run(Script1.groovy:129)
    org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317)
    org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155)
    qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:926)
    qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:859)
    qupath.lib.gui.scripting.DefaultScriptEditor.executeScript(DefaultScriptEditor.java:782)
    qupath.lib.gui.scripting.DefaultScriptEditor$2.run(DefaultScriptEditor.java:1271)
    java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    java.base/java.lang.Thread.run(Unknown Source)

It seems to be caused by this line of code:

Geometry tumorMarginGeometry2= tumorMarginGeometry.difference(tissueGeometry)

Actually the script generally works for most of the files with ROIs I tested, but reproducibly fails on some ROIs, however I do not see an obvious reason why the operation should not work.

Cheers,
Peter

Related.

I was able to minimize it here, but dealing with this will likely depend on how you are doing what you are doing.

@Peter.Zentis if you google the message in the title, or search for it in GitHub, you will find quite a lot of references to it across different software applications – in the end, it comes from Java Topology Suite, which is extremely widely used.

See here for an explanation: https://locationtech.github.io/jts/jts-faq.html#D1

QuPath became increasingly strict in how it would create JTS geometries throughout the milestone releases, and so I hope this should not occur often (ideally not at all…) with annotations created and manipulated in v0.2.0 – but since the issue is quite Geometry-specific, this is hard to predict.

It may be more frequent with annotations created in earlier versions, even if these are then manipulated in v0.2.0.

I cannot suggest a workaround in this case without knowing more about exactly what version you are using, the contents of the script, and how the problematic annotations appear. But perhaps the information above can help better understand (and possibly avoid) the problem.

Using 0.2.0 (final version with Tensorflow) and get the same problem when attempting Stardist on large whole slide images (H-DAB). I’ve added some new configurations to the Stardist script, but did not have that problem previously. Will try to do a CPU-build with Tensorflow and also try old scripts to see if I still get the same problem.

Here is the log:
INFO: Detecting nuclei for 2088 tiles
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 4 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 4 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 18 nucleus detection(s) due to error in resolving overlaps (0.1% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 10 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0.1% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 26 nucleus detection(s) due to error in resolving overlaps (0.1% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 6 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 7 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 5 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 3 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 13 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 4 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 5 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 4 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 4 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 1 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
WARN: Skipped 2 nucleus detection(s) due to error in resolving overlaps (0% of all skipped)
INFO: Resolving nucleus overlaps
WARN: Skipped 10 nucleus detection(s) due to error in resolving overlaps (0.8% of all skipped)
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
WARN: Geometries must all be of the same type when converting to a ROI! Converted GeometryCollection to Polygon.
ERROR: TopologyException: found non-noded intersection between LINESTRING ( 48775.28 43469.45, 48775.30078125 43469.44140625 ) and LINESTRING ( 48772.25 43461.30859375, 48775.29 43469.45 ) [ (48775.288662407525, 43469.446417801395, NaN) ]

ERROR: org.locationtech.jts.noding.FastNodingValidator.checkValid(FastNodingValidator.java:140)
org.locationtech.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:81)
org.locationtech.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:46)
org.locationtech.jts.operation.overlay.OverlayOp.computeOverlay(OverlayOp.java:231)
org.locationtech.jts.operation.overlay.OverlayOp.getResultGeometry(OverlayOp.java:183)
org.locationtech.jts.operation.overlay.OverlayOp.overlayOp(OverlayOp.java:86)
org.locationtech.jts.operation.overlay.snap.SnapIfNeededOverlayOp.getResultGeometry(SnapIfNeededOverlayOp.java:75)
org.locationtech.jts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(SnapIfNeededOverlayOp.java:37)
org.locationtech.jts.geom.Geometry.union(Geometry.java:1388)
qupath.lib.objects.CellTools.estimateCellBoundary(CellTools.java:154)
qupath.lib.objects.CellTools.estimateCellBoundary(CellTools.java:137)
qupath.tensorflow.stardist.StarDist2D.convertToObject(StarDist2D.java:691)
qupath.tensorflow.stardist.StarDist2D.lambda$detectObjects$6(StarDist2D.java:631)
java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source)
java.base/java.util.stream.ReduceOps$ReduceTask.doLeaf(Unknown Source)
java.base/java.util.stream.AbstractTask.compute(Unknown Source)
java.base/java.util.concurrent.CountedCompleter.exec(Unknown Source)
java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

ERROR: TopologyException: found non-noded intersection between LINESTRING"

What do you mean?
Does it run to completion (despite the error), or stop at that point?

I don’t think it will be possible to avoid the errors entirely, and with the geometry-based method of cell estimation used here there are a lot of geometry operations being performed. All this is kind of independent of StarDist, since it is a post-processing step, so switching to CPU probably won’t solve it.

However, if the error causes the entire detection to fail then I can try to figure out how to get a single failure not to cause everything to fail.

1 Like

Runs, then stops - does not complete. Ran another scripts now with less settings (no simplify shapes, etc.) and that worked (except for two skipped tiles).

This script worked:

import qupath.tensorflow.stardist.StarDist2D

// Specify the model directory (you will need to change this!)
def pathModel = '/QuPath/he_heavy_augment'

def stardist = StarDist2D.builder(pathModel)
        .threshold(0.1)              // Prediction threshold
        .normalizePercentiles(1, 99) // Percentile normalization
        .pixelSize(0.45)              // Resolution for detection
        .cellExpansion(2)          // Approximate cells based upon nucleus expansion
        .measureShape()              // Add shape measurements
        .measureIntensity()          // Add cell measurements (in all compartments)
        .includeProbability(true)    // Include prediction probability as measurement
        .build()

// Run detection for the selected objects
def imageData = getCurrentImageData()
def pathObjects = getSelectedObjects()
if (!pathObjects) {
    Dialogs.showErrorMessage("StarDist", "Please select a parent object!")
    return
}
stardist.detectObjects(imageData, pathObjects)
println 'Done!'


This script often generates “ERROR: TopologyException” on large images and no resulting cell detections:

import qupath.tensorflow.stardist.StarDist2D

// Specify the model directory (you will need to change this!)
def pathModel = '/QuPath/he_heavy_augment'

def stardist = StarDist2D.builder(pathModel)
        .threshold(0.1)              // Prediction threshold
        .normalizePercentiles(1, 99) // Percentile normalization
        .pixelSize(0.45)              // Resolution for detection
        .cellExpansion(2)          // Approximate cells based upon nucleus expansion
        .measureShape()              // Add shape measurements
        .measureIntensity()          // Add cell measurements (in all compartments)
        .includeProbability(true)    // Include prediction probability as measurement
        .tileSize(1024)              // Specify width & height of the tile used for prediction
        .cellConstrainScale(1.6)     // Constrain cell expansion using nucleus size
        .ignoreCellOverlaps(false)   // Set to true if you don't care if cells expand into one another
        .simplify(1)                 // Control how polygons are 'simplified' to remove unnecessary vertices
        .doLog()                     // Use this to log a bit more information while running the script
        .build()

// Run detection for the selected objects
def imageData = getCurrentImageData()
def pathObjects = getSelectedObjects()
if (!pathObjects) {
    Dialogs.showErrorMessage("StarDist", "Please select a parent object!")
    return
}
stardist.detectObjects(imageData, pathObjects)
println 'Done!'


1 Like

It would help to format the scripts using the preformatted text option so that they can be read and copied more easily.
image

1 Like

So, we meet again, Java Topology Suite…

I’m aware there are many reports of JTS, but I wanted to mention that I am encountering this exception, outside of scripting or StarDist, when attempting to merge a particularly demanding annotation with another (both drawn using the brush tool).

Objects > Annotations… > Simplify shape does allow me to eventually merge succesfully.

This occurs in 0.2.3 and 0.3.0-dev.

Edit: Pixel snapping was enabled, is this still of relevance here?

Thanks.

Can you provide the exact annotations (if not the image file as well) that are causing the problem?
https://qupath.readthedocs.io/en/latest/docs/advanced/exporting_annotations.html#geojson

There are a few more examples of scripts with file outputs here and other places on the forum.

This won’t be helpful for work outside of scripting, but I have found that using PrecisionReducer helps with this error a lot. I assume this is doing something similar to the Simplify Shape command. Here’s how to get geometries with a very slightly lowered precision that doesn’t trigger that error:

import org.locationtech.jts.precision.GeometryPrecisionReducer
import org.locationtech.jts.geom.PrecisionModel

PrecisionModel PM = new PrecisionModel(PrecisionModel.FIXED)
def geos = getAnnotationObjects().collect{GeometryPrecisionReducer.reduce(it.getROI().getGeometry(), PM)}
//merging, subtraction, etc
2 Likes

@camlloyd and @smcardle how often do these errors still occur? I haven’t seen one for a very long time.

I’ve spend many many hours fighting with these subtle precision errors to get things into a somewhat robust (as far as I know) state, and for any lingering issues it’s not clear to me if it’s simply a bug/limitation in JTS.

Unless they happen frequently and there is a reproducible way to create them / they are associated with one or two specific QuPath commands, I tend towards not doing anything for fear of breaking something more common… meanwhile, shape simplification and precision reduction are good workarounds.

1 Like

Not very often, and almost never when I’m using QuPath’s built-in functions. They come up for me when I try to do fancy merging of hundreds of pixel-classifier defined detections. I wouldn’t worry much about it. Maybe it could be useful to test for that error during merging/subtraction commands and if it occurs, then ask the user if they want to Simplify Shapes first?

3 Likes

This does look helpful, thank you!

I have only run into this maybe twice in the last 50 or so samples, but those 2 samples were no less important than the others. I think Simplify shapes will be suitable for now.

Thanks!

Thanks as always for the quick response - I didn’t have the data on hand to share (and still don’t).

I’m aware replies can only be so helpful without this to try and reproduce. I will try to post when I can!

1 Like