using NeuroAnalyzer
using Plots
= load("files/eeg.hdf"); eeg
[ Info: Loaded: EEG (24 × 282991 × 1; 1105.43 s)
Load data:
using NeuroAnalyzer
using Plots
= load("files/eeg.hdf"); eeg
[ Info: Loaded: EEG (24 × 282991 × 1; 1105.43 s)
Heart rate variability (HRV) is the physiological phenomenon of variation in the time interval between heartbeats. It is measured by the variation in the beat-to-beat interval (source: Wikipedia).
NeuroAnalyzer allows detecting and analysis of HRV using ECG channel.
The following time-domain parameters are analyzed:
First, detect peaks:
= hrv_detect(eeg) nn_seg, r_idx
[ Info: ECG channel found: ECG
[ Info: Detected NN segments: 1287
(nn_seg = [945.3125, 929.6875, 929.6875, 945.3125, 941.40625, 929.6875, 820.3125, 929.6875, 941.40625, 933.59375 … 19.53125, 31.25, 19.53125, 19.53125, 19.53125, 23.4375, 19.53125, 19.53125, 19.53125, 19.53125],
r_idx = [146.0, 388.0, 626.0, 864.0, 1106.0, 1347.0, 1585.0, 1795.0, 2033.0, 2274.0 … 282829.0, 282837.0, 282842.0, 282847.0, 282852.0, 282858.0, 282863.0, 282868.0, 282873.0, 282878.0],)
Visualize peaks to check if were detected correctly:
= get_channel(eeg, ch="ecg")
ch = eeg.data[24, :, :][:]
ecg plot(ecg[1:10*sr(eeg)], # 10 seconds
Plots.=:black,
lc=0.5,
lw=(-2000, 2000),
ylims=false,
legend=false,
yticks=false)
xticksvline!(r_idx[1:11], # 11 peaks
Plots.=:dot,
ls=:red,
lc=0.5) alpha
Finally, analyze peaks properties:
hrv_analyze(nn_seg)
(menn = 858.137,
mdnn = 937.5,
vnn = 67015.708,
sdnn = 258.874,
rmssd = 89.096,
sdsd = 89.128,
nn50 = 46.0,
pnn50 = 0.036,
nn20 = 86.0,
pnn20 = 0.067,)