Bases¶
Overview¶
Detect lateral root base points and compute base-related traits. Critical for understanding lateral root emergence patterns and density.
Key functions:
- get_bases - Detect base points where laterals emerge from primary
- get_base_length - Length of lateral root zone
- get_base_ct_density - Lateral root density
- get_root_widths - Root width measurements
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()
# Detect base points
bases = sr.get_bases(primary_pts, lateral_pts_list)
print(f"Base points shape: {bases.shape}")
# Compute base zone length
base_length = sr.get_base_length(bases)
print(f"Lateral root zone length: {base_length:.2f} px")
API Reference¶
get_bases¶
get_bases ¶
Return bases (r1) from each root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pts
|
ndarray
|
Root landmarks as array of shape |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of bases |
Source code in sleap_roots/bases.py
get_base_length¶
get_base_length ¶
Get the y-axis difference from the top lateral base to the bottom lateral base.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lateral_base_ys
|
ndarray
|
y-coordinates of the base points of lateral roots of shape
|
required |
Return
The distance between the top base y-coordinate and the deepest
base y-coordinate. Returns np.nan when the input array is empty
(e.g. plate frames with zero detected laterals). See issue #156.
Source code in sleap_roots/bases.py
get_base_ct_density¶
get_base_ct_density ¶
Get a ratio of the number of base points to maximum primary root length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary_length_max
|
float
|
Scalar of maximum primary root length. |
required |
lateral_base_pts
|
ndarray
|
Base points of lateral roots as returned by |
required |
Return
Scalar of base count density.
Source code in sleap_roots/bases.py
Example:
import sleap_roots as sr
series = sr.Series.load("dicot", primary_path="primary.slp", lateral_path="lateral.slp")
primary_pts = series.get_primary_points()
lateral_pts_list = series.get_lateral_points()
bases = sr.get_bases(primary_pts, lateral_pts_list)
density = sr.get_base_ct_density(bases, primary_pts)
print(f"Lateral root density: {density:.3f} roots/pixel")
get_root_widths¶
get_root_widths ¶
get_root_widths(
primary_max_length_pts: ndarray,
lateral_pts: ndarray,
tolerance: float = 0.02,
return_inds: bool = False,
) -> Tuple[ndarray, list, ndarray, ndarray]
Estimate root width using bases of lateral roots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary_max_length_pts
|
ndarray
|
Longest primary root, represented as a 2D array of shape (nodes, 2). |
required |
lateral_pts
|
ndarray
|
Lateral roots, represented as a 3D array of shape (n, nodes, 2). |
required |
tolerance
|
float
|
Tolerance level for the projection difference between matched roots. Defaults to 0.02. |
0.02
|
return_inds
|
bool
|
Flag to indicate whether to return matched indices along with distances. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
|
list
|
|
Source code in sleap_roots/bases.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
Related Modules¶
- Tips - Tip point detection
- Lengths - Base-to-tip distances
- DicotPipeline - Uses base functions