Read all data

(convert bpm to peaks as needed)

Sleep state label manipulations

Compute N3 REM duration as example;

The script can be changed easily to study systematically sleep state architecture:

wake = 0, N1 = 1, N2 = 2, N3 = 3, REM = 5

HRV UDFs

HRV ancilllary UDFs

HRV metrics UDFs

Compute HRV

Compute higher order HRV metrics

This includes statistical and HMM estimates

Vizualization of sleep states architecture, HR, HRV metrics

Execute the entire analysis

  1. Read heart rate and sleep labels files
  2. Compute HRV and sleep metrics
  3. Save dataframes
  4. Perform viz and stats

Combine and save everything: HRV plus higher order spreadsheets

Now do a) viz to demo the sleep state dynamics and b) correlation matrix btw HRV metrics and N3 NREM duration

VIZ: comp example HRV complexity metric and plot with heart rate & sleep state architecture

also save SampEn and sleep state stats to correlate

correlation matrix

now compute and viz correlations for the entire sleep state stats & HRV metrics