Skip to content

Commit

Permalink
Clip min eigenvalues to 0 to block negative values in sqrt
Browse files Browse the repository at this point in the history
This sometimes can happen with floating point representation of very small numbers
  • Loading branch information
zoccoler committed Oct 4, 2024
1 parent e38cc72 commit 7bd6a69
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion napari_skimage_regionprops/_regionprops.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def ellipsoid_axis_lengths(table):
S = np.asarray([[sxx, sxy, sxz], [sxy, syy, syz], [sxz, syz, szz]])
# determine eigenvalues in descending order
eigvals = np.sort(np.linalg.eigvalsh(S))[::-1]
return tuple([math.sqrt(20.0 * e) for e in eigvals])
return tuple([math.sqrt(20.0 * np.clip(e, a_min=0, a_max=None)) for e in eigvals])

regionprops_table_all_frames = analyze_all_frames(regionprops_table)
register_function(regionprops_table_all_frames, menu="Measurement tables > Regionprops of all frames (nsr)")
Expand Down

0 comments on commit 7bd6a69

Please sign in to comment.