2

I need to read data from an .EDF using Python file and save it in .txt format. I found a python library that does this, but while it is running, an error occurs. I just started learning Python. I ask you to help me! Link to .EDF file conversion code I'm trying to use: http://csl-sessions.blogspot.ru/2014/06/program-to-convert-files-edf-to-txt.html

.EDF Download file link: https://cloud.mail.ru/public/CUtc/WrFkpHMDd

If you know of another way to help me, I will be grateful.

hobs
  • 18,473
  • 10
  • 83
  • 106
EmptyMan
  • 297
  • 1
  • 4
  • 25
  • Please be much more specific. Exactly what code are you running? Which error occurs? (Show the full traceback) – Rory Daulton Jul 01 '16 at 12:59
  • Link to all of the code: http://csl-sessions.blogspot.ru/2014/06/program-to-convert-files-edf-to-txt.html I changed it only these lines: FileEDF = 'BARBIERI_EYES_OPEN' FileName = 'infoFile' textFileName = FileName + '.txt' command_line = 'wfdb2mat -r '+ FileEDF +'.edf>'+ FileName +'.info' os.system(command_line) mat = scipy.io.loadmat (FileEDF+'_edfm.mat') – EmptyMan Jul 01 '16 at 14:01
  • End treceback: File "C:\Users\alexey\AppData\Local\Continuum\Anaconda2\lib\site-packages\scipy\io\matlab\mio.py", line 23, in _open_file return open(file_like, 'rb') IOError: [Errno 2] No such file or directory: 'BARBIERI_EYES_OPEN_edfm.mat' – EmptyMan Jul 01 '16 at 14:05
  • Sorry, I do not know how more clearly display the code and trekking in the comments. – EmptyMan Jul 01 '16 at 14:06

1 Answers1

4

Use pyedflib - a python library to parse .edf files. (Iv'e ran one of their examples on your file)

from __future__ import division, print_function, absolute_import
import os
import pyedflib

if __name__ == '__main__':
    data_dir = os.path.join('.', 'data')
    test_data_file = os.path.join(data_dir, 'BARBIERI_EYES_OPEN.EDF')
    f = pyedflib.EdfReader(test_data_file)
    print("\nlibrary version: %s" % pyedflib.version.version)

    print("\ngeneral header:\n")

    print("file duration: %i seconds" % f.file_duration)
    print("startdate: %i-%i-%i" % (f.getStartdatetime().day,f.getStartdatetime().month,f.getStartdatetime().year))
    print("starttime: %i:%02i:%02i" % (f.getStartdatetime().hour,f.getStartdatetime().minute,f.getStartdatetime().second))
    print("patientcode: %s" % f.getPatientCode())
    print("gender: %s" % f.getGender())
    print("birthdate: %s" % f.getBirthdate())
    print("patient_name: %s" % f.getPatientName())
    print("patient_additional: %s" % f.getPatientAdditional())
    print("admincode: %s" % f.getAdmincode())
    print("technician: %s" % f.getTechnician())
    print("equipment: %s" % f.getEquipment())
    print("recording_additional: %s" % f.getRecordingAdditional())
    print("datarecord duration: %f seconds" % f.getFileDuration())
    print("number of datarecords in the file: %i" % f.datarecords_in_file)
    print("number of annotations in the file: %i" % f.annotations_in_file)

    channel = 3
    print("\nsignal parameters for the %d.channel:\n\n" % channel)

    print("label: %s" % f.getLabel(channel))
    print("samples in file: %i" % f.getNSamples()[channel])
    print("physical maximum: %f" % f.getPhysicalMaximum(channel))
    print("physical minimum: %f" % f.getPhysicalMinimum(channel))
    print("digital maximum: %i" % f.getDigitalMaximum(channel))
    print("digital minimum: %i" % f.getDigitalMinimum(channel))
    print("physical dimension: %s" % f.getPhysicalDimension(channel))
    print("prefilter: %s" % f.getPrefilter(channel))
    print("transducer: %s" % f.getTransducer(channel))
    print("samplefrequency: %f" % f.getSampleFrequency(channel))
Jossef Harush Kadouri
  • 32,361
  • 10
  • 130
  • 129