Network Length¶
Overview¶
Compute whole-plant network-level metrics including bounding box, width-depth ratio, and distribution statistics.
Key functions:
- get_network_length - Total root system length
- get_network_width_depth_ratio - W:D ratio
- get_network_distribution - Spatial distribution metrics
- get_bbox - Bounding box coordinates
Quick Example¶
import sleap_roots as sr
series = sr.Series.load("plant", primary_path="primary.slp", lateral_path="lateral.slp")
primary_pts = series.get_primary_points()
lateral_pts_list = series.get_lateral_points()
# Network metrics
from sleap_roots import join_pts
all_pts = join_pts([primary_pts] + lateral_pts_list)
network_len = sr.get_network_length(all_pts)
wd_ratio = sr.get_network_width_depth_ratio(all_pts)
print(f"Total network length: {network_len:.2f} px")
print(f"Width:Depth ratio: {wd_ratio:.2f}")
API Reference¶
get_network_length¶
get_network_length ¶
get_network_length(
lengths0: Union[float, ndarray],
*args: Optional[Union[float, ndarray]]
) -> float
Return the total root network length given primary and lateral root lengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lengths0
|
Union[float, ndarray]
|
Either a float representing the length of a single
root or an array of root lengths with shape |
required |
*args
|
Optional[Union[float, ndarray]]
|
Additional optional floats representing the lengths of single
roots or arrays of root lengths with shape |
()
|
Returns:
| Type | Description |
|---|---|
float
|
Total length of root network. |
Source code in sleap_roots/networklength.py
get_network_width_depth_ratio¶
get_network_width_depth_ratio ¶
Return width to depth ratio of bounding box for root network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
Union[ndarray, Tuple[float, float, float, float]]
|
Root landmarks as array of shape (..., 2) or boundary box. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Float of bounding box width to depth ratio of root network. |
Source code in sleap_roots/networklength.py
get_network_distribution¶
get_network_distribution ¶
get_network_distribution(
pts_list: List[ndarray],
bounding_box: Tuple[float, float, float, float],
fraction: float = 2 / 3,
) -> float
Return the root length in the lower fraction of the plant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts_list
|
List[ndarray]
|
A list of arrays, each having shape |
required |
bounding_box
|
Tuple[float, float, float, float]
|
Tuple in the form |
required |
fraction
|
float
|
Lower fraction value. Defaults to 2/3. |
2 / 3
|
Returns:
| Type | Description |
|---|---|
float
|
Root network length in the lower fraction of the plant. |
Source code in sleap_roots/networklength.py
get_bbox¶
get_bbox ¶
Return the bounding box of all landmarks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
ndarray
|
Root landmarks as array of shape (..., 2). |
required |
Returns:
| Type | Description |
|---|---|
float
|
Tuple of four parameters in bounding box: |
float
|
left_x, the x axis value of left side |
float
|
top_y, the y axis value of top side |
float
|
width, the width of the bounding box |
Tuple[float, float, float, float]
|
height, the height of bounding box. |
Source code in sleap_roots/networklength.py
Related Modules¶
- Convex Hull - Spatial analysis
- Lengths - Individual root lengths