Inspiration
Cardiovascular disease remains the leading cause of global mortality. In clinical cardiology, risk assessments are frequently presented as abstract, static percentage scores or dense tabular printouts. This presentation creates a cognitive gap: neither emergency room clinicians under severe time pressure nor patients can immediately visualize where coronary ischemia is developing or which physiological factors are driving the risk.
I asked a straightforward question: Why should cardiovascular risk assessment look like a spreadsheet when the heart is an intricate, spatial organ?
I set out to build Perfusion3D—an interactive spatial digital twin workstation that translates non-invasive clinical biomarkers, ECG metrics, and echocardiographic findings into continuous, localized ischemic risk maps across the coronary arterial tree in real time.
What it does
Perfusion3D links tabular machine learning with real-time 3D WebGL computer graphics to provide clinical decision support:
- Localized Multi-Target Predictions: Simultaneously predicts overall Coronary Artery Disease (CAD) status and individual stenosis probabilities (greater than or equal to 50%) across the three primary coronary arteries:
- LAD (Left Anterior Descending): Perfuses the anterior wall and apex.
- LCX (Left Circumflex): Perfuses the posterolateral left ventricle.
- RCA (Right Coronary Artery): Perfuses the right ventricle, inferior wall, and conduction nodes.
- Dynamic Spatial Perfusion Mapping: Predicted posterior probabilities (P in [0.0, 1.0]) map directly to PBR shader color uniforms on native epicardial arterial conduits:
- Optimal (P <= 0.40): Emerald Green (
#10B981). - Borderline (0.40 < P <= 0.70): Amber (
#F59E0B). - Critical Ischemia (P > 0.70): Crimson Red (
#EF4444) with an oscillating 1.2 Hz emissive alert pulse when P >= 0.75.
- Optimal (P <= 0.40): Emerald Green (
- Sub-4ms Explainability (TreeSHAP): Every inference pass computes local feature attribution vectors in under 3.5 ms, rendering a horizontal divergence waterfall HUD that clearly explains why risk shifted (e.g., Regional Wall Motion Abnormalities, ST elevations, or Ejection Fraction depressions).
- Live Reactive Telemetry Drawer: Modifying patient vitals or ECG parameters triggers debounced (250 ms) re-scoring loops, updating probabilities, 3D shader uniforms, and floating Drei callout tags in real time.
How I built it
I designed Perfusion3D with a decoupled, containerized monorepo architecture:
1. Data Pipeline & Zero-Leakage Architecture
Trained on the UCI Extension of Z-Alizadeh Sani Dataset (N = 303 records, 54 attributes). To eliminate data leakage, I implemented a custom StrictFeatureFilter transformer that excludes invasive catheterization (Cath) and target ground-truth labels from the feature matrix before imputation or scaling:
$$\mathcal{T} = {\text{'CAD'}, \text{'LAD'}, \text{'LCX'}, \text{'RCA'}}$$ $$\mathcal{P} = {\text{'Cath'}, \text{'catheterization'}, \text{'stenosis_status'}}$$ $$\mathcal{X} = \mathcal{U} \setminus (\mathcal{T} \cup \mathcal{P})$$
Preprocessing applies median imputation and RobustScaler fit exclusively within training folds to prevent distribution skew.
2. Multi-Model Ensemble Benchmarking & Calibration
I conducted 5-fold repeated cross-validation across Classical ML, Gradient Boosters (LightGBM, XGBoost, CatBoost), Bagging ensembles, and Soft-Voting models:
- CAD Classifier:
RandomForest-120(balanced subsample) — ROC-AUC: 0.927 ± 0.037, Sensitivity: 94.4%, Brier Score: 0.097. - LAD Classifier:
RandomForest-120— ROC-AUC: 0.851 ± 0.048, Sensitivity: 91.5%, Brier Score: 0.152. - LCX Classifier:
RandomForest-120— ROC-AUC: 0.727 ± 0.067, Sensitivity: 91.6%, Brier Score: 0.208. - RCA Classifier:
SoftVoting (LGBM + XGBoost + RF)— ROC-AUC: 0.745 ± 0.059, Sensitivity: 89.5%, Brier Score: 0.202.
Probabilities are calibrated using isotonic regression to minimize Brier scores, ensuring continuous color transitions rather than saturated binary margins.
3. 3D WebGL Graphics & Spatial Telemetry
- Frontend: React 19, TypeScript, React Three Fiber (
@react-three/fiber), Three.js,@react-three/drei, Tailwind CSS, and Zustand. - Anatomical Alignment: Integrated high-fidelity cardiac mesh geometry with native epicardial sulcus conduits (
vessel_LAD,vessel_LCX,vessel_RCA) and interactive Drei<Html>floating billboard badges. - De-Snapped Camera Rig: Smooth cubic camera lerping to arterial centroids that automatically decouples during manual orbit/pan gestures.
4. High-Throughput Inference Backend
- Built on Python 3.11 and FastAPI with strict Pydantic v2 validation contracts, structured JSON logging, and containerized Docker orchestration deployed on Render.
Challenges I ran into
- Target Leakage in Tabular Clinical Data: Retaining proxy columns from catheterization or angiography reports can artificially inflate accuracy. I designed automated adversarial unit tests (
pytest apps/api/tests/test_leakage.py) that deliberately inject forbidden features, verifying that the pipeline throws immediate validation exceptions. - Sub-4ms Real-Time Explainability: Standard SHAP kernel estimations are computationally heavy. I compiled pre-indexed
shap.TreeExplainerinstances directly in memory during application startup lifespan events, reducing local feature attribution latency to under 3.5 ms per vessel pass. - Anatomical Conduit Alignment in WebGL: Procedural meshes often produce torn topology or unrealistic shapes. I replaced synthetic geometry with an optimized medical GLB asset segmented via
@gltf-transform, ensuring smooth tubular conduits along the epicardial sulci without surface clipping or frame drops on integrated GPUs. - Preset Differentiation vs. Uniform Coloring: Initial clinical presets caused all vessels to shift colors simultaneously. I recalibrated test fixtures to represent localized vascular distributions (e.g., isolated LAD anterior infarct displaying Crimson LAD alongside Emerald LCX/RCA).
Accomplishments that I'm proud of
- Clinical-Grade Sensitivity: Achieved over 91% sensitivity across critical primary targets (94.4% for CAD, 91.5% for LAD), prioritizing the prevention of missed anterior ischemic events.
- Sub-4ms High-Throughput XAI Pipeline: Delivered localized TreeSHAP waterfall charts with sub-4ms execution times, enabling live explainability updates alongside interactive 3D rendering.
- Seamless WebGL Spatial HUD: Built a cohesive dark glassmorphic medical telemetry interface featuring decoupled orbit controls, dynamic 3D callout badges, and responsive shader feedback.
- Zero-Leakage Assurance: Maintained complete separation of training features from catheterization targets through custom transformers and passing test suites.
What I learned
- Clinical Objectives Dictate ML Thresholds: In cardiovascular decision support, maximizing overall accuracy is secondary to Sensitivity (Recall). Missing an anterior myocardial infarction carries fatal risks; tuning my optimal decision thresholds to prioritize over 90% sensitivity was essential for clinical relevance.
- Probabilistic Calibration is Essential for WebGL: Raw model margins jump abruptly between extremes. Isotonic calibration is necessary to achieve smooth, visually meaningful color gradients across 3D shader uniforms.
- Spatial Framing Transforms Diagnostic Telemetry: Translating abstract numbers into localized anatomical geometry and real-time TreeSHAP attributions makes predictive modeling immediately interpretable for both specialists and non-experts.
What's next for Perfusion3D: Spatial Coronary Ischemia Tool
- DICOM / CT-Angiography Ingestion: Expanding from tabular data to direct ingestion of patient-specific volumetric coronary CT scans for automated 3D mesh reconstruction.
- Hemodynamic Fractional Flow Reserve (FFR) Physics: Coupling ML stenosis probabilities with lattice Boltzmann fluid dynamics simulations to model blood pressure drops across lesions.
- SaMD Class IIa Validation Trials: Advancing from research prototype status toward prospective multi-center clinical validation adhering to FDA/CE SaMD guidelines.
Built With
- cardiology
- docker
- drei
- fastapi
- gltf
- lightgbm
- machine-learning
- pydantic
- python
- react-three-fiber
- react.js
- render
- scikit-learn
- shap
- tailwind-css
- three.js
- typescript
- vite
- webgl
- xgboost
- zustand
Log in or sign up for Devpost to join the conversation.