Abstract
The shape of the ECG depends on the lead positions but also on the distribution and dispersion of different cell types and their action potential (AP) durations and shapes. We present an interactive JavaScript program that allows fast simulations of the ECG by solving and displaying the dynamics of cardiac cells in tissue using a web browser. We use physiologically accurate ODE models of cardiac cells of different types including SA node, right and left atria, AV node, Purkinje, and right and left ventricular cells with dispersion that accounts for apex-to-base and epi-to-endo variations. The software allows for real-time variations for each cell type and their spatial range so as to identify how the shape of the ECG varies as a function of cell type, distribution, excitation duration and AP shape. The propagation of the wave is visualized in real time through all the regions as parameters are kept fixed or varied to modify ECG morphology. The code solves thousands of simulated cells in real time and is independent of operating system, so it can run on PCs, laptops, tablets and cellphones. This program can be used to teach students, fellows and the general public how and why lead positions and the different cell physiology in the heart affect the various features of the ECG.
1. Introduction
The heart contracts due to an electrical signal that for humans originates at the sinoatrial node and by diffusion propagates across the atrium to the atrioventricular node and finally to the ventricles via the His-Purkinje network. Therefore, every heartbeat is produced by an electrical wave that can be measured externally, as first demonstrated by Augustus Waller in 1887 with a mercury capillary electrometer that showed two deflections. Willem Einthoven at the beginning of the 20th century then showed the first detailed electrocardiogram (ECG) signal with the introduction of his string galvanometer. Because variations in the ECG signals are direct consequences of changes in the propagation of the electrical wave throughout the heart, cardiologists are able to use the ECG to diagnose and identify many conditions affecting the heart. The ECG is then an irreplaceable diagnostic method in clinical practice, with minimal costs and at the same time a fast, painless and noninvasive process. Therefore, teaching residents and nurses to interpret ECGs in order to identify variations associated with particular diseases, drug effects or genetic disorders is crucial, but it is also necessary to understand the cellular mechanism that leads to a particular ECG. The interpretation of ECGs is a highly complex topic that requires years of training and experience, and it has been shown that computer-aided programs to teach electrocardiography are superior to traditional methods alone[1, 2].
2. Other ECG Simulator Programs
A wide variety of programs have been designed to teach and increase understanding of the origins of the ECG, from an interactive ECG teaching system on the Macintosh computer [3] and WinHeart [4] in the early 1990s, to WebECG (in MATLAB) [5] in the 2010s. With the increase in computer power, several other programs with 3D visualization and real-time interactivity have been developed over the years, such as ECGSIM [6], among others [7-9]. For the study of the ECG formation, several groups have used simplified models to reproduce ECG morphology [10-13]. However, other groups have developed high-performance computer codes that solve the dynamics across scales from the cell to the whole heart, by solving in detail the dispersion in cell dynamics across the heart in order to compute and reproduce the ECG signals obtained from the different leads in the body [14-17]. In this work we present a simplified 1D domain [13, 18] that accounts for all the cells across the heart that are responsible of the generation of the ECG. The action potentials are generated by a minimal model [19] that reproduces the action potential shapes and durations of cardiac cells. The program thus allow easy visualization and modification of the cells along the cable to analyze how the ECG morphology changes as a function of the different regions of cells and their physiology.
3. Activation Sequence of the Normal ECG
The activation of the heart follows the activation sequence shown in Figures 1-2. The first activation originates with the sino-atrial node excitation that propagates by diffusion to the atria and then to the AV node; from there, it spreads to the ventricles by the Purkinje network, shown in black. There still remains some controversy regarding which gradient of APD in the ventricles is the dominant cause for the deflection of the T wave, the transamural dispersion between epicardium, midmiocardium and endocardium cells (Figure 3) or the apex-to-base dispersion.
Figure 1.
Activation sequence that leads to the ECG. The different cell types sequentially activated are shown in an open canine heart that includes the atrium, ventricles and Purkinje network obtained by staining the tissue with Lugol’s solution and then drawn superimposed on the surface.
Figure 2.
Activation sequence as in Figure 1, here visualized on a slice of human heart MRI to further visualize where the different types of cells are located. Compared to Figure 1, where the gradient in APD is from epicardium to endocardium, here the gradient is given as a dispersion from apex to base.
Figure 3.
Pseudo-ECG QRS-T section produced by the dispersion along the thickness of the tissue, where APDEndo < APDEpi << APDM leads to the T wave being positive instead of negative.
4. Numerical Methods
We solve the propagation of the electrical wave across different cell types in the 1D domain by solving the reaction-diffusion equations
| (1) |
| (2) |
where Vm is the membrane voltage, si are the gating variables that control the various transmembrane currents Ii, Cm = 1μF is the membrane capacitance and D = 0.001cm/ms2 is the diffusion coefficient. We integrate the equations using finite differences with dt = 0.01ms and dx = 100μm in a JavaScript program. Parameters for the different cell types are given in Refs. [19, 20]. To avoid any boundary-condition effects when calculating the ECG, we use a phase-field approach [21] to implement the zero-flux boundary conditions (conservation of charge). Then a pseudo-ECG ϕ(r) at a particular reference point (r) is calculated by integrating over all the dipoles generated by Vm as it propagates across the 1D tissue using the following equation:
| (3) |
5. Results
The JS-ECG code presented here simulates the activation sequence of the heart in a 1D cable by clicking the Start/Pause button. The activation sequence starts with SA node cells that self-activate and propagate an electrical wave to atrial cells and eventually to ventricular cells, going through endocardial, M and epicardial cells. The size distribution of these regions can be dynamically changed to investigate the effect on the ECG waveform. With the initial distribution of cell types along the 1D cable, it is easy to visualize (Figure 4) the voltage signal for each cell in the space-time plot (Figure 4, bottom) as the wave propagates along the cable. At the same time, the top panel of Figure 4 shows the ECG calculated using Equation 3 for a position r = rX given by the electrode position value entered in menu. Moving the position changes the shape and amplitude of the ECG (emulating the transition from electrode V1 to V6); therefore it is necessary to change the y-axis of this window in the menu. The tissue parameters can be modified and take effect when clicking the Update Parameter button.
Figure 4.
Image from JS-ECG that displays the pseudo-ECG in time in the top panel and the action potentials for each type of cell with different colors in the lower panel. The menu allows the user to modify the size of the domains for each section in the tissue interactively to investigate changes in the pseudo-ECG.
A third window shows the electrical wave propagating along the 1D cable (see examples in Figure 5). As the wave propagates, changes in the voltage profile can be observed due to the different cell types. By observing all three panels (the pseudo-ECG and action potential panels as in Fig. 4 and the wave profile panel as in Fig. 5), it can be seen that the P wave is created by the SA node and atrial activation, then the QRS is produced by the depolarizing wave front propagating along the cable and the T wave by the depolarization wave back. The propagating wave panel (examples shown in Fig. 5) depictes the wave front exciting all the cells sequentially, while the wave back has a more complex repolarization pattern where the M cells depolarize last, causing the T wave to be a positive deflection. If all cells in the ventricles were the same, the T wave would be inverted.
Figure 5.
The JavaScript code also displays the voltage wave as it propagates along the cable. The four frames indicate the propagation of the wave front and the complex repolarization of the wave back (see text).
6. Conclusions and Future Work
JS-ECG is a program that simulates in detail the different cell types in the hearts and reproduces a normal ECG signal. Parameters in the model can be modified to observe different dynamics, for example by accelerating the activation of the SA node; the period of activation can increase and show arrhythmic effects in the ECG such as T-wave alternans [22] and QRS alternans [23]. Interesting simulations include investigations of the shapes and durations of the QRS and T waves, different types of long QT, and the dynamics of concordant and discordant alternans in tissue and their effect on T-wave and QRS-alternans. Effects of temperature as well as drugs blocking or enhancing certain ion channels also can be simulated in all cell types and their effects on the ECGs can be quantified. JS-ECG is evolving and we expect to add more functionality, including 2D simulations, and to accelerate it using WebGL[24].
Acknowledgments
This study was supported in part by the National Science Foundation grants NSF-FDA-2037894 (FHF,AK), NSF-REU1852519 (JRO,FHF), CMMI-2011280 (EMC) and CMMI-1762553 (FHF) and by the National Institutes of Health grant 1R01HL143450-01 (EMC and FHF)
References
- [1].Patuwo T, Wagner G, Ajijola O. Comparison of teaching basic electrocardiographic concepts with and without ECGSIM, an interactive program for electrocardiography. In 2007 Computers in Cardiology. IEEE, 2007; 61–64. [Google Scholar]
- [2].Granero-Molina J, Fernández-Sola C, López-Domene E, Hernández-Padilla JM, Preto LSR, Castro-Sánchez AM. Effects of web-based electrocardiography simulation on strategies and learning styles. Revista da Escola de Enfermagem da USP 2015;49:0650–0656. [DOI] [PubMed] [Google Scholar]
- [3].Garber G, Fogel R, Berman J, Podrid P. Interactive ECG teaching system on the macintosh computer. Journal of the American College of Cardiology 1991;17(2S1):A10–A10. [Google Scholar]
- [4].Novosel D Winheart [R]-a computer program for studying the interpretation of electrocardiograms and ECG knowledge evaluation. Croatia Medical Journal 1996;37:288–293. [Google Scholar]
- [5].Güney E, Ekşi Z, Çakıroğlu M WebECG: A novel ECG simulator based on MATLAB web figure. Advances in Engineering Software 2012;45(1):167–174. [Google Scholar]
- [6].Van Dam PM, Oostendorp TF, Van Oosterom A. ECGSIM: interactive simulation of the ecg for teaching and research purposes. In 2010 Computing in Cardiology. IEEE, 2010;841–844. [Google Scholar]
- [7].Ryan J, O’Sullivan C, Bell C, Mooney R. A virtual reality electrocardiography teaching tool. In Proceedings of the Second International Conference, Biomedical Engineering, Innsbruck. 2004; 250–253. [Google Scholar]
- [8].Ryan J, O’Sullivan C, Bell C. Real-time interactive volumetric animation of the heart’s electrical cycle from automatically synchronized ECG. Computer Animation and Virtual Worlds 2004;15(3-4):353–360. [Google Scholar]
- [9].Sochocka A, Kawa T, Płaneta R. Visualization and simulation of the human heart based on ECG. Bio Algorithms and Med Systems 2013;9(3):141–146. [Google Scholar]
- [10].Ryzhii E, Ryzhii M. A heterogeneous coupled oscillator model for simulation of ECG signals. Computer Methods and Programs in Biomedicine 2014;117(1):40–49. [DOI] [PubMed] [Google Scholar]
- [11].Das S, Maharatna K. Fractional dynamical model for the generation of ECG like signals from filtered coupled Vander Pol oscillators. Computer Methods and Programs in Biomedicine 2013;112(3):490–507. [DOI] [PubMed] [Google Scholar]
- [12].Gois SR, Savi MA. An analysis of heart rhythm dynamics using a three-coupled oscillator model. Chaos Solitons Fractals 2009;41(5):2553–2565. [Google Scholar]
- [13].Jiang Z, Pajic M, Connolly A, Dixit S, Mangharam R. Real-time heart model for implantable cardiac device validation and verification. In 2010 22nd Euromicro Conference on Real-Time Systems. IEEE, 2010; 239–248. [Google Scholar]
- [14].Clayton RH, Holden AV. Computational framework for simulating the mechanisms and ECG of re-entrant ventricular fibrillation. Physiological Measurement 2002; 23(4):707. [DOI] [PubMed] [Google Scholar]
- [15].Lyon A, Bueno-Orovio A, Zacur E, Ariga R, Grau V, Neubauer S, Watkins H, Rodriguez B, Minchole A. Electrocardiogram phenotypes in hypertrophic cardiomyopathy caused by distinct mechanisms: apico-basal repolarization gradients vs. Purkinje-myocardial coupling abnormalities. EP Europace 2018;20(suppl_3):iii102–iii112. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [16].Keller DU, Seemann G, Weiss DL, Farina D, Zehelein J, Dossel O. Computer based modeling of the congenital long-qt 2 syndrome in the visible man torso: From genes to ECG. In 2007 29th Annual International Conference of the IEEE Engineering in Medicine and Biology Society. IEEE, 2007; 1410–1413. [DOI] [PubMed] [Google Scholar]
- [17].Sovilj S, Magjarević R, Lovell NH, Dokos S. A simplified 3d model of whole heart electrical activity and 12-lead ECG generation. Computational and Mathematical Methods in Medicine 2013;2013. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [18].Huang S, Diep M, Jang K, Cherry EM, Fenton FH, Cleaveland R, Lindvall M, Mangharam R, Porter A. Towards automated comprehension and alignment of cardiac models at the system invariant level. In CSBio’20: Proceedings of the Eleventh International Conference on Computational Systems-Biology and Bioinformatics. 2020; 18–28. [Google Scholar]
- [19].Bueno-Orovio A, Cherry EM, Fenton FH. Minimal model for human ventricular action potentials in tissue. Journal of Theoretical Biology 2008;253(3):544–560. [DOI] [PubMed] [Google Scholar]
- [20].Lombardo DM, Fenton FH, Narayan SM, Rappel WJ. Comparison of detailed and simplified models of human atrial myocytes to recapitulate patient specific properties. PLoS Computational Biology 2016;12(8):e1005060. [DOI] [PMC free article] [PubMed] [Google Scholar]
- [21].Fenton FH, Cherry EM, Karma A, Rappel WJ. Modeling wave propagation in realistic heart geometries using the phase-field method. Chaos An Interdisciplinary Journal of Nonlinear Science 2005;15(1):013502. [DOI] [PubMed] [Google Scholar]
- [22].Pastore JM, Girouard SD, Laurita KR, Akar FG, Rosenbaum DS. Mechanism linking T-wave alternans to the genesis of cardiac fibrillation. Circulation 1999;99(10):1385–1394. [DOI] [PubMed] [Google Scholar]
- [23].Chen DD, Gray RA, Uzelac I, Herndon C, Fenton FH. Mechanism for amplitude alternans in electrocardiograms and the initiation of spatiotemporal chaos. Physical Review Letters 2017;118(16):168101. [DOI] [PubMed] [Google Scholar]
- [24].Kaboudian A, Cherry EM, Fenton FH. Real-time interactive simulations of large-scale systems on personal computers and cell phones: Toward patient-specific heart modeling and other applications. Science Advances 2019; 5(3):eaav6019. [DOI] [PMC free article] [PubMed] [Google Scholar]





