Function Signature
Detected Risk Factors
Tumor Touches
Contact with cancerous tissue that should be avoided
Hemorrhages
Vascular damage events causing bleeding
Critical Quadrants
Spatial zones where errors occurred
Event Clustering
Multiple incidents in the same area
Implementation
analysis_pipeline.py
Algorithm Breakdown
Count Critical Events
Count occurrences of TUMOR_TOUCH and HEMORRHAGE events.
These events are emitted by the frontend simulation when collision detection triggers.
Define Spatial Quadrants
Divide the surgical workspace into four quadrants using midpoints.This creates four regions:
- Sup-Der (Superior-Right): x > mid_x, y > mid_y
- Sup-Izq (Superior-Left): x < mid_x, y > mid_y
- Inf-Der (Inferior-Right): x > mid_x, y < mid_y
- Inf-Izq (Inferior-Left): x < mid_x, y < mid_y
Output Structure
The function returns a dictionary with three keys:| Key | Type | Description | Severity |
|---|---|---|---|
touches | int | Number of tumor contacts | Moderate (-8 points each) |
hemorrhages | int | Number of bleeding events | Critical (-15 points each) |
cuadrantes | list[str] | Quadrants where errors occurred | Informational |
Example Outputs
- Perfect Performance
- Minor Issues
- Serious Concerns
Event Types
The simulation frontend can emit these surgical events:START
START
Marks the beginning of the surgical procedure. Not counted as a risk.
NONE
NONE
Normal movement with no special event. The majority of movements fall into this category.
TUMOR_TOUCH
TUMOR_TOUCH
Scalpel made contact with tumor tissue. In real surgery, touching the tumor can cause cancer cell spread.Penalty: -8 points per occurrence
HEMORRHAGE
HEMORRHAGE
Vascular structure was damaged, causing bleeding. This is the most severe error.Penalty: -15 points per occurrence
FINISH
FINISH
Marks successful completion of the procedure. Not counted as a risk.
Quadrant Visualization
Clinical Interpretation
Hemorrhage Analysis
0 Hemorrhages
Excellent vascular control
1-2 Hemorrhages
Needs technique review
3+ Hemorrhages
Requires immediate retraining
Tumor Touch Analysis
- 0 touches: Excellent tumor avoidance
- 1-3 touches: Minor contact, acceptable in complex cases
- 4+ touches: Excessive contact suggests poor spatial awareness
Spatial Patterns
Errors in Single Quadrant
Errors in Single Quadrant
Suggests a specific anatomical challenge or approach angle issue. Recommendation: Practice from different angles.
Errors in Multiple Quadrants
Errors in Multiple Quadrants
Indicates systemic issues with control or planning. Recommendation: Fundamental skill review needed.
Score Impact
Risk factors directly affect the final score in Step 5:Example Calculations
| Touches | Hemorrhages | Points Lost | Remaining Score |
|---|---|---|---|
| 0 | 0 | 0 | 100 |
| 2 | 0 | 16 | 84 |
| 0 | 1 | 15 | 85 |
| 3 | 2 | 54 | 46 |
These are baseline penalties. Additional penalties may apply based on economy of movement and other factors.
Future Enhancements
3D Quadrant Analysis
Include Z-axis for full 3D spatial risk mapping
Temporal Clustering
Detect rapid succession of errors (panic response)
Proximity Warnings
Identify near-misses that didn’t trigger events
Risk Heatmaps
Generate visual heatmaps of high-risk zones
Performance
Risk analysis is highly efficient:- Event counting: O(n) with vectorized boolean operations
- Quadrant mapping: O(k) where k = number of critical events (typically much less than n)
- No complex calculations: Simple comparisons and arithmetic
Next Step
With risk factors quantified, the pipeline generates the final score and feedback:Scoring & Feedback
Convert all metrics into actionable scores and recommendations