StarDist in QuPath error message

Hi! I’ve successfully used StarDist in QuPath so far (thanks to @petebankhead for making it so easy to integrate!). However, for one image the script runs for a good 10min (it’s a large image) before failing and coming up with this error message. Anyone know what this might be about?

ERROR: TopologyException: found non-noded intersection between LINESTRING ( 22424.810546875 16717.849609375, 22425.259765625 16720.2109375 ) and LINESTRING ( 22425.279296875 16720.189453125, 22424.080078125 16721.390625 ) [ (22425.25945861494, 16720.209323694933, 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.intersection(Geometry.java:1335)
    qupath.lib.objects.CellTools.estimateCellBoundary(CellTools.java:152)
    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)

Hi @madzha, the problem is occurring whenever the detected nuclei are converted to cells. There is something awkward in the geometry that isn’t working.

It looks like the line numbers in your error don’t match with the current QuPath + StarDist code (e.g. the location of convertToObject). Can you check whether the problem persists whenever you are running the very latest code?

I remember making some changes that I hope would avoid such errors (or at leasts not fail completely because of a single cell); if you built the software some time ago you might be missing these.

1 Like

Hi Pete, thanks for the advice! Have updated the code, but unfortunately I’m still getting the same fail + error, only difference is the line numbers here:

qupath.tensorflow.stardist.StarDist2D.convertToObject(StarDist2D.java:705)
qupath.tensorflow.stardist.StarDist2D.lambda$detectObjects$6(StarDist2D.java:646)
1 Like

Thanks, it looks the same issue as TopologyException: found non-noded intersection between LINESTRING – and somewhat related to https://github.com/locationtech/jts/issues/288 (since the exception is thrown deep in Java Topology Suite, but triggered by an intersection rather than a union).

I created a QuPath issue here: https://github.com/qupath/qupath/issues/587

And promptly tried to resolve it here: https://github.com/qupath/qupath/pull/588

If you’re able to rebuild QuPath using the link at the bottom of the pull request then hopefully the issue will be resolved. There may still be one cell whose boundary is not handled properly, but at least it doesn’t cause the entire detection to fail.

Alternatively, the code that that leads to it all seems to be based on the cellConstrainScale parameter in the StarDist script. If you’re using this, excluding that parameter should also work around the problem.

1 Like

I couldn’t figure out how to rebuild with the pull request, but just taking out the cellConstrainScale parameter worked! Thank you for the quick fix!

Fair enough, if you’ve got a GitHub account you might see an ‘Open with’ button somewhere that helps you get the code (e.g. in GitHub Desktop)… but since since my access to the repo is different, I’m not entirely sure what anyone else sees when they go to that page.

Glad the other way works!

1 Like