首页 > 解决方案 > AttributeError: 'tuple' object has no attribute 'p_signals'

问题描述

I am stucked in this error any help please. This is my code:

import numpy as np 
import pandas as pd 
from subprocess import check_output
print(check_output(["ls", "/home/mahmood/apnea-ecg"]).decode("utf8"))
import os
os.listdir("/home/mahmood/apnea-ecg")
import wfdb
import numpy as np
import matplotlib.pyplot as plt
recordname = "/home/mahmood/apnea-ecg/a04"
record = wfdb.rdsamp(recordname)
record.p_signals

标签: python-3.xtime-series

解决方案


wfdb.rdsamp源代码:

Returns ------- signals : numpy array A 2d numpy array storing the physical signals from the record. fields : dict A dictionary containing several key attributes of the read record: - fs: The sampling frequency of the record - units: The units for each channel - sig_name: The signal name for each channel - comments: Any comments written in the header

因此,您得到一个包含 2 个元素、信号和字段的元组。我只想写:

p_signals, _ = wfdb.rdsamp(recordname)

推荐阅读