Stress detection using physiological signals has gained significant attention due to its impact on both physical and mental health. While existing approaches based on machine learning and deep learning achieve strong predictive performance, they often rely on black-box models and fail to capture individual variability in physiological responses. In this work, we propose an interpretable and personalized framework for stress detection using electrocardiogram (ECG) signals based on motif discovery and Matrix Profile analysis. Instead of training a classifier, the method learns subject-specific baseline cardiac behavior by extracting recurring heartbeat patterns (motifs) from ECG signals. Stress is then detected as a deviation from these baseline patterns using a distance-based anomaly score. Experiments are conducted on the WESAD dataset using a carefully designed train-validation-test protocol to ensure reliable evaluation. The results show that the proposed approach can effectively detect stress for several subjects while providing clear interpretability through direct comparison of ECG patterns. However, the performance varies across individuals due to differences in physiological responses, with some subjects exhibiting minimal morphological changes under stress. Additional analysis incorporating heart rate variability (HRV) features reveals that while HRV can improve performance in certain cases, its contribution is not consistent across all subjects. These findings highlight the importance of personalization and interpretability in physiological stress detection and demonstrate that motif-based approaches provide a meaningful alternative to black-box models, while also revealing inherent limitations due to inter-subject variability.
Figures & tables
Fig. 1: Typical morphological components of the ECG waveform.
Subject
m
k
Threshold (%ile)
S2
1050
5
93
S3
1050
5
92
S4
1050
5
59
S5
1050
5
56
S6
1050
5
71
S7
1050
5
50
TABLE I: Finalized Hyperparameter Configurations per Subject
Subj.
Acc
Prec
Rec
F1
Sep.
S2
0.885
0.921
0.842
0.879
1.03x
S3
0.870
0.921
0.809
0.862
1.02x
S4
0.726
0.689
0.823
0.750
1.00x
S5
0.747
0.676
0.947
0.789
1.00x
S6
0.700
0.641
0.909
0.752
1.00x
S7
0.483
0.483
0.462
0.472
1.00x
TABLE II: Test Set Performance per Subject
Fig. 2: Baseline motif comparison between S2 (best performer, F1 = 0.879) and S8 (worst performer, F1 = 0.047).
Fig. 3: Baseline Motif vs Most Anomalous Segment Comparison between S2 (best performer, F1 = 0.879) and S8 (worst performer, F1 = 0.047).
Fig. 4: Real-time anomaly detection comparison between S2 (top) and S8 (bottom).
Subject
F1 (Motif)
F1 (Motif + HRV)
Difference
S2
0.879
0.932
+0.052
S3
0.861
0.989
+0.127
S4
0.750
0.941
+0.191
S5
0.789
0.915
+0.126
S6
0.752
0.663
-0.088
S7
0.472
0.236
-0.236
TABLE III: Performance Comparison: Motif-Only vs. Motif + HRV Features
Fig. 5: Baseline motif comparison between S2 (best performer, F1 = 0.879) and S8 (worst performer, F1 = 0.047).
Fig. 6: Baseline Motif vs Most Anomalous Segment Comparison between S2 (best performer, F1 = 0.879) and S8 (worst performer, F1 = 0.047).
Engineering and Technology institute Groningen (ENTEG), University of Groningen, Groningen, 9742AG, the Netherlands · Department of Human Movement Sciences, University Medical Center Groningen, Groningen, Netherlands