For an exhaustive, production-grade technical breakdown of each subsystem, consult our dedicated architecture and engineering specifications in the docs/ directory:
| Document | Technical Scope & Topics Covered |
|---|---|
| docs/ARCHITECTURE.md | System Topology & Runtime Dataflow: Decoupled FastAPI + React 18 topology, sub-80ms async inference pipeline, Pydantic data contracts, and component lifecycle benchmarks. |
| docs/MACHINE_LEARNING.md |
Predictive AI Core & Anti-Leakage Protocol: UCI Z-Alizadeh Sani cohort (Cath, LAD, LCX, RCA), 4x tuned XGBoost classifiers, 5-fold cross-validation (84.9% holdout / 91.4% CV ROC-AUC), and exact TreeSHAP game-theoretic mathematics. |
| docs/3D_VISUALIZATION.md |
WebGL Biomechanical Graphics: Three.js / React Three Fiber rendering, procedural Catmull-Rom cubic splines & TubeGeometry for coronary trees (LMCA, LAD, LCX, RCA, D1, D2, OM1, AM, PDA), harmonic Wiggers cardiac cycle simulation, multi-spectral CT windowing shaders, and 3D virtual stent meshes. |
| docs/CLINICAL_DECISION_SUPPORT.md | Cardiovascular Decision Support: Society of Cardiovascular Computed Tomography (SCCT) CAD-RADS™ 2.0 classification tree, What-If GDMT counterfactual simulator (ARR & NNT), fluid hemodynamic CT-FFR estimation, real-time Lead II ECG waveform morphology sync, and ACC/AHA consultation EHR export. |
┌──────────────────────────────────────────────────────────────────────────────────┐
│ PulsePlex Architecture │
└──────────────────────────────────────────────────────────────────────────────────┘
[ Clinical Inputs & Patient Sliders ]
(Demographics, Vitals, ECG, Echo, Lab Markers)
│
▼
┌───────────────────────────────┐
│ FastAPI ML Backend (:8000) │
└───────────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
[ 4x XGBoost Models ] [ SHAP TreeExplainer ]
- Overall CAD Status - Local feature attribution
- LAD Stenosis (>50%) - Positive risk drivers
- LCX Stenosis (>50%) - Negative protective factors
- RCA Stenosis (>50%)
│ │
└───────────────┬───────────────┘
│ JSON Payload (Probabilities, Attributions, Colors)
▼
┌───────────────────────────────┐
│ React + Vite Frontend │
│ (:5173) │
└───────────────────────────────┘
│
┌──────────────┴──────────────┐
▼ ▼
[ React Three Fiber 3D Scene ] [ Clinical Dashboard UI ]
- Anatomical ventricular base - Overall CAD probability gauge
- Dynamic coronary artery tubes - Multi-vessel involvement badge
• LAD: Anterior wall - Diverging SHAP waterfall chart
• LCX: Lateral/posterior - Empirical validation metrics table
• RCA: Inferior/acute margin - Regulatory safety disclaimer
- Color interpolation:
• Green (<30% Low Risk)
• Yellow (30-60% Moderate)
• Red (>60% High Risk)
- Raycasting hover/click tooltips
- Anatomical camera view controls
In accordance with clinical protocol and ML validation standards on the UCI Z-Alizadeh Sani Extended Dataset (303 records, 59 attributes):
- EXCLUDED FROM INPUT FEATURES:
Cath,LAD,LCX, andRCA. - In angiography,
Cathrepresents the post-catheterization diagnosis andLAD,LCX,RCArepresent post-catheterization vessel-level diameter narrowing. Including any of these variables in the input matrix causes target leakage. - Input feature vectors consist purely of non-invasive pre-catheterization diagnostic inputs (55 clinical variables + one-hot encodings = 60 feature matrix).
Models were trained using stratified splits (80/20 train/test) and evaluated with 5-fold stratified cross-validation on the Z-Alizadeh Sani dataset:
| Target Endpoint | Task Type | Accuracy | Precision | Recall | F1-Score | ROC-AUC | 5-Fold CV ROC | Positive Class Ratio |
|---|---|---|---|---|---|---|---|---|
| Overall CAD Status | Binary (Cath CAD vs Normal) |
83.61% | 85.11% | 93.02% | 0.8889 | 0.8488 | 0.9137 | 71.29% |
| LAD Stenosis (>50%) | Left Anterior Descending Artery | 75.41% | 78.38% | 80.56% | 0.7945 | 0.8289 | 0.8430 | 58.42% |
| LCX Stenosis (>50%) | Left Circumflex Artery | 67.21% | 61.11% | 45.83% | 0.5238 | 0.7568 | 0.7271 | 39.27% |
| RCA Stenosis (>50%) | Right Coronary Artery | 75.41% | 78.57% | 47.83% | 0.5946 | 0.7666 | 0.7223 | 37.62% |
All metrics are automatically logged and serialized to backend/models/metrics.json.
For each patient assessment, shap.TreeExplainer computes exact local Shapley values
Where:
-
$\phi_0$ is the base expected value. - Positive
$\phi_i > 0$ denotes features escalating the risk of coronary stenosis (e.g. Typical Anginal Chest Pain, ST Depression, Low Ejection Fraction, Elevated LDL). - Negative
$\phi_i < 0$ denotes protective clinical factors dampening risk (e.g. High HDL, Preserved Ejection Fraction, Absence of Angina). - Features are mapped to descriptive clinical nomenclature and visualized via a responsive horizontal diverging bar chart.
The 3D cardiac viewer leverages React Three Fiber and Three.js to project predicted stenosis risks directly onto anatomical coronary trajectories:
- Vessel Trajectories & Geometry:
- LAD (Left Anterior Descending): Descends anteriorly from the aortic root along the interventricular groove to the apex.
- LCX (Left Circumflex): Traverses the left atrioventricular groove posterolaterally around the obtuse margin.
- RCA (Right Coronary Artery): Encircles the right atrioventricular sulcus towards the inferior crux and posterior descending artery.
- Dynamic Risk Color Coding:
- Low Risk (<30%):
#22c55e(Emerald Green) - Moderate Risk (30% - 60%):
#eab308(Amber Yellow) - High Risk (>60%):
#ef4444(Vibrant Red)
- Low Risk (<30%):
- Pulsatile Feedback & Stenosis Warnings:
- Realistic dual-pulse cardiac cycle animation (systolic contraction and diastolic relaxation).
- High-risk / stenotic vessels display an emissive glow and pulsating warning wireframe halos.
- Camera Controls & Raycasting:
- Anatomical view buttons: Anterior (LAD), Lateral (LCX), Right/Inferior (RCA), and Reset Camera.
- Raycasting hover & click events on vessel landmark nodes trigger floating HTML risk inspection cards with anatomical territory descriptions.
PulsePlex introduces five clinical decision-support and interventional innovations that set it apart from standard risk calculators:
-
"What-If" Counterfactual Intervention Simulator (Clinical Actionability):
- Allows clinicians to simulate Guideline-Directed Medical Therapy (GDMT) in real time (e.g. High-Intensity Statin Therapy, Antihypertensive Optimization to SBP $\le 118$ mmHg, Smoking Cessation Protocol, GLP-1 RA Weight Management).
- Instantaneously projects post-intervention risk reductions, computes Number Needed to Treat (NNT), and dynamically switches the 3D heart vessel colors from ischemic red to patent green.
-
Virtual PCI & Drug-Eluting Stent (DES) Deployment in 3D:
- In the Plaque Inspector cross-section, clinicians can simulate balloon angioplasty and coronary stenting.
- Restores Minimal Lumen Diameter (MLD) and Area (MLA), drops stenosis from
$>80%$ to$<10%$ residual, and elevates hemodynamic FFR from an ischemic$\le 0.65$ to$0.96$ . - Renders a 3D platinum-chromium wireframe stent mesh on the coronary artery trajectory in the Three.js viewport.
-
Multimodal Clinical Consultation Report & EHR Export:
- Generates a clinical consultation note formatted according to ACC/AHA guidelines.
- Incorporates patient vitals, 12-lead ECG changes, SCCT CAD-RADS™ 2.0 classifications, SHAP mechanistic attributions, and GDMT recommendations.
- Includes one-click copy to clipboard for hospital EHRs and a printable PDF stylesheet (
window.print()).
-
Dynamic Ischemic 12-Lead ECG Morphology Sync:
- Real-time Lead II canvas waveform dynamically morphs its P-Q-R-S-T morphology based on the patient's actual clinical profile:
- ST-segment depression (subendocardial ischemia)
- ST-segment elevation (transmural injury / STEMI)
- T-wave inversion & pathological Q-waves
- Heart rate-dependent sweep velocity.
- Real-time Lead II canvas waveform dynamically morphs its P-Q-R-S-T morphology based on the patient's actual clinical profile:
-
SCCT CAD-RADS™ 2.0 & CCTA Plaque Phenotyping:
- Translates raw predictions into recognized clinical grades (CAD-RADS 0 through 5/V).
- Breaks down atheroma volume, soft lipid core attenuation (
$<30-50$ HU), and dense calcium deposits ($>900$ HU).
pulseplex/
├── docs/ # In-depth technical engineering documentation
│ ├── ARCHITECTURE.md # System topology, micro-service dataflow & benchmarks
│ ├── MACHINE_LEARNING.md # Anti-leakage protocol, 4x XGBoost, CV & TreeSHAP
│ ├── 3D_VISUALIZATION.md # Three.js splines, Wiggers cardiac cycle & 3D stenting
│ └── CLINICAL_DECISION_SUPPORT.md # CAD-RADS 2.0, What-If GDMT, CT-FFR & EHR consultation
├── backend/
│ ├── data/
│ │ ├── z_alizadeh_sani_extended.xlsx # Original UCI/Mendeley dataset
│ │ └── z_alizadeh_sani_extended.csv # 303 records, 59 attributes
│ ├── models/
│ │ ├── cad_model.pkl # Trained XGBoost model for CAD
│ │ ├── lad_model.pkl # Trained model for LAD Stenosis
│ │ ├── lcx_model.pkl # Trained model for LCX Stenosis
│ │ ├── rca_model.pkl # Trained model for RCA Stenosis
│ │ ├── preprocessor.pkl # Fitted clinical data preprocessor
│ │ └── metrics.json # Out-of-sample & 5-fold CV metrics
│ ├── pipeline/
│ │ ├── preprocess.py # Feature engineering & leakage prevention
│ │ ├── train.py # Multi-target training & evaluation
│ │ ├── explain.py # SHAP TreeExplainer attribution engine
│ │ └── generate_glb.py # Standalone GLTF/GLB heart generator
│ ├── main.py # FastAPI server & endpoints
│ └── requirements.txt
├── frontend/
│ ├── public/
│ │ └── models/
│ │ └── heart.glb # Binary GLTF heart mesh
│ ├── src/
│ │ ├── components/
│ │ │ ├── Canvas3D.tsx # Three.js / R3F WebGL viewport
│ │ │ ├── HeartMesh.tsx # Procedural cardiac mesh, vessel tubes & 3D stent models
│ │ │ ├── Dashboard.tsx # Risk gauges, metrics & SHAP charts
│ │ │ ├── InputForm.tsx # Interactive sliders, tabs & presets
│ │ │ ├── InterventionSimulator.tsx # What-If GDMT & lifestyle counterfactual engine
│ │ │ ├── PlaqueCutawayModal.tsx # CCTA plaque morphology & virtual PCI stent simulator
│ │ │ ├── ClinicalReportModal.tsx # ACC/AHA clinical consultation note & EHR export
│ │ │ └── ECGMonitor.tsx # Synced real-time Lead II ECG waveform generator
│ │ ├── services/
│ │ │ └── api.ts # Type-safe API client for backend
│ │ ├── App.tsx # Main layout & disclaimer footer
│ │ ├── main.tsx # React root
│ │ └── index.css # Tailwind CSS styles
│ ├── package.json
│ ├── tsconfig.json
│ ├── tailwind.config.js
│ └── vite.config.ts
└── README.md
- Python: 3.10 or higher
- Node.js: v18 or higher (Node v20+ recommended)
- Git (optional)
-
Open a terminal and navigate to the
backend/directory:cd backend -
(Optional) Create and activate a Python virtual environment:
python -m venv venv # On Windows: venv\Scripts\activate # On Linux/macOS: source venv/bin/activate
-
Install required Python packages:
pip install -r requirements.txt
-
(Optional) Re-run model training and metrics logging:
python pipeline/train.py
-
Launch the FastAPI backend server:
python -m uvicorn main:app --host 127.0.0.1 --port 8000 --reload
-
Verify that the backend is running:
- Health check: http://127.0.0.1:8000/health
- Interactive Swagger API Docs: http://127.0.0.1:8000/docs
- Model Metrics: http://127.0.0.1:8000/metrics
-
Open a second terminal and navigate to the
frontend/directory:cd frontend -
Install npm dependencies:
npm install
-
Start the Vite development server:
npm run dev
-
Open your browser and navigate to:
http://localhost:5173/
| Method | Endpoint | Description | Sample Output |
|---|---|---|---|
GET |
/health |
Server status, loaded models, tracked arteries | {"status": "healthy", "models_loaded": ["CAD", "LAD", "LCX", "RCA"]} |
GET |
/metrics |
Validation metrics (Accuracy, F1, ROC-AUC) for all 4 models | {"CAD": {"accuracy": 0.8361, "roc_auc": 0.8488, ...}} |
GET |
/sample-patients |
Pre-configured authentic clinical profiles (Low Risk, Single LAD, Triple Vessel) | [{"id": "sample-single-lad", "name": "...", "data": {...}}] |
POST |
/predict |
Ingests patient features; outputs probabilities, colors, SHAP attributions | {"cad_status": "CAD", "vessels": {"LAD": {"probability": 0.98, ...}}, ...} |
Caution
Notice: Predictions and visualizations generated by this system are strictly for educational and decision-support purposes only. They do not replace formal diagnostic imaging (coronary computed tomography angiography, invasive coronary angiography) or clinical evaluations conducted by licensed medical practitioners.