What this research found
An end-to-end pipeline for detecting physiological stress from electrocardiogram (ECG) signals: bandpass filtering, R-peak detection, eight heart rate variability (HRV) features over 60-second windows, non-parametric hypothesis testing, and four classifiers compared under leave-one-subject-out validation. Because the WESAD benchmark requires manual download and authentication, the pipeline was exercised on synthetic ECG generated to match WESAD's chest-sensor specification — three simulated subjects at 700 Hz — rather than on the real recordings. On that synthetic cohort, Random Forest reached 98.81% accuracy and a single feature, pNN50, carried roughly 78% of the model's predictive weight.
- The numbers come from synthetic signals, not real recordings. With WESAD gated behind manual download and authentication, a generator produced three simulated subjects of 30 minutes each at 700 Hz, with realistic P-QRS-T complexes plus baseline wander and high-frequency noise added to mimic recording conditions.
- One feature does nearly all the work. Across validation folds, pNN50 — the share of successive heartbeat intervals differing by more than 50 milliseconds — carried 0.7801 plus or minus 0.0418 of the gradient-boosted model's feature importance, with mean interbeat interval at 0.1029 and RMSSD at 0.0497, leaving the frequency-domain features near zero.
- All eight HRV features separated the two conditions after Bonferroni correction across 84 baseline and 84 stress windows, six of them at p < 0.001. pNN50 showed the largest effect (75.88% down to 52.88%, Cohen's d = 3.33), followed by mean interbeat interval (624.09 to 520.54 milliseconds, d = 1.52), sample entropy (1.55 to 1.23, d = 0.69), and the LF/HF ratio (1.53 to 0.61, d = 0.51).
- Model choice barely mattered. Under leave-one-subject-out validation, Random Forest reached 98.81% plus or minus 0.84% accuracy with 2 windows misclassified, SVM 98.21% with 3, logistic regression 97.62% with 4, and XGBoost 97.02% with 5. The linear model landing within about a percentage point suggests the classes are largely linearly separable in the eight-feature space.
- Two features moved against textbook expectation: high-frequency power rose under stress (23,691 to 35,446, d = -0.25), the only feature to increase, and the LF/HF ratio fell rather than rising as conventional sympathovagal interpretation would predict.
How it was done
ECG sampled at 700 Hz was bandpass filtered between 0.5 and 40 Hz with a 4th-order zero-phase Butterworth filter, improving signal-to-noise ratio by 10.81 decibels. R-peaks were detected with a Pan-Tompkins implementation, and interbeat intervals were cut into 60-second windows stepped every 30 seconds and never crossing a condition boundary, giving 168 windows split evenly between baseline and stress. Eight features were computed per window: four time-domain measures (mean interbeat interval, SDNN, RMSSD, pNN50), three frequency-domain measures from Welch power spectral density, and sample entropy. Shapiro-Wilk tests indicated non-normal distributions, so comparisons used Mann-Whitney U tests with Bonferroni correction over the eight features plus Cohen's d for effect size. Random Forest, SVM, logistic regression, and XGBoost were then compared under leave-one-subject-out cross-validation, with standardisation applied inside the pipeline for the two scale-sensitive models.
Data sources
- Synthetic ECG generated to the WESAD chest-sensor specification — 3 simulated subjects, 700 Hz, 30 minutes each, 168 sixty-second windows
- WESAD (Wearable Stress and Affect Detection), UCI Machine Learning Repository — the intended source, not retrieved during the run
- Schmidt et al., ICMI (2018) — WESAD dataset description
- Task Force of the European Society of Cardiology (1996) — heart rate variability measurement standards
Limitations
The headline accuracies come from synthetic signals, so they demonstrate that the pipeline works rather than that HRV distinguishes real stress. Three subjects and 168 windows with 50% overlap between neighbours leave the leave-one-subject-out estimates fragile, and 60-second windows are shorter than the five-minute standard for HRV analysis.
How this research was produced
K-Dense Web planned and ran this biosignals investigation end to end — gathering the sources, carrying out the analysis, producing the figures, and drafting the report. The full session transcript, including every intermediate step, is available to view.


