ALL Metrics
-
Views
-
Downloads
Get PDF
Get XML
Cite
Export
Track
Software Tool Article

ECGSim-Advanced: An Open-Source Interactive Simulator for Teaching Electrolyte, Conduction, and Repolarization Abnormalities in Electrocardiography

[version 1; peer review: awaiting peer review]
PUBLISHED 12 May 2026
Author details Author details
OPEN PEER REVIEW
REVIEWER STATUS AWAITING PEER REVIEW

Abstract

Background

Interpreting electrocardiogram (ECG) changes associated with electrolyte disturbances, atrioventricular (AV) conduction blocks, and hereditary or acquired QT syndromes is a critical skill in clinical medicine. Interactive simulation tools can greatly aid in understanding these complex ECG manifestations. We present ECGSim-Advanced, an R Shiny application designed for dynamic simulation of these specific conditions, providing a focused educational experience.

Methods

ECGSim-Advanced is developed in R using the Shiny framework for its interactive user interface and `ggplot2` for ECG visualization. The application mathematically generates ECG waveforms (P, QRS, T, and U waves) using Gaussian functions. Users can select simulation modes for “Normal Sinus Rhythm,” “Electrolyte Imbalance (Potassium, Calcium),” “AV Blocks (1st Degree, 2nd Degree Mobitz I & II, 3rd Degree),” and “QT Syndromes (Long QT, Short QT).” Specific parameters for each condition (e.g. ST-segment/QT interval changes for calcium and QT syndromes) are modelled based on established electrocardiographic criteria.

Results

The application features a user-friendly interface allowing real-time manipulation of parameters such as heart rate, electrolyte levels (hypo−/hyper-kalaemia/calcaemia), AV block type, and target QTc interval. The generated ECG trace is displayed dynamically, mimicking standard ECG paper with adjustable speed and gain. On-screen callipers facilitate interval and amplitude measurements. The tool provides dynamically updated “Simulated Intervals/Info” and “Key ECG Findings & Educational Notes” relevant to the selected condition. An extensive library of clinical vignettes, each with case scenarios, questions, and detailed explanations, allows users to apply their knowledge and test interpretation skills.

Conclusion

ECGSim-Advanced serves as an accessible, open-source educational tool for medical students, trainees, and healthcare professionals to enhance their understanding of ECG manifestations in common and critical electrolyte, conduction, and repolarization disorders. Its interactive nature, focused simulation modes, and integrated clinical vignettes promote active learning and diagnostic reasoning. Therefore, this tool can enhance ECG literacy in cardiology training programs globally.

Keywords

ECG Simulator, R Shiny, Medical Education, Electrolyte Imbalance, Cardiology, Electrocardiography, Interactive Learning, Open Source Software

Introduction

The electrocardiogram (ECG) remains one of the most essential diagnostic tools in cardiovascular medicine, widely used for the detection and monitoring of cardiac arrhythmias, myocardial ischemia, electrolyte disturbances, and inherited channelopathies.1,2 Among its many clinical utilities, ECG interpretation plays a critical role in the early identification of life-threatening conditions such as hyperkalaemia, third-degree atrioventricular (AV) block, and Long QT Syndrome (LQTS).3,4,5 Despite its importance, proficiency in ECG interpretation remains a significant educational challenge for medical students and trainees, often due to the abstract and pattern-based nature of the skill, as well as the variability in teaching quality and clinical exposure.6,7

Traditional ECG education typically relies on static images in textbooks or lectures, which may insufficiently convey the dynamic nature of cardiac electrical activity.6 This passive form of learning often fails to address learners’ needs for active experimentation and immediate feedback, both of which are known to enhance retention and clinical reasoning.8,9,10 Furthermore, many conventional educational tools do not allow learners to manipulate physiologic parameters, such as electrolyte levels or heart rate, to observe their real-time impact on ECG morphology.11,12 This gap limits learners’ ability to develop a mechanistic understanding of ECG changes across different clinical contexts.10,12

Simulation-based learning has emerged as a powerful pedagogical approach in medical education, offering interactive, learner-centred environments where complex concepts can be explored safely and repeatedly.13,14 In particular, ECG simulation tools have demonstrated promise in improving diagnostic accuracy, promoting self-directed learning, and enhancing clinical confidence among trainees.15,16 However, many existing simulators are proprietary, limited in scope, or lack flexibility in reproducing a range of common and critical pathologies.

To address these limitations, we developed ECGSim-Advanced, an open-source, R Shiny-based interactive simulator tailored specifically to modelling the ECG manifestations of electrolyte disturbances (potassium and calcium), AV conduction abnormalities, and QT interval syndromes. ECGSim-Advanced allows users to dynamically manipulate relevant physiological parameters and observe the corresponding changes in ECG waveforms. The simulator is further enhanced by an integrated library of clinical vignettes, which bridge the gap between pattern recognition and clinical application by providing realistic scenarios, diagnostic questions, and guided explanations.

Methods

Implementation

ECGSim-Advanced is developed using the R programming language (version 4.5.1)17 and the Shiny web application framework (version 1.10.0)18 to create an interactive and browser-based user interface. Data transformation and internal logic are managed using the dplyr package (version 1.1.4),19 while ECG visualization is handled by ggplot2 (version 3.5.2).20 User-triggered events and dynamic UI behaviour are enabled using shinyjs (version 2.1.0.9011).21

ECG waveform generation

The simulator generates ECG signals through the summation of Gaussian-modelled waveform components. Each wave - P, Q, R, S, T, and U - is constructed using the generate_segment() function defined as:

Wave(t)=A·exp(0.5((tc)sigma)2)

Where A is the amplitude, t is time, c is the wave centre, and sigma is derived from the duration and shape of the wave.

Custom functions model each wave:

  • generate_p_wave_electrolyte(): Creates adjustable P waves.

  • generate_qrs_electrolyte(): Summates Q, R, and S waves with user-defined width and height.

  • generate_t_wave_electrolyte(): Produces T waves with controllable inversion and morphology.

  • generate_u_wave_electrolyte(): Adds U waves, especially for hypokalaemia.

Parameter translation and reactive logic

User input from the interface (e.g., selected mode, heart rate, QTc, electrolyte state) is converted into numeric waveform parameters via the current_ecg_params() function. These values are then passed to generated_ecg_trace() to create a beat-by-beat ECG signal over a standard time window.

Simulation modes

ECGSim-Advanced provides dedicated simulation modes for four pathological domains: electrolyte imbalance, AV conduction blocks, QT interval syndromes, and normal sinus rhythm. Within each mode, users can manipulate relevant parameters in real time - such as heart rate, QTc interval, potassium and calcium levels, or atrial and ventricular rates - to generate ECG waveforms reflecting pathophysiological changes. The electrolyte mode allows selection of hypokalaemia, hyperkalemia, hypocalcaemia, or hypercalcemia; the AV block mode includes first-, second- (Mobitz type I and II), and third-degree AV blocks; and the QT syndrome mode enables simulation of both Long and Short QT Syndromes. The waveform morphology dynamically responds to these inputs, with underlying Gaussian functions adjusted to reflect user-defined settings. A summary of available modes, user-controlled parameters, and key ECG features is shown in Table 1.

Table 1. Key features and simulation modes available in ECGSim-advanced.

Simulation modeKey parameters controlled by userPrimary ECG features simulated
Normal sinus rhythmHeart RateBaseline normal P-QRS-T morphology and intervals.
Electrolyte imbalanceElectrolyte (K+, Ca++), Level (Normal, Hypo-, Hyper-)K+: T-wave changes (peaking, flattening, inversion), U-waves, PR/QRS changes. Ca++: ST/QT changes.
AV blocksType (1st, 2nd Mobitz I/II, 3rd), Atrial Rate, Ventricular Escape Rate1st: Prolonged PR; 2nd: static dropped beats; 3rd: AV dissociation.
QT syndromesType (LQTS, SQTS), Target QTcProlonged or shortened QT interval, T-wave changes (broad T in LQTS, peaked T in SQTS).

User interface

The user interface of ECGSim-Advanced (see Figure 1) is composed of two primary components: a sidebar and a main display panel. The sidebar facilitates mode selection and provides adjustable controls, including sliders and dropdown menus, enabling users to modify simulation parameters dynamically. The main display panel features a real-time electrocardiogram (ECG) plot that updates in response to parameter adjustments. Additionally, it incorporates a calliper tool designed for precise measurement of intervals (dX) and amplitudes (dY). Dynamic text boxes are integrated to present updated interval values and educational summaries, enhancing the learning experience by providing immediate feedback and contextual information.

c729cf9c-3bea-49f2-b11f-182a9d02e3d8_figure1.gif

Figure 1. Screenshot of the ECGSim-advanced user interface.

The left sidebar enables selection of simulation mode (e.g., electrolyte imbalance, AV block, QT syndrome) and adjustment of key parameters, including heart rate (30–180 bpm), paper speed (25/50 mm/s), and ECG gain (0.5x–2x). The main panel displays a real-time ECG waveform on standard grid paper, which updates dynamically with parameter changes. Simulated interval measurements (PR, QRS, QT, QTc) are automatically calculated and shown below the controls. The caliper tool allows manual measurement of waveform intervals and amplitudes. Key ECG findings and educational notes are presented beneath the waveform, and a clinical vignette selection system is integrated at the bottom for case-based learning.

Clinical vignettes

An integrated vignette system provides real-world clinical scenarios. When a vignette is selected (e.g., “Post-Thyroidectomy Paraesthesias”), the application automatically loads corresponding simulation parameters (e.g., hypocalcemia), generates the relevant ECG trace, and provides a diagnostic prompt with explanation.

System Requirements and Launch Instructions

  • Software: R (version 4.0.0 or higher)

  • Packages: shiny, shinythemes, ggplot2, dplyr, shinyjs

  • Install: install.packages(c(“shiny”, “shinythemes”, “ggplot2”, “dplyr”, “shinyjs”))

Workflow

  • 1. Open RStudio and load the app. R file or navigate to the app directory.

  • 2. Run the application using the command: shiny::runApp(‘path/to/app_directory’) or click “Run App” in RStudio.

  • 3. The main interface loads with a sidebar and ECG panel.

  • 4. Select a simulation mode: “Normal Sinus Rhythm,” “Electrolyte Imbalance,” “AV Blocks,” or “QT Syndromes.”

  • 5. Adjust mode-specific parameters:

    • Electrolytes: Select potassium or calcium, and specify the level (e.g., hypokalemia).

    • AV Blocks: Choose block type and enter atrial and ventricular rates if applicable.

    • QT Syndromes: Choose syndrome type and set QTc value.

  • 6. Adjust global settings: heart rate, ECG paper speed, and gain.

  • 7. Observe ECG changes in real-time on the plot. Use the caliper to measure intervals.

  • 8. Select a clinical vignette if desired. The simulator will auto-adjust parameters and display the corresponding ECG.

  • 9. Click “Show Clues & Explanation” to reveal diagnosis and educational content.

Results

Interactive simulation output

The ECGSim-Advanced interface provides real-time feedback, displaying an ECG waveform that dynamically adjusts with any user input. The plot replicates standard ECG paper, with customizable paper speed (25 mm/s or 50 mm/s) and gain (0.5x, 1x, 2x). Calipers allow direct point-to-point measurements for both interval duration (dX) and voltage amplitude (dY). Below the waveform, live values for PR, QRS, QT, and QTc intervals are continuously updated.

Accuracy of pathological simulation

ECGSim-Advanced reliably reproduces hallmark ECG features under various pathological states. The application generates waveform changes consistent with established diagnostic criteria. In simulations of electrolyte imbalances, hypokalemia is represented with flattened or inverted T-waves, ST segment depression, and pronounced U-waves ( Figure 2A). For hyperkalemia, the application produces peaked T-waves, prolonged PR intervals, absent P-waves, and widened QRS complexes ( Figure 2B). Hypocalcaemia is simulated by producing ST segment lengthening and QT interval prolongation ( Figure 3A), while hypercalcemia leads to a shortened ST segment and abbreviated QT interval ( Figure 3B).

c729cf9c-3bea-49f2-b11f-182a9d02e3d8_figure2.gif

Figure 2. Potassium imbalance simulations.

(A) Hyperkalemia: Peaked T-waves, PR prolongation (240 ms), absent P-waves, and QRS widening (140 ms). (B) Hypokalemia: Flattened T-waves, ST segment depression (0.8 mm), and prominent U-waves. Simulations were generated at 75 bpm, 25 mm/s paper speed and 10 mm/mV (1x) ECG gain.

c729cf9c-3bea-49f2-b11f-182a9d02e3d8_figure3.gif

Figure 3. Calcium disturbance simulations.

(A) Hypercalcemia: Shortening of the QTc (313 ms) and ST segment (B) Hypocalcemia: ST segment lengthening and QTc prolongation (470 ms). Simulations were generated at 75 bpm, 25 mm/s paper speed and 10 mm/mV (1x) ECG gain.

The AV block mode encompasses first-, second-, and third-degree conduction disturbances. First-degree AV block is rendered as uniform prolongation of the PR interval with preserved atrioventricular conduction. Second-degree AV block is illustrated using static templates for both Mobitz type I (Wenckebach), defined by progressive PR interval prolongation culminating in a non-conducted P-wave, and Mobitz type II, which features fixed PR intervals with intermittent dropped QRS complexes. Third-degree (complete) AV block is simulated with dissociated atrial and ventricular rhythms, displaying distinct, fixed P and QRS rates ( Figure 4).

c729cf9c-3bea-49f2-b11f-182a9d02e3d8_figure4.gif

Figure 4. Third-degree AV block simulation.

Complete atrioventricular dissociation with independent regular atrial (70 bpm) and ventricular (40 bpm) rhythms. Simulated using atrial and ventricular rate inputs as described in Methods. Simulations were generated at 75 bpm, 25 mm/s paper speed and 10 mm/mV (1x) ECG gain.

In the context of repolarisation disorders, ECGSim-Advanced generates a prolonged QTc interval (e.g., 500 ms) with broad, low-amplitude T-waves for Long QT Syndrome ( Figure 5A), and a shortened QT interval with narrow, peaked T-waves for Short QT Syndrome ( Figure 5B). The QT interval is derived from QTc using Bazett’s formula: QT = QTc · √RR. Across all tested pathological states, the simulated ECG waveforms and interval measurements were consistent with published electrocardiographic standards, supporting the accuracy and educational value of the platform.

c729cf9c-3bea-49f2-b11f-182a9d02e3d8_figure5.gif

Figure 5. Repolarization disorder simulations.

(A) Long QT Syndrome: QTc prolongation (490 ms) with broad, low-amplitude T-waves at 75 bpm. (B) Short QT Syndrome: Shortened QTc (315 ms) with narrow, peaked T-waves at 75 bpm. QT values calculated using Bazett’s formula. Simulations were generated at 75 bpm, 25 mm/s paper speed and 10 mm/mV (1x) ECG gain.

Use case demonstrations

Use case 1: Simulating severe hyperkalaemia

Severe hyperkalaemia is simulated by selecting the Electrolyte Imbalance mode, setting potassium as the target electrolyte, and adjusting the concentration to the hyperkaliaemic range with a base heart rate of 60 bpm. The resulting ECG displays tall, peaked T-waves, PR interval prolongation, flattening or absence of P-waves, and QRS widening. Educational notes describe the progressive changes of hyperkalaemia, and interval measurements confirmed prolongation of PR and QRS durations with characteristic T-wave alterations.

Use case 2: Simulating third-degree (complete) av block

The simulator was configured in AV Blocks mode to model a third-degree AV block. The atrial rate was set to 80 beats per minute, representing regular P-wave activity, while the ventricular escape rate was set to 35 beats per minute to simulate independent ventricular rhythm. The resulting ECG trace demonstrated classic AV dissociation, with regular P-waves at 80 bpm and independent, regular QRS complexes at 35 bpm. As expected in complete AV block, the PR interval was not applicable. Educational notes explained the mechanism of AV dissociation and the nature of escape rhythms, while interval measurements confirmed the distinct atrial and ventricular rates characteristic of this conduction abnormality.

Use case 3: Simulating long qt syndrome (LQTS)

For this scenario, the simulator was set to QT Syndromes mode with Long QT Syndrome selected, a target QTc of 500 ms, and a base heart rate of 70 beats per minute. The resulting ECG trace demonstrated a visibly prolonged QT interval, with T-wave morphology appearing broader than normal. Educational annotations described the clinical features and risks associated with LQTS, including the potential for Torsades de Pointes and common aetiologies. Interval measurements confirmed a QT interval consistent with a QTc of approximately 500 ms at the specified heart rate.

Use case 4: Engaging with a clinical vignette (e.g., “Post-thyroidectomy paraesthesias”)

In this scenario, the user selects the clinical vignette titled “Post-Thyroidectomy Paraesthesias” from the dropdown menu. The simulator presents a case description of a 42-year-old female who develops circumoral numbness three days after total thyroidectomy, accompanied by a related diagnostic question. Upon vignette selection, the system automatically switches to Electrolyte Imbalance mode, selects calcium as the relevant electrolyte, and sets the level to hypocalcaemia. The ECG display updates to reflect features characteristic of hypocalcaemia, notably a prolonged QT interval resulting from ST segment lengthening. When the user clicks “Show Clues & Explanation,” the simulator reveals the diagnosis of hypocalcaemia, outlines the expected ECG findings, and provides a rationale linking the clinical scenario to the observed electrocardiographic changes.

Discussion

Accurate ECG interpretation is a core competency for clinicians across many specialties, yet it remains a persistent challenge in undergraduate and postgraduate medical training.6,7,12 While traditional teaching methods rely heavily on didactic instruction and static images, there is growing evidence that interactive and simulation-based approaches can enhance learner engagement, conceptual understanding, and diagnostic performance.16,22,23

ECGSim-Advanced was developed to address these educational gaps by offering an interactive, open-source platform for exploring ECG manifestations of electrolyte disturbances, AV conduction blocks, and QT interval abnormalities. Unlike many existing ECG simulators, which are either proprietary, limited in scope, or focused on arrhythmia classification, ECGSim-Advanced allows users to dynamically manipulate key physiological and pathological parameters. This includes real-time adjustments to electrolyte levels, heart rate, QTc interval, and conduction block type, with immediate visual feedback on ECG waveform morphology.

The use of Gaussian models to generate ECG waveforms, while simplified, allows for fine-tuned simulation of features such as T-wave peaking (hyperkalaemia), U-waves (hypokalemia), and PR interval prolongation (first-degree AV block).24 Although single-lead simulation may limit diagnostic completeness, this abstraction aligns with the pedagogical goal of teaching pattern recognition and foundational principles before learners progress to multi-lead interpretation.25,26,27

A notable strength of ECGSim-Advanced is the integration of clinical vignettes, which situate ECG findings in realistic scenarios and encourage diagnostic reasoning. This not only helps learners connect abstract ECG changes to clinical presentations, but also supports the development of illness scripts and cognitive pattern recognition - both essential for expert-level interpretation.28,29 By combining active parameter manipulation with case-based learning, the simulator adopts a constructivist educational approach that aligns with best practices in simulation-enhanced lea30,31,32

Comparison with existing tools

Several commercial and academic ECG education platforms exist, including Life in the Fast Lane ECG Library, ECGPedia, and PhysioNet simulators. While these resources offer high-quality static ECGs and explanations, they generally lack the flexibility for real-time manipulation of waveform characteristics. Tools like SimECG or SimVentricular may provide rhythm training but often require institutional licenses or focus narrowly on arrhythmias. ECGSim-Advanced fills a unique niche by simulating morphological rather than rhythmic changes and offering transparent, modifiable source code.

Limitations

Despite its advantages, the simulator has several limitations. First, it is currently limited to a single-lead representation (Lead II approximation), which restricts the simulation of conditions requiring spatial analysis across multiple leads (e.g., STEMI localization). Second, the use of Gaussian approximations, while computationally efficient, may not fully replicate the complex morphologies seen in clinical practice. Third, dynamic rhythm simulation (e.g., progressive PR lengthening in Mobitz I) is not yet implemented; second-degree AV blocks are shown as static representations with accompanying educational notes.

Additionally, no formal user study has yet been conducted to assess learning outcomes, usability metrics, or long-term knowledge retention. Such validation will be important for future educational deployment and comparison with existing resources.

Future directions

Planned enhancements include:

  • Support for multi-lead ECG output, allowing spatial interpretation of pathologies;

  • More nuanced T-wave and ST-segment modelling, especially for ischemia or pericarditis;

  • Implementation of dynamic beat-to-beat variability to better simulate arrhythmias and conduction delays;

  • Integration with assessment modules to track user performance and progression;

  • Expansion of the clinical vignette library, potentially through crowdsourced contributions.

The tool’s open-source nature makes it well-suited for collaborative development by the broader medical education and cardiology communities. It also allows easy adaptation for use in simulation labs, flipped classrooms, or remote learning environments.

Conclusion

ECGSim-Advanced is a flexible, interactive, and open-source simulation platform designed to enhance ECG education by allowing users to explore the morphological effects of electrolyte disturbances, AV conduction blocks, and QT interval syndromes in real time. By combining dynamic waveform manipulation with clinically grounded vignettes, the tool promotes active learning, pattern recognition, and diagnostic reasoning - skills essential for accurate ECG interpretation.

While current limitations include single-lead representation and simplified waveform modelling, ECGSim-Advanced provides a strong foundation for future development and curricular integration. Its accessibility and adaptability make it a valuable resource not only for medical students and trainees, but also for educators seeking to modernize ECG instruction using simulation-enhanced learning.

With continued refinement and validation, ECGSim-Advanced has the potential to contribute meaningfully to ECG training in both academic and clinical settings.

Comments on this article Comments (0)

Version 1
VERSION 1 PUBLISHED 12 May 2026
Comment
Author details Author details
Competing interests
Grant information
Copyright
Download
 
Export To
metrics
Views Downloads
F1000Research - -
PubMed Central
Data from PMC are received and updated monthly.
- -
Citations
CITE
how to cite this article
Bussuri L, Smith J, Takreem M et al. ECGSim-Advanced: An Open-Source Interactive Simulator for Teaching Electrolyte, Conduction, and Repolarization Abnormalities in Electrocardiography [version 1; peer review: awaiting peer review]. F1000Research 2026, 15:714 (https://doi.org/10.12688/f1000research.180507.1)
NOTE: If applicable, it is important to ensure the information in square brackets after the title is included in all citations of this article.
track
receive updates on this article
Track an article to receive email alerts on any updates to this article.

Open Peer Review

Current Reviewer Status:
AWAITING PEER REVIEW
AWAITING PEER REVIEW
?
Key to Reviewer Statuses VIEW
ApprovedThe paper is scientifically sound in its current form and only minor, if any, improvements are suggested
Approved with reservations A number of small changes, sometimes more significant revisions are required to address specific details and improve the papers academic merit.
Not approvedFundamental flaws in the paper seriously undermine the findings and conclusions

Comments on this article Comments (0)

Version 1
VERSION 1 PUBLISHED 12 May 2026
Comment
Alongside their report, reviewers assign a status to the article:
Approved - the paper is scientifically sound in its current form and only minor, if any, improvements are suggested
Approved with reservations - A number of small changes, sometimes more significant revisions are required to address specific details and improve the papers academic merit.
Not approved - fundamental flaws in the paper seriously undermine the findings and conclusions
Sign In
If you've forgotten your password, please enter your email address below and we'll send you instructions on how to reset your password.

The email address should be the one you originally registered with F1000.

Email address not valid, please try again

You registered with F1000 via Google, so we cannot reset your password.

To sign in, please click here.

If you still need help with your Google account password, please click here.

You registered with F1000 via Facebook, so we cannot reset your password.

To sign in, please click here.

If you still need help with your Facebook account password, please click here.

Code not correct, please try again
Email us for further assistance.
Server error, please try again.