import numpy as np from wfdb import processing from scipy.signal import find_peaks peaks, _ = find_peaks(signal_filtered, distance=int(0.2*fs), height=0.2) rpeaks, _ = wfdb.processing.gqrs_detect(signal_filtered, fs=fs) p_peaks = [] for p in peaks: if p < rpeaks[0]: p_peaks.append(p) p_peak = np.min(p_peaks)中报错 rpeaks, _ = wfdb.processing.gqrs_detect(signal_filtered, fs=fs) ValueError: too many values to unpack (expected 2)
时间: 2023-06-11 15:06:33 浏览: 182
import numpy as np import matplotlib.pyplot as plt import math
这个错误的原因是 gqrs_detect 函数返回的值不是一个包含两个元素的元组,而是一个包含三个元素的元组。你需要将代码修改为以下形式:
```
rpeaks, _, _ = wfdb.processing.gqrs_detect(signal_filtered, fs=fs)
```
或者:
```
output = wfdb.processing.gqrs_detect(signal_filtered, fs=fs)
rpeaks = output[0]
```
这样就可以正确获取到 rpeaks 的值了。
阅读全文