Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

35 Commits

Folders and files

Repository files navigation

CardioSim Lab

Interactive cardiac electrophysiology and 12-lead ECG simulator. One causal simulation links cell action potentials, spatial activation of an idealised heart and a forward-computed 12-lead ECG on a single clock. Change a parameter, and the ECG changes because the simulated electrophysiology changed.

CardioSim Lab in action: activation spreading through the heart, the heart vector projected onto leads II and aVR, a premature ventricular complex, and normal conduction compared with left bundle branch block

28-second preview, recorded from the running app: normal activation → lead vectors → premature ventricular complex → normal vs LBBB (A/B view).
Watch the full narrated demo (4 min 21 s, MP4, 1080p, 21 MB)

Research education and concept demonstration only. This is not a clinically validated diagnostic system or a patient-specific prediction tool, and it does not predict clinical drug effects.

Quick start

Option A — no installation

Double-click CardioSim-standalone.html and open it in a recent Chrome, Edge or Firefox. Everything is inside that one file. Without internet the fonts fall back to system fonts; nothing else changes.

Option B — development version (Windows, macOS, Linux)

Requires Node.js 20.19+ or 22.12+ (https://nodejs.org).

cd D:\ECG\cardiosim-lab
npm install
npm run dev          # opens http://localhost:5173
Command What it does
npm run dev Development server with hot reload
npm run build Type-check and build a static site in dist/ (serve with npm run preview)
npm run build:standalone Build one self-contained HTML file in dist-standalone/index.html
npm test 104 physiology / scenario / ionic / ECG unit tests (Vitest, about 5 min)
npm run test:e2e 21 browser tests (Playwright). First time: npx playwright install chromium
npm run validate Prints a baseline report: ECG-measured intervals vs model timings vs references

Using the app

Four modes (top bar):

Mode Contents
Simulator A · Anatomy & activation: smooth 3-D heart with toggleable layers (anatomy, major conduction pathways, activation, repolarisation, refractoriness, vectors, tissue mesh), presets for anterior, posterior, left-lateral and superior views, and click-to-select. Great vessels are shown for orientation only. B · Action potentials: reduced-order APs for selected cells. C · 12-lead ECG: 3×4 + rhythm strip (6×2 on narrow screens) with standard, right-sided (V3R–V6R) or posterior (V7–V9) chest leads, or any selection of the 19 leads; calipers, Inspect and SVG/PNG/CSV export; measurements next to model truth; a causal event log (click an event to highlight the structure and read what it means). D · Controls: Scenarios (registry with implementation status), Parameters, Explain, Lessons, Ionic cell (TP06), Validation, A/B and About.
Leads & Vectors Torso with RA/LA/LL/RL and V1–V6 electrodes; lead axes (solid = positive half), wiring to the Wilson central terminal, projection bar, optional lead-field proximity map; hexaxial frontal plane with QRS loop and measured axis; horizontal plane with the effective chest-lead vector and its R². Compare up to three leads. The Experiments menu runs A–F.
Split view Heart, torso, frontal vector, ECG strip, action potentials and the current electrical event, all on one clock.
A/B Two parameter sets simulated from t = 0 and animated side by side, with an ECG overlay at identical scaling and the list of differences.

Panels can be resized by dragging the dividers and maximised with ⤢ (Esc restores). Present switches to full-screen with larger type.

Keyboard. Space play/pause · ← → step 20 ms · [ ] previous/next beat.

Live changes. In live mode a parameter change takes effect at the current display time. The simulation is replayed deterministically up to that point and continues with the new value. Use restart to begin again at t = 0.

Save/Load. Scenarios are JSON files containing the full parameter set and sampling rate.

What is and is not simulated

Mechanistic or reduced-order and runnable Partial Not supported (labelled, not runnable)
Sinus rhythm and rate changes, sinus arrest, SA exit block, 1° AV block, Mobitz I and II, 2:1 and complete AV block with escape rhythms, PACs, PVCs (compensatory and interpolated), bigeminy, trigeminy, couplets (also on demand: Premature beats controls), focal AT, AVNRT, orthodromic and antidromic AVRT, pre-excitation, typical atrial flutter, atrial fibrillation, LBBB; RBBB (axis incomplete) Focal VT (automaticity imposed); IKr inhibition, short QT, Na⁺ and Ca²⁺ channel block via the TP06 ionic cell model mapped to tissue APD/CV; hyper-/hypokalaemia (TP06 + calibrated T/U shape); dofetilide, quinidine, verapamil calibrated to a human study; ischaemia and infarction for seven culprit lesions, through all five phases from hyperacute to old (ST patterns, Q waves, T inversion, right-sided and posterior leads); scar VT, polymorphic VT, VF, hyper-/hypocalcaemia, EAD/DAD, drug scenarios (partial); torsades (gated on the long-QT substrate, but the source is imposed rather than emergent — see SCIENTIFIC_LIMITATIONS.md and docs/MECHANISTIC_TDP_PROPOSAL.md) None since v1.2.0

The status of every scenario is in docs/scenario-registry.json; limitations are in SCIENTIFIC_LIMITATIONS.md. The details are in docs/FIDELITY_MATRIX.md. The baseline (default parameters, measured from the simulated ECG) is HR 66, PR 158 ms, QRS 88 ms, QT 370 ms, QTc 387 ms and QRS axis +18°; lead I R 0.73 mV and V2 S 1.6 mV (amplitudes recalibrated in v1.4.0, see SCIENTIFIC_LIMITATIONS.md); the model gives AH 65 ms and HV 41 ms.

Documentation

  • DEVELOPMENT_STATUS.md, IMPLEMENTATION_BACKLOG.md, SCIENTIFIC_LIMITATIONS.md, TEST_RESULTS.md, NEXT_SESSION.md
  • docs/scenario-registry.json: machine-readable scenario status (regenerate with npx tsx scripts/export-registry.ts)
  • docs/ARCHITECTURE.md: layered model, runtime architecture, folder/module structure
  • docs/FIDELITY_MATRIX.md: fidelity levels, output classes, limitations
  • docs/PARAMETER_DEPENDENCIES.md: causal graph, defaults with evidence tags, planned parameters
  • docs/ROADMAP.md: phased plan and next priorities
  • docs/VALIDATION.md: what the tests check
  • docs/REFERENCES.md: sources (with DOIs/PMIDs) and which values have none
  • docs/MECHANISTIC_TDP_PROPOSAL.md: staged design for a mechanistic (reaction–diffusion) torsades model

Licence

Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0). SPDX: CC-BY-NC-4.0. Full text in LICENSE; scope and exclusions in NOTICE.

You may copy, share, adapt and build on this work for non-commercial purposes, provided you credit the author, link to the licence and state what you changed. Commercial use requires separate permission.

Two things the licence does not reach. Third-party dependencies keep their own (permissive) licences, including in a standalone build, which inlines them. And published literature cited in docs/REFERENCES.md remains under its publishers' terms — the numerical values used for calibration are facts, but the papers are not covered by anything here.

Not a medical device and not for clinical use; see NOTICE and SCIENTIFIC_LIMITATIONS.md.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages