我从下面的代码中得到以下回溯:
Traceback (most recent call last):
File "C:/Users/shafi/anaconda3/envs/NEW37/Lib/encodings/EDFreadingchina.py", line 36, in <module>
sigbufs=upload_brain_wave_file()
File "C:/Users/shafi/anaconda3/envs/NEW37/Lib/encodings/EDFreadingchina.py", line 23, in upload_brain_wave_file
sigbufs[i,:]=f.readSignal(i)
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
这是代码:
import pyedflib
import numpy as np
import os
def upload_brain_wave_file():
brain_wave_list=[]
#brain_wave= os.path.join(os.getcwd(),f"datasets/brain_wave")
brain_wave="C:\\Users\\shafi\\PycharmProjects\\pyHrv\\SN001.edf"
f= pyedflib.EdfReader(brain_wave)
n=f.signals_in_file
print("signal numbers:",n)
signal_lebels = f.getSignalLabels()
print("Labels:", signal_lebels,len(signal_lebels),sep="\n==========\n")
sample_signal=f.getSampleFrequency(chn=n)
# print('sample_signal',sample_signal.shape)
# signal_headers=f.getSignalHeaders() #আগে এটা ছিল
signal_headers=f.getSignalHeader(7)
print("Header:",signal_headers,len(signal_headers),sep="\n===\n")
sigbufs=np.zeros((f.getNSamples()[0]))
timestart=f.getFileDuration()
print('timestart',timestart)
for i in np.arange(n):
sigbufs[i,:]=f.readSignal(i)
print('ooo',sigbufs)
label= f.getLabel(i)
sample_rate=f.getSampleFrequency(i)
# print("sample_rate",sample_rate)
d=list(enumerate(sigbufs[0,0:sample_rate]))
print('da',d)
# print({label:sigbufs[0,0:10]})
# return {label:sigbufs[0,0:256]}
# print(sigbufs.shape)
#return sigbufgs
sigbufs=upload_brain_wave_file()
print(sigbufs)
import matplotlib.pyplot as plt
plt.plot(*np.array(list(enumerate(sigbufs[0,0:256]))).T, linestyle='-', linewidth=1,color='dodgerblue')
plt.show()