PyHealth icon indicating copy to clipboard operation
PyHealth copied to clipboard

Add WESAD Dataset for Wearable Stress Detection

Open ChengcenZhou opened this issue 1 month ago • 0 comments

Contributor Info

Type of Contribution

  • New dataset (WESAD: Wearable Stress and Affect Detection)
  • New tasks (stress_detection_wesad_fn, binary and multiclass variants)
  • New unit tests

What's WESAD Dataset?

This PR integrates the WESAD dataset [Schmidt et al., 2018] into PyHealth for wearable stress detection research. It adds:

  • A WESADDataset class for loading Empatica E4 wrist-worn sensor data (EDA, BVP, ACC, TEMP) from 15 subjects
  • Task functions for binary stress detection (stress vs non-stress) and 3-class classification (baseline, stress, amusement)
  • Unit tests with synthetic data generation

The implementation follows the contributing guidelines (PEP8, Google-style docstrings, and documented function signatures).

Files to Review

Modified:

  • pyhealth/datasets/__init__.py: register WESADDataset
  • pyhealth/tasks/__init__.py: register stress_detection_wesad_fn

New:

  • pyhealth/datasets/wesad.py: WESADDataset class implementation
  • pyhealth/tasks/stress_detection_wesad.py: Task functions for stress detection
  • tests/test_wesad.py: Unit tests for dataset and tasks

Dataset Info

Item Details
Subjects 15 (S2-S17, excluding S1, S12)
Device Empatica E4 wristband
Signals EDA (4Hz), BVP (64Hz), ACC (32Hz), TEMP (4Hz)
Labels Baseline, Stress, Amusement
Source UCI ML Repository / Kaggle

Reference

  • Paper Title: Schmidt, P., Reiss, A., Duerichen, R., Marberger, C., & Van Laerhoven, K. "Introducing WESAD, a Multimodal Dataset for Wearable Stress and Affect Detection", ICMI 2018
  • Paper Link: https://doi.org/10.1145/3242969.3242985
  • Dataset Link: https://archive.ics.uci.edu/ml/datasets/WESAD

How to Use

from pyhealth.datasets import WESADDataset
from pyhealth.tasks import stress_detection_wesad_fn

# Load dataset
dataset = WESADDataset(root="/path/to/WESAD/")

# Apply task
dataset = dataset.set_task(stress_detection_wesad_fn)

# Access samples
print(f"Total samples: {len(dataset.samples)}")

ChengcenZhou avatar Dec 07 '25 04:12 ChengcenZhou