From 0cb699834279e48fa9e83a2aa96a8e016d7f6134 Mon Sep 17 00:00:00 2001 From: kapoorlab Date: Mon, 17 Jun 2024 22:54:31 +0200 Subject: [PATCH] add try catch block --- pom.xml | 2 +- .../action/oneat/TrackCorrectorRunner.java | 74 +++++++++---------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/pom.xml b/pom.xml index 481ffaa..dd9f23f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ sc.fiji TrackMate-Oneat - 3.2.7-SNAPSHOT + 3.2.8-SNAPSHOT TrackMate-Oneat diff --git a/src/main/java/fiji/plugin/trackmate/action/oneat/TrackCorrectorRunner.java b/src/main/java/fiji/plugin/trackmate/action/oneat/TrackCorrectorRunner.java index 7c0d301..fd141f9 100644 --- a/src/main/java/fiji/plugin/trackmate/action/oneat/TrackCorrectorRunner.java +++ b/src/main/java/fiji/plugin/trackmate/action/oneat/TrackCorrectorRunner.java @@ -653,44 +653,42 @@ public static > SimpleWeightedGraph> graphlistresult = LinkCreator(model, trackmate, uniquelabelID, - DividingStartspots, Mitosisspots, settings, ndim, logger, img, framespots, numThreads, - calibration, addDisplay); - for (Future graphresult : graphlistresult) { - - Graphobject object = graphresult.get(); - ArrayList> removeedges = object.removeedges; - ArrayList> addedges = object.addedges; - ArrayList costlist = object.costlist; - - for (int i = 0; i < costlist.size(); ++i) { - - Pair removesourcetarget = removeedges.get(i); - graph.removeEdge(removesourcetarget.getA(), removesourcetarget.getB()); - - } - for (int i = 0; i < costlist.size(); ++i) { - - Pair addsourcetarget = addedges.get(i); - double cost = costlist.get(i); - graph.addVertex(addsourcetarget.getA()); - graph.addVertex(addsourcetarget.getB()); - - if (graph.degreeOf(addsourcetarget.getB()) < 2) { - final DefaultWeightedEdge edge = graph.addEdge(addsourcetarget.getA(), - addsourcetarget.getB()); - - graph.setEdgeWeight(edge, cost); - - } - - } - - } - - } + if (Mitosisspots != null) { + + List> graphlistresult = LinkCreator(model, trackmate, uniquelabelID, + DividingStartspots, Mitosisspots, settings, ndim, logger, img, framespots, numThreads, + calibration, addDisplay); + for (Future graphresult : graphlistresult) { + try { + Graphobject object = graphresult.get(); + ArrayList> removeedges = object.removeedges; + ArrayList> addedges = object.addedges; + ArrayList costlist = object.costlist; + + for (int i = 0; i < costlist.size(); ++i) { + Pair removesourcetarget = removeedges.get(i); + graph.removeEdge(removesourcetarget.getA(), removesourcetarget.getB()); + } + for (int i = 0; i < costlist.size(); ++i) { + Pair addsourcetarget = addedges.get(i); + double cost = costlist.get(i); + graph.addVertex(addsourcetarget.getA()); + graph.addVertex(addsourcetarget.getB()); + + if (graph.degreeOf(addsourcetarget.getB()) < 2) { + final DefaultWeightedEdge edge = graph.addEdge(addsourcetarget.getA(), + addsourcetarget.getB()); + + graph.setEdgeWeight(edge, cost); + } + } + } catch (Exception e) { + // Log the exception or handle it as needed + e.printStackTrace(); + } + } + + } }