Troubleshooting¶
This guide addresses common issues when using sleap-roots and provides solutions.
Installation Issues¶
Git LFS Data Not Downloaded¶
Problem: Example data files are missing or show as text pointers
Solution:
# Install Git LFS
git lfs install
# Pull LFS data
git lfs pull
# Verify files are binary (not text pointers)
file tests/data/*.h5 # Should show "HDF5 data file"
Import Errors¶
Problem: ModuleNotFoundError: No module named 'sleap_roots'
Solution:
# Install in editable mode for development
pip install -e .
# Or install normally
pip install sleap-roots
# Verify installation
python -c "import sleap_roots; print(sleap_roots.__version__)"
Dependency Conflicts¶
Problem: Version conflicts with other packages
Solution: Create a fresh virtual environment:
# Using venv (built-in)
python -m venv sleap-roots-env
source sleap-roots-env/bin/activate # On Windows: sleap-roots-env\Scripts\activate
pip install sleap-roots
# Or use uv (recommended - faster)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install sleap-roots
Data Loading Issues¶
Cannot Load H5 File¶
Problem: OSError: Unable to open file
Causes and solutions:
-
File doesn't exist:
-
File is corrupted:
-
Wrong file format: Ensure file is exported from SLEAP, not a raw labels file:
Cannot Load SLP File¶
Problem: ValueError: Cannot load SLEAP file
Solution:
# Verify SLP file is valid
import sleap_io as sio
labels = sio.load_slp("predictions.slp")
print(f"Loaded {len(labels)} frames")
print(f"Skeleton: {labels.skeleton.node_names}")
Missing Predictions¶
Problem: Empty or sparse predictions in H5/SLP files
Solution: 1. Check SLEAP tracking quality 2. Lower confidence threshold in SLEAP 3. Review frames with missing tracks in SLEAP GUI
Trait Computation Issues¶
NaN Values in Traits¶
Problem: Computed traits contain NaN values
Common causes:
-
Insufficient tracking points:
-
Empty root arrays:
-
Division by zero: Handle edge cases in custom computations:
Incorrect Trait Values¶
Problem: Trait values seem wrong or unexpected
Debugging steps:
-
Visualize the data:
-
Check intermediate values:
-
Verify pixel scaling: If physical units are needed:
Missing Lateral Roots¶
Problem: Lateral root count is lower than expected
Solutions:
- Check SLEAP tracking:
- Open
lateral.slpin SLEAP GUI - Verify all laterals are tracked
-
Check for broken tracks
-
Verify node names:
-
Lower confidence threshold:
Pipeline-Specific Issues¶
DicotPipeline¶
Problem: Primary-lateral connections incorrect
Solution:
# Verify primary and lateral bases align
primary_pts = series.primary_pts[0]
lateral_pts_list = series.lateral_pts[0]
# Primary base should be near (0,0) in root coordinates
print(f"Primary base: {primary_pts[0]}")
# Each lateral should start near primary
for i, lateral_pts in enumerate(lateral_pts_list):
print(f"Lateral {i} base: {lateral_pts[0]}")
MonocotPipeline¶
Problem: Crown roots not detected
Solution: 1. Ensure crown roots are in separate file from primary 2. Check that crown root bases are labeled correctly 3. Verify SLEAP model detects all crown roots
# Check crown root data
crown_pts_list = series.crown_pts[0] # For monocot pipelines
print(f"Crown root count: {len(crown_pts_list)}")
MultiplePipeline¶
Problem: Plants not separated correctly
Solution:
# Check track IDs
labels = sio.load_slp("predictions.slp")
track_ids = set()
for frame in labels:
for instance in frame:
if instance.track is not None:
track_ids.add(instance.track.name)
print(f"Found {len(track_ids)} unique tracks: {track_ids}")
# Should match expected plant count
Performance Issues¶
Slow Computation¶
Problem: Trait computation takes too long
Solutions:
-
Use vectorized operations:
-
Process in parallel:
-
Reduce temporal resolution:
High Memory Usage¶
Problem: Out of memory errors
Solutions:
-
Process in batches:
-
Clear unused data:
Visualization Issues¶
Plots Not Showing¶
Problem: plt.show() doesn't display plots
Solutions:
-
Use interactive backend:
-
For Jupyter notebooks:
-
Save to file instead:
Coordinate System Issues¶
Problem: Plots appear flipped or rotated
Solution:
# Image coordinates: origin at top-left
plt.plot(pts[:, 0], pts[:, 1], 'o-')
plt.gca().invert_yaxis() # Flip y-axis to match image
plt.axis('equal') # Equal aspect ratio
Export Issues¶
CSV Not Created¶
Problem: write_csv=True but no file appears
Solutions:
-
Check file permissions:
-
Verify write succeeded:
CSV Encoding Issues¶
Problem: Special characters garbled in CSV
Solution:
Testing Issues¶
Tests Fail Locally¶
Problem: Tests pass in CI but fail locally
Solutions:
-
Check Git LFS data:
-
Verify environment:
-
Run specific test:
Import Errors in Tests¶
Problem: ModuleNotFoundError when running tests
Solution:
Platform-Specific Issues¶
Windows¶
Path separators:
from pathlib import Path
# Good: platform-independent
path = Path("data") / "predictions.h5"
# Avoid: hardcoded separators
# path = "data/predictions.h5" # May fail on Windows
Long paths: Enable long path support in Windows or use shorter paths
macOS¶
File permissions:
Linux¶
Display issues:
Common Error Messages¶
KeyError: 'primary_root'¶
Cause: Node name mismatch
Solution:
# Check actual node names
labels = sio.load_slp("primary.slp")
print("Available nodes:", labels.skeleton.node_names)
# Pass correct names to pipeline
pipeline = sr.DicotPipeline(primary_name="actual_node_name")
IndexError: list index out of range¶
Cause: Empty tracking results
Solution:
# Check for empty frames
for i, frame_pts in enumerate(series.primary_pts):
if len(frame_pts) == 0:
print(f"Frame {i} has no points")
ValueError: array size must be at least 2¶
Cause: Too few points for computation
Solution:
# Filter frames with sufficient points
def has_enough_points(pts, min_points=5):
return len(pts) >= min_points
valid_frames = [i for i, pts in enumerate(series.primary_pts)
if has_enough_points(pts)]
Getting Help¶
If you're still stuck:
-
Check existing issues: GitHub Issues
-
Search documentation: Use search bar (top of page)
-
Create a minimal example:
-
Open an issue: Include:
- Error message and full traceback
- Minimal reproducible example
- sleap-roots version:
import sleap_roots; print(sleap_roots.__version__) - Python version:
python --version -
Operating system
-
Community support:
- GitHub Discussions
- SLEAP Slack workspace
Best Practices for Avoiding Issues¶
1. Validate Data Early¶
def validate_series(series):
"""Check series has required data."""
assert len(series.primary_pts) > 0, "No primary root data"
assert all(len(pts) >= 2 for pts in series.primary_pts), "Insufficient points"
print("Series validation passed!")
validate_series(series)
2. Use Try-Except Blocks¶
try:
traits = pipeline.compute_plant_traits(series)
except Exception as e:
print(f"Error processing {series.series_name}: {e}")
# Log error and continue with next plant
continue
3. Log Intermediate Results¶
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.info(f"Processing {series.series_name}")
traits = pipeline.compute_plant_traits(series)
logger.info(f"Computed {len(traits.columns)} traits")
4. Test on Small Subset First¶
# Test on first 3 plants before processing all 100
test_series = series_list[:3]
for series in test_series:
traits = pipeline.compute_plant_traits(series)
print(f"{series.series_name}: OK")
# If tests pass, process all
all_traits = pipeline.compute_multi_plant_traits(series_list)
Next Steps¶
- Review Quick Start for basic usage
- Read Pipeline Guides for pipeline-specific details
- Check Trait Reference for trait definitions
- See Batch Processing for large-scale workflows