1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import neurokit2 as nk import matplotlib.pyplot as plt import pandas as pd
df = pd.read_csv('Polar_ECG.csv')
ecg = df.ECG
peaks, info = nk.ecg_peaks(ecg, sampling_rate=130)
hrv = nk.hrv(peaks, sampling_rate=130, show=True)
hrv.to_csv('HRV.csv', index=False, header=True)
figure = plt.gcf() figure.set_size_inches(32 / 1.5, 18 / 1.5) plt.savefig('HRV.png', bbox_inches='tight', dpi=120)
|