import numpy as np
a=[100,101,103,105,106,107,108,109,111,112,113,114,115,116,117,118,119,200,
201,202,203,205,207,208,209,210,212,213,214,215,217,220,221,222,223,228,230,231,232,233,234]
#设置表格样式
#写Excel
for m in a:
PATH="./MIT-BIH/" #path, 这里就是写刚才你保存的数据地址
HEADERFILE=str(m)+".hea" #文件格式为文本格式
#print("HEADERFILE:",HEADERFILE)
#continue
ATRFILE=str(m)+".atr" #attributes-file 文件以二进制格式
DATAFILE=str(m)+".dat" #data-file
SAMPLES2READ=3000 #读取的数据样本点数
####################读取头文件######################
f=open(PATH+HEADERFILE,"r")
z=f.readline().split()
nosig,sfreq=int(z[1]),int(z[2]) #% number of signals,sample rate of data
dformat,gain,bitres,zerovalue,firstvalue=[],[],[],[],[]
for i in range(nosig):
z=f.readline().split()
dformat.append(int(z[1])) #format; here only 212 is allowed
gain.append(int(z[2])) #number of integers per mV
bitres.append(int(z[3])) #bitresolution
zerovalue.append(int(z[4])) #integer value of ECG zero point
firstvalue.append(int(z[5])) #first integer value of signal (to test for errors)
f.close()
####################读取dat文件######################
f=open(PATH+DATAFILE,"rb") #以二进制格式读入dat文件
b=f.read()
f.close()
#print("b:",b)
A_init=np.frombuffer(b,dtype=np.uint8) #将读入的二进制文件转化为unit8格式
A_shape0=i
查阅MIT-BIH 异常的心拍类别及其总数
最新推荐文章于 2024-05-08 15:44:16 发布