Tips¶
Overview¶
Detect and extract root tip coordinates. Used for tracking root growth direction and computing tip-based traits.
Key functions:
- get_tips - Extract tip points from root arrays
- get_tip_xs - Get x-coordinates of tips
- get_tip_ys - Get y-coordinates of tips
Quick Example¶
import sleap_roots as sr
series = sr.Series.load("plant", lateral_path="lateral.slp")
lateral_pts_list = series.get_lateral_points()
# Get tip points
tips = sr.get_tips(lateral_pts_list)
print(f"Tip shape: {tips.shape}") # (n_laterals, 2)
print(f"First tip: x={tips[0, 0]:.1f}, y={tips[0, 1]:.1f}")
API Reference¶
get_tips¶
get_tips ¶
Return tips (last node) from each root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
ndarray
|
Root landmarks as array of shape |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of tips. If the input is |
ndarray
|
returned. If the input is |
ndarray
|
|
ndarray
|
tips, an array of shape |
Source code in sleap_roots/tips.py
Example:
import sleap_roots as sr
import numpy as np
series = sr.Series.load("plant", lateral_path="lateral.slp")
lateral_pts_list = series.get_lateral_points()
# Extract all lateral tips
tips = sr.get_tips(lateral_pts_list)
# Handle NaN (missing tips)
valid_tips = tips[~np.isnan(tips).any(axis=1)]
print(f"Valid tips: {len(valid_tips)}/{len(tips)}")
get_tip_xs¶
get_tip_xs ¶
Get x coordinates of tip points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tip_pts
|
ndarray
|
Root tip points as array of shape |
required |
Return
An array of tip x-coordinates (instances,) or a scalar when there is only one root.
Source code in sleap_roots/tips.py
get_tip_ys¶
get_tip_ys ¶
Get y coordinates of tip points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tip_pts
|
ndarray
|
Root tip points as array of shape |
required |
Return
An array of tip y-coordinates (instances,) or a scalar when there is only one root.
Source code in sleap_roots/tips.py
Example:
import sleap_roots as sr
lateral_pts_list = sr.Series.load("plant", lateral_path="lateral.slp").get_lateral_points()
# Get tip coordinates separately
tip_xs = sr.get_tip_xs(lateral_pts_list)
tip_ys = sr.get_tip_ys(lateral_pts_list)
print(f"Tip x-coordinates: {tip_xs}")
print(f"Tip y-coordinates: {tip_ys}")