Traceback (most recent call last): File "D:\pythonProject_ecg_analyzation_x\main.py", line 20, in <module> r_peaks, bpm = GetRpeak.getrpeak(ecg_voltage, user_number) File "D:\pythonProject_ecg_analyzation_x\GetRpeak.py", line 27, in getrpeak _filtered_ecg_voltage = hp.filter_signal(_ecg_voltage, [0.5, 40.0], sample_rate=main.fs) File "C:\Users\24430\AppData\Roaming\Python\Python39\site-packages\heartpy\filtering.py", line 216, in filter_signal b, a = butter_lowpass(cutoff, sample_rate, order=order) File "C:\Users\24430\AppData\Roaming\Python\Python39\site-packages\heartpy\filtering.py", line 47, in butter_lowpass normal_cutoff = cutoff / nyq TypeError: unsupported operand type(s) for /: 'list' and 'float'
时间: 2023-08-29 13:08:25 浏览: 179
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
这个错误提示已经在之前回答中提到了,是由于传递给 `butter_lowpass` 函数的参数类型不正确导致的。可以检查一下 GetRpeak.py 中调用 `butter_lowpass` 函数时,传递的参数格式是否如下所示:
```python
butter_lowpass(cutoff, sample_rate, order=order)
```
其中,`cutoff` 参数应该为一个浮点数列表,如 `[0.5, 40.0]`,而 `sample_rate` 参数应该为一个整数或浮点数,表示信号的采样率。如果传递的参数格式正确,但依然出现这个错误,可以将 `cutoff` 参数改为一个浮点数,如 `cutoff = 0.5`。
阅读全文