Pipeline Entry Point
The main entry point is therun_pipeline() function, which orchestrates all five analysis steps:
analysis_pipeline.py
Input Data Structure
The pipeline expects trajectory data in this format:Pipeline Steps
Step 1: Data Ingestion & Cleaning
Converts the JSON trajectory data into a pandas DataFrame optimized for numerical analysis.
Learn More
Detailed documentation on data preparation
Step 2: Dexterity Metrics
Calculates physics-based metrics including velocity, acceleration, jerk, and economy of movement.
Learn More
Complete guide to dexterity calculations
Step 3: Benchmarking
Compares actual trajectory to an ideal straight-line path.
Learn More
How performance is compared to ideal patterns
Step 4: Risk Analysis
Identifies critical events and spatial patterns indicating surgical risks.
Learn More
Risk detection and quadrant analysis
Output Structure
The pipeline returns a tuple containing:- Score (float): Numerical score from 0 to 100
- Feedback (string): Markdown-formatted report
Example Output
Performance Considerations
The entire pipeline typically completes in under 1 second for surgeries with 1000-5000 movements.
Optimization Techniques
- Vectorized operations: All calculations use NumPy for C-level performance
- Single-pass processing: Each step processes data only once
- Efficient data structures: pandas DataFrames for optimized numerical operations
- Minimal memory footprint: In-place operations where possible
Error Handling
The pipeline handles various edge cases:Empty or Invalid Data
Empty or Invalid Data
If
movements array is empty or malformed, the pipeline returns a default score of 0 with an error message.Missing Coordinates
Missing Coordinates
Missing z-coordinates default to 0. Missing x or y coordinates will raise a ValueError.
Division by Zero
Division by Zero
All division operations use
.replace(0, np.inf) followed by .replace(np.inf, 0) to handle zero time deltas.Identical Start/End Points
Identical Start/End Points
When start and end positions are identical, economy defaults to 1.0 to avoid division by zero.
Integration Example
Here’s a complete example showing how the pipeline integrates with the Justina backend:Next Steps
Data Ingestion
Learn how trajectory data is cleaned and prepared
Dexterity Metrics
Explore the physics calculations behind skill assessment