首次上传代码

This commit is contained in:
2025-10-20 22:01:18 +08:00
parent 67a817fd01
commit 0c37782d21
7722 changed files with 763 additions and 1528852 deletions

28
heart_rate.py Normal file
View File

@@ -0,0 +1,28 @@
import numpy as np
from global_var import global_var_init
cycle, fs, record_name, data_path = global_var_init()
from ecg_peaks_val import ecg_peaks_val
(P_peaks, Q_peaks, R_peaks, S_peaks, T_peaks,
P_onsets, P_offsets, T_onsets, T_offsets,
P_peaks_values, Q_peaks_values, R_peaks_values, S_peaks_values, T_peaks_values,
P_onsets_values, P_offsets_values, T_onsets_values, T_offsets_values,
PQ_baseline) = ecg_peaks_val()
def compute_interval():
# 1. RR 间期
rr_s = np.diff(R_peaks) / fs # 单位:秒
rr_ms = rr_s * 1000 # 单位:毫秒
# 2. 瞬时心率
hr_inst = 60.0 / rr_s # 单位bpm
# 3. 平均心率
hr_mean = float(np.mean(hr_inst))
# print(f"瞬时心率: {hr_inst.round(1)} ")
print(f"平均心率: {hr_mean:.1f}")
if __name__ == "__main__":
compute_interval()