Skip to content

Commit

Permalink
Update scanline functions and get_pr/lr_pts function in series class. (
Browse files Browse the repository at this point in the history
…#32)

* Update scanline functions and get_pr/lr_pts function in series class.

* fix case where points are in a list

* Specified SLEAP version

* Uncomment graphpipeline tests

* Bump version requirement for sleap-io

* Use isinstance and remove commented lines.

* Black format of graphpipeline.py and scanline.py.

* Disable warning spam from nan/empty slice operations.

---------

Co-authored-by: Lin Wang <linwang9926@gmail.com>
Co-authored-by: Elizabeth Berrigan <berri104@gmail.com>
Co-authored-by: Talmo Pereira <talmo@salk.edu>
  • Loading branch information
4 people authored Jun 26, 2023
1 parent 64d8407 commit a9d1f1c
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 279 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies = [
"pandas",
"matplotlib",
"seaborn",
"sleap-io>=0.0.5",
"sleap-io>=0.0.6",
"scikit-image",
"shapely"
]
Expand Down
16 changes: 4 additions & 12 deletions sleap_roots/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,12 @@ def get_root_pair_widths_projections(lateral_pts, primary_pts, tolerance):
tolerance: difference in projection norm between the right and left side (~0.02).
Returns:
A tuple of (dists, left_inds, right_inds) where:
- match_dists is the distance in pixels between the bases of matched
A match_dists is the distance in pixels between the bases of matched
roots as a vector of size (n_matches,).
- left_inds is are the indices of the left roots that were matched as
a vector of size (n_matches,).
- right_inds is are the indices of the right roots that were matched as
a vector of size (n_matches,).
If all the lateral roots are on one side of the primary root, 3 empty arrays of
shape 0 are returned.
"""
if np.isnan(primary_pts).all():
return []
return np.nan
else:
primary_pts_filtered = primary_pts[~np.isnan(primary_pts).any(axis=2)]
primary_line = LineString(primary_pts_filtered)
Expand All @@ -256,7 +248,7 @@ def get_root_pair_widths_projections(lateral_pts, primary_pts, tolerance):

# Edge Case: Only found roots on one side.
if is_left.all() or (~is_left).all():
return np.array([]), np.array([]), np.array([])
return np.nan

# Get left and right base points.
left_bases, right_bases = lateral_pts[is_left, 0], lateral_pts[~is_left, 0]
Expand Down Expand Up @@ -311,4 +303,4 @@ def get_root_pair_widths_projections(lateral_pts, primary_pts, tolerance):
left_inds = valid_inds[left_inds]
right_inds = valid_inds[right_inds]

return match_dists, left_inds, right_inds
return match_dists
Loading

0 comments on commit a9d1f1c

Please sign in to comment.