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.
The core signal processing technology of this simulator is directly connected to vibration/acoustical engineering. Examining the frequency spectrum of an ECG is essentially the same as "FFT (Fast Fourier Transform) analysis," which identifies abnormal sounds from machine vibration data. For example, shaft imbalance in rotating machinery creates peaks at specific frequencies, a technique shared with identifying power line noise (50/60 Hz peaks) in electrocardiography.
Furthermore, filter design theory from control engineering is applied directly. The band-pass filters used in biological signals combine low-pass and high-pass filters, sharing the same design philosophy as "notch filters" or "low-pass filters" that remove unwanted frequency band signals in feedback control systems. The feeling of adjusting the cutoff frequency in the simulator is directly linked to the feeling of adjusting the bandwidth of a control system.
There are also connections to non-destructive testing in materials/structural engineering. In ultrasonic flaw detection, various noises are superimposed on the reflected waves (signals) from defects inside a material. The signal processing that separates this "true signal" from "noise" to estimate the defect's location and size is technically a cousin to ECG analysis, which detects small P or T waves buried in noise.
The first next step is to move towards analysis that consciously treats biological signals as "time-series data." While the simulator primarily focuses on a single heartbeat, you actually deal with long-duration data. For example, you could read 5 minutes of ECG data as an array, detect all R-wave positions to create an RR interval time series, and then calculate its standard deviation (SDNN: one metric of heart rate variability). Trying to actually write code in a programming environment (like Python's NumPy/SciPy) is the most effective approach.
Regarding mathematical background, the fundamentals of linear algebra and statistics
A recommended next specific topic is "Wavelet Transform." While FFT tells you the frequency components of the entire signal, wavelet transform can simultaneously provide information on both "time and frequency." This becomes a powerful tool for analyzing non-stationary signals—for example, suddenly occurring arrhythmias or changes in electroencephalogram (EEG) due to sleep stages. As the next evolutionary step from the Fourier transform you learned with the simulator, try exploring its concepts.