Purpose
The AI system serves multiple critical functions:Performance Evaluation
Objective scoring based on dexterity metrics, precision, and safety
Real-Time Feedback
Immediate, actionable recommendations for surgical improvement
Risk Detection
Identification of critical events like hemorrhages and tumor touches
Training Analytics
Long-term performance tracking and skill progression analysis
Architecture
The AI system is built as a Python microservice that integrates with the backend via REST API and WebSocket channels.5-Step Analysis Pipeline
The analysis pipeline processes surgical trajectory data through five sequential steps:Data Ingestion & Cleaning
Converts raw movement data into a structured pandas DataFrame, calculates relative timestamps, and prepares data for analysis.
Technical Details
Technical Details
- Extracts x, y, z coordinates from each movement
- Sorts by timestamp for chronological order
- Calculates time deltas (dt) between movements
- Converts timestamps to relative seconds
Dexterity Metrics Calculation
Computes physics-based metrics that quantify surgical skill and hand coordination.
Calculated Metrics
Calculated Metrics
- Velocity (v = distance/time): Movement speed
- Acceleration (a = dv/dt): Rate of speed change
- Jerk (j = da/dt): Smoothness indicator
- Economy of Movement: Ratio of total path length to direct distance
- Duration: Total procedure time
Benchmarking Against Ideal
Compares actual trajectory to an ideal straight-line path between start and end points.
Comparison Metrics
Comparison Metrics
- Calculates perpendicular distance from each point to ideal line
- Averages deviation across all movements
- Converts to precision percentage (100% = perfect)
Risk Analysis
Identifies critical events and spatial patterns that indicate surgical risks.
Risk Factors
Risk Factors
- Tumor Touches: Contact with cancerous tissue
- Hemorrhages: Vascular damage events
- Critical Quadrants: Spatial zones where errors occurred
Key Components
Analysis Pipeline
Core 5-step algorithm implemented in Python
AI Client
JustinaAIClient class for backend integration
WebSocket Integration
Real-time notifications when new surgeries complete
Technologies
The AI system leverages modern Python data science libraries:- pandas: Data manipulation and time-series analysis
- numpy: Numerical computations and linear algebra
- requests: HTTP client for REST API calls
- websocket-client: Real-time backend communication
- flask: Optional REST API server
Performance Tiers
The AI system classifies surgical performance into four tiers:🌟 EXCELENTE (90-100)
🌟 EXCELENTE (90-100)
Exceptional performance with minimal errors, optimal economy of movement, and no critical events.
✅ BUENO (75-89)
✅ BUENO (75-89)
Good performance with minor inefficiencies, few errors, and safe technique.
⚠️ MEJORABLE (60-74)
⚠️ MEJORABLE (60-74)
Adequate performance but with notable areas for improvement in precision or safety.
❌ DEFICIENTE (<60)
❌ DEFICIENTE (<60)
Needs significant improvement due to multiple errors, poor economy, or critical safety events.
Integration Workflow
The typical AI workflow follows these steps:The AI system operates asynchronously from the simulation, allowing surgeons to continue training while analysis runs in the background.
Next Steps
Explore the Pipeline
Deep dive into each analysis step with code examples
Setup Your Environment
Install dependencies and configure the AI service