Skip to content

Commit

Permalink
Treenode back-end: make node insertion slighlty more robust
Browse files Browse the repository at this point in the history
It seems to happen in very rare cases that a passed in radius or
confidence is NaN. Handling these situations more gracefully is use ful
to mitigate this behavior. It should still be checked why such
situations happen, but they shouldn't prevent node creation.
  • Loading branch information
tomka committed Jul 16, 2018
1 parent de5b8f0 commit 1ee60a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions django/applications/catmaid/control/treenode.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ def insert_new_treenode(parent_id=None, skeleton_id=None):
new_treenode.location_x = float(x)
new_treenode.location_y = float(y)
new_treenode.location_z = float(z)
new_treenode.radius = int(radius)
new_radius = int(radius if (radius and not math.isnan(radius)) else 0)
new_treenode.radius = new_radius
new_treenode.skeleton_id = skeleton_id
new_treenode.confidence = int(confidence)
new_confidence = int(confidence if not math.isnan(confidence) and (confidence or confidence is 0) else 5)
new_treenode.confidence = new_confidence
if parent_id:
new_treenode.parent_id = parent_id
new_treenode.save()
Expand Down

0 comments on commit 1ee60a1

Please sign in to comment.