CardioTwin is engineered as two completely decoupled, high-performance systems communicating over a canonical REST API:

  1. The Frontend (Clinical Command Center) Framework: React 18 + Vite + TypeScript (Strict Mode). 3D Visualization: React Three Fiber (@react-three/fiber), @react-three/drei, and three.js, rendering custom PBR materials, procedural coronary vessels, and N8AO ambient occlusion. Particle Physics & Shaders: Custom arterial blood flow particle system with variable speed gradients keyed to vessel blockage severity. Audio Synthesis: Native Web Audio API synthesizing authentic dual-tone cardiac auscultation synchronized to heartbeat frame ticks. State & Transitions: Zustand for centralized state, Framer Motion for UI micro-interactions, and Recharts for SHAP waterfall charts and 5-year risk projections. Design System: Clinical dark-mode command center palette (#090d16 base) with strict reserved risk signaling (Green: 0–33%, Amber: 34–66%, Red: 67–100%).

  2. The Machine Learning Engine & Backend API Core ML: Tuned XGBoost models trained independently for each coronary vessel and calibrated via CalibratedClassifierCV over Stratified 10-Fold Cross-Validation to guarantee true probabilistic outputs. Zero-Leakage Architecture: Strict mathematical exclusion in build_X() that purges all catheterization ground truth (Cath, LAD, LCX, RCA) before feature transformations. Dual-Cohort Validation: Trained on the gold-standard prospective Z-Alizadeh Sani clinical cohort (303 patients) and validated out-of-sample against our 50,000-patient synthetic simulation cohort generated via Multivariate Gaussian Copula and rank covariance modeling (ml/synthesize.py). Explainability Pipeline: Built-in SHAP TreeExplainer on base estimators that strips pipeline prefixes and matches features to medical glossaries and population references. Production API: FastAPI (Python 3.11) with automated default schema imputation (eliminating 500 crashes on incomplete patient charts), sub-30ms inference latency, OpenAPI /docs, and enterprise observability headers (X-Process-Time, X-Request-ID). Containerization & Testing: Dockerized (Dockerfile with libomp-dev) and verified with an automated 13-test Pytest suite and a 155ms self-diagnostic smoke test.

Challenges we ran into- The Target Leakage Trap: In medical datasets, target labels are easily entangled (e.g., overall Cath diagnosis is defined by vessel blockages). Many baseline models accidentally achieve a fake "99% accuracy" because the target leaks through the features. We audited every step of the CV pipeline to guarantee absolute mathematical isolation. Calibrated Probability vs. SHAP Compatibility: Scikit-Learn's CalibratedClassifierCV hides the underlying XGBoost model inside a meta-estimator wrapper, breaking standard SHAP calls. We engineered a dynamic extraction strategy to pull base estimators from the calibration folds without incurring runtime overhead. The "We Are Not Doctors" Boundary: In healthcare AI, it is dangerous to claim autonomous medical diagnosis or "prescribe" treatments. We deliberately framed the software around pure engineering and statistics: replacing prescriptive diagnosis with 95% Confidence Intervals, out-of-distribution sensor screening, and a formal Non-Diagnostic CDS regulatory disclaimer. Real-Time 3D Performance: Running a 3D pulsing anatomical mesh, an arterial particle system, post-processing bloom, and Web Audio simultaneously in the browser can cause frame drops. We optimized draw calls, implemented frustum culling, and added performance tier gating for lower-end hardware. Zero-Crash Clinical Fault Tolerance: Real patient charts often miss lab values. We built an automated default imputation engine that fills omitted biomarkers with canonical schema defaults and surfaces non-blocking structured warnings instead of throwing 500 errors.

Accomplishments that we're proud of - Exceptional Predictive Rigor: Achieved 91.7% ROC-AUC / 93.0% Recall on overall CAD on the gold-standard prospective trial cohort with zero target leakage. Proven 50,000-Patient Generalization: Validated the engine against a 50,000-patient simulation cohort with an out-of-sample generalization gap under 0.05 (86.3% ROC-AUC / 90.6% Recall across 50,000 patients). Real-Time Responsiveness: Complete 4-vessel multi-target risk prediction executes in ~23 milliseconds, with local SHAP feature attributions generated in under 12 milliseconds. Immersive Visual & Audio Fidelity: Bringing medical data to life with synchronized S1/S2 heartbeats, occlusion-aware 3D labels, and realistic fluoroscopic angiogram blooms. 100% Test Pass Rate: 13 out of 13 automated unit, integration, and leakage tests passing with zero failures. What we learned In clinical AI, uncertainty quantification is as vital as the prediction itself. An AI saying "85% risk" is dangerous unless the doctor knows whether the confidence interval is 83% - 87% or 60% - 98%. Separating technical representations from human interfaces is key. Doctors don't want to see num_TG or nom_VHD_mild; translating data pipeline artifacts into standard medical nomenclature is essential for clinical adoption. 3D visualization turns abstract data into empathy. Seeing an artery visibly choke with slowed blood flow on a 3D heart makes disease risk immediately intuitive to patients and clinicians alike.

What's next for CardioLens/CardioTwin - Prospective Hospital Pilot: Partnering with clinical cardiology departments to benchmark CardioLens against live cardiac catheterization laboratory workflows. EHR & FHIR Interoperability: Exporting HL7 FHIR RiskAssessment resources to seamlessly pull patient data from hospital EHR systems like Epic and Cerner. Continuous Wearable Telemetry: Integrating continuous PPG and smart-patch ECG feeds (Apple Watch, BioIntelliSense) for real-time longitudinal risk tracking. Virtual Surgical Planning: Expanding the digital twin to simulate post-intervention hemodynamics, allowing surgeons to virtually model the risk reduction from stent angioplasty or coronary artery bypass grafting (CABG).

Built With

Share this project:

Updates

Submission history