Skip to content

Commit

Permalink
add try catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Jun 17, 2024
1 parent 64d7e6c commit 0cb6998
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>sc.fiji</groupId>
<artifactId>TrackMate-Oneat</artifactId>
<version>3.2.7-SNAPSHOT</version>
<version>3.2.8-SNAPSHOT</version>


<name>TrackMate-Oneat</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,44 +653,42 @@ public static <T extends NativeType<T>> SimpleWeightedGraph<Spot, DefaultWeigh
count = 0;

if (createlinks) {
if (Mitosisspots != null) {

List<Future<Graphobject>> graphlistresult = LinkCreator(model, trackmate, uniquelabelID,
DividingStartspots, Mitosisspots, settings, ndim, logger, img, framespots, numThreads,
calibration, addDisplay);
for (Future<Graphobject> graphresult : graphlistresult) {

Graphobject object = graphresult.get();
ArrayList<Pair<Spot, Spot>> removeedges = object.removeedges;
ArrayList<Pair<Spot, Spot>> addedges = object.addedges;
ArrayList<Double> costlist = object.costlist;

for (int i = 0; i < costlist.size(); ++i) {

Pair<Spot, Spot> removesourcetarget = removeedges.get(i);
graph.removeEdge(removesourcetarget.getA(), removesourcetarget.getB());

}
for (int i = 0; i < costlist.size(); ++i) {

Pair<Spot, Spot> 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<Future<Graphobject>> graphlistresult = LinkCreator(model, trackmate, uniquelabelID,
DividingStartspots, Mitosisspots, settings, ndim, logger, img, framespots, numThreads,
calibration, addDisplay);
for (Future<Graphobject> graphresult : graphlistresult) {
try {
Graphobject object = graphresult.get();
ArrayList<Pair<Spot, Spot>> removeedges = object.removeedges;
ArrayList<Pair<Spot, Spot>> addedges = object.addedges;
ArrayList<Double> costlist = object.costlist;

for (int i = 0; i < costlist.size(); ++i) {
Pair<Spot, Spot> removesourcetarget = removeedges.get(i);
graph.removeEdge(removesourcetarget.getA(), removesourcetarget.getB());
}
for (int i = 0; i < costlist.size(); ++i) {
Pair<Spot, Spot> 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();
}
}

}
}


Expand Down

0 comments on commit 0cb6998

Please sign in to comment.