Function Signature
Calculated Metrics
Velocity
Rate of position change (distance/time)
Acceleration
Rate of velocity change (Δv/Δt)
Jerk
Rate of acceleration change (Δa/Δt) - measures smoothness
Economy
Ratio of actual path length to direct distance
Complete Implementation
analysis_pipeline.py
Detailed Breakdown
1. Distance Calculation
The Euclidean distance between consecutive points is computed using the 3D distance formula:The
diff() operation computes the difference between consecutive rows, giving us Δx, Δy, Δz.2. Velocity Calculation
Velocity is the rate of position change:3. Acceleration Calculation
Acceleration measures how quickly velocity changes:4. Jerk Calculation
Jerk (the derivative of acceleration) indicates movement smoothness:5. Economy of Movement
Economy compares the actual path length to the shortest possible path:Economy = 1.0
Economy = 1.0
Perfect economy - the surgeon moved in a perfectly straight line.
Economy = 1.2
Economy = 1.2
Good economy - path is only 20% longer than necessary.
Economy = 2.0
Economy = 2.0
Poor economy - path is twice as long as the direct route.
Output Structure
The function returns a dictionary with these keys:| Key | Type | Description | Ideal Value |
|---|---|---|---|
economia | float | Path length ratio | < 1.2 |
v_avg | float | Average velocity (units/s) | Moderate |
a_max | float | Maximum acceleration | Low |
j_avg | float | Average jerk (smoothness) | Low |
total_dist | float | Total path length | N/A |
duration | float | Total procedure time (s) | N/A |
Example Output
Interpretation Guide
- Excellent Performance
- Good Performance
- Needs Improvement
- Economy: 1.0 - 1.2x
- Jerk: < 0.5 (smooth movements)
- Max Acceleration: < 5.0
- Duration: Appropriate for task complexity
Why These Metrics Matter
Velocity
Reveals hesitation (low v) or rushed movements (high v)
Acceleration
High peaks indicate sudden stops/starts, suggesting poor planning
Jerk
Direct measure of hand tremor and movement control
Economy
Indicates spatial planning and efficiency
Performance Optimization
All calculations use vectorized NumPy operations for maximum speed:- No loops: Entire columns processed at once
- In-place operations: Minimal memory allocation
- Efficient algorithms: O(n) complexity for all metrics
Next Step
With dexterity metrics calculated, the pipeline moves to benchmarking:Benchmarking
Compare performance against ideal patterns