Need help to convert ECG data from EDF format to TXT format in Python

929 Views Asked by At

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()
1

There are 1 best solutions below

4
Ruggero On

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().