P wave: Atrial depolarization (0.1s)
QRS complex: Ventricular depolarization (0.08s)
T wave: Ventricular repolarization (0.2s)
Heart rate: HR = 60 / RR[s]
Adjust heart rate, noise level, and filter cutoff to visualize ECG waveform, RR interval, and frequency spectrum in real time.
The most fundamental calculation in ECG analysis is determining heart rate from the time interval between ventricular depolarizations (R-peaks).
$$HR = \frac{60}{RR}$$HR: Heart Rate in beats per minute (BPM).
RR: RR interval in seconds, the time between consecutive R-peaks in the QRS complex. This is the direct measurement you can see changing on the simulator's waveform when you adjust the Heart Rate parameter.
To analyze the rhythm and autonomic nervous system influence, we quantify the variation in these intervals. A common simple metric is the Standard Deviation of NN intervals (SDNN), where NN intervals are normal-to-normal (sinus rhythm) RR intervals.
$$SDNN = \sqrt{\frac{1}{N-1}\sum_{i=1}^{N}(RR_i - \overline{RR})^2}$$SDNN: Standard Deviation of NN intervals (ms). A higher value generally indicates greater parasympathetic (rest-and-digest) activity and better cardiovascular health.
$RR_i$: Individual RR interval.
$\overline{RR}$: The mean RR interval over the measurement period.
Clinical Cardiac Diagnosis: ECG analysis is the first-line tool for diagnosing arrhythmias like atrial fibrillation, myocardial infarction (heart attack), and bradycardia/tachycardia. Engineers design algorithms to automatically detect these abnormal patterns in real-time monitoring equipment, much like the peak detection shown in this simulator.
Ambulatory Holter Monitoring: Patients wear a portable ECG device for 24-48 hours to capture intermittent heart issues. Signal processing, including the filtering techniques you can experiment with here, is crucial to remove motion artifact noise from daily activities while preserving the critical cardiac data.
Brain-Computer Interfaces (BCIs): For EEG signals, frequency band analysis (Alpha, Beta, Theta waves) is used to control external devices with thought. For instance, a user focusing might increase Beta wave power, which a BCI can translate into a command to move a robotic arm or type on a screen.
Sleep Stage Analysis & Neurological Assessment: Polysomnography (sleep studies) uses EEG to characterize sleep stages based on dominant wave frequencies. Similarly, EEG is used to diagnose and monitor conditions like epilepsy by detecting abnormal spike-and-wave discharge patterns that would stand out in both the time-domain waveform and frequency spectrum.
First, be aware of the common tendency to think "removing all noise is perfect." In the simulator, if you apply a strong "filter cutoff," the waveform will indeed become smooth. However, in actual clinical settings, sharp corners in the waveform (high-frequency components) can sometimes contain crucial information. For example, the waveform of a premature ventricular contraction (PVC) becomes wider, but if you round it off with an excessively strong filter, you risk missing this characteristic. Remember that filtering is a "trade-off" operation.
Next, the assumption that "heart rate is constant." The simulator's heart rate slider sets a fixed value, but a living person's heart rate is constantly fluctuating (Heart Rate Variability: HRV). For instance, even at rest, RR intervals subtly vary, e.g., 0.85 seconds, 0.92 seconds, 0.88 seconds... This variation itself is a barometer of autonomic nervous system activity. During analysis, it's important to focus not only on the short-term average heart rate but also on this range of variation.
Finally, the misidentification that "any prominent peak is a QRS complex." Actual ECGs can have artifacts (false signals) appearing as large peaks. Examples include large-amplitude baseline wander from a detached electrode or strong electromyographic (EMG) noise. In the simulator, setting the noise level to maximum can reproduce the phenomenon of another peak riding on top of the QRS wave. When automatically detecting QRS complexes with an algorithm, you need "logic" that makes a comprehensive judgment based not just on amplitude but also on waveform shape and the surrounding context.
Patient with sinus rhythm at 72 bpm, 15 µV EMG noise floor, 0.5 Hz high-pass filter, 30-second window. Raw signal shows 30 QRS complexes with RR intervals clustering around 833 ms. After filtering, PR segments reveal baseline stability within ±20 µV. FFT peak at 1.2 Hz confirms heart rate component; secondary peaks at 50/60 Hz indicate powerline contamination successfully attenuated by the 0.5 Hz cutoff.