首页 > 解决方案 > 怎么下载最新版的Heartpy==1.2.4

问题描述

我正在使用 Heartpy 分析嘈杂的心电图信号,但是当我在呼吸示例中运行下面的代码时,我收到了这个错误:

AttributeError:模块“HeartPy”没有属性“enhance_ecg_peaks”

我已经下载了heartpy使用

1-pip install heartpy==1.2.4

2点安装heartpy

3-我已经下载了呼吸:https ://github.com/paulvangentcom/heartrate_analysis_python.git

4-我已经克隆了它

filtered = hp.enhance_ecg_peaks(hp.scale_data(ecg), sample_rate, 
                 iterations=4, aggregation='median', notch_filter=True)


#show filtered signal

plt.figure(figsize=(12,4))

plt.plot(filtered)

plt.show()

#zoom in on signal section and overlay filtered segment 

plt.figure(figsize=(12,4))

plt.title('original signal zoom in')

plt.plot(hp.scale_data(ecg[15000:17000]), label='original data')

plt.title('processed signal zoom in')

plt.plot(hp.scale_data(filtered[15000:17000]), alpha=0.5, label='processed 
                      data')
plt.legend()
plt.show()

标签: python-3.x

解决方案


这是Python 心率分析工具包文档的完整文档

增强心电峰值:heartpy.enhance_ecg_peaks(hrdata,sample_rate,iterations=4,aggregation='mean',notch_filter=True)

这是一个错误,并创建了一个问题heartrate_analysis_python -> 缺少属性

修复步骤

  1. 卸载现有的heartpy使用

    pip uninstall heartpy==1.2.4

  2. 克隆存储库heartpy并运行安装程序

    git clone https://github.com/paulvangentcom/heartrate_analysis_python.git
    cd heartrate_analysis_python
    python -m setup.py install
    

然后你可以简单地使用它,它工作得很好:

filtered = hp.enhance_ecg_peaks(hp.scale_data(ecg), sample_rate, 
             iterations=4, aggregation='median', notch_filter=True)

希望这会帮助你。


推荐阅读