-1

I can need to convert ECG edf file to text format in PYTHON. Can not do it. Tried a lot. plz help me someone.

by using pyedflib getting this traceback:

:Traceback (most recent call last): File "C:/Users/shafi/anaconda3/envs/NEW37/Lib/encodings/rd_edf_py.py", line 8, in sigbufs=np.zeros((n, f.getSignalLabels()[0])) TypeError: 'str' object cannot be interpreted as an integer

actual code is below**

import pyedflib
import numpy as np
import matplotlib.pyplot as plt

f= pyedflib.EdfReader( 'C:\\Users\\shafi\\PycharmProjects\\pyHrv\\Sample.edf')
n=f.signals_in_file 
signal_labels=f.getSignalLabels()
sigbufs=np.zeros((n, f.getSignalLabels()[0])) 
fig=plt.figure()
ax=plt.axes() 
for i in np.arange(n):
    sigbufs[i, :] = f.readSignal(i) 
    ax.plot(f.readSignal(i))
    x.plot(f.readSignal(i)) 
    plt.show()
  • Welcome to StackOverflow. Please, post an example of the input you are using. Also, share your efforts so people could help you better. Your question is too vague. – revy Nov 03 '21 at 18:20

1 Answers1

1

You can use pyedflib: it is a library useful for your case, for example to read a .edf file.

Once you have read your .edf file, you can save every array through simple numpy commands such as numpy.savetxt().

Ruggero
  • 427
  • 2
  • 10