我需要使用Python文件从.EDF中读取数据并将其保存为.txt格式。
我找到了执行此操作的python库,但是在运行时会发生错误。我刚刚开始学习Python。
我请你帮我!
链接到我尝试使用的.EDF文件转换代码:
http://csl-sessions.blogspot.ru/2014/06/program-to-convert-files-edf-to-txt.html

.EDF下载文件链接:https://cloud.mail.ru/public/CUtc/WrFkpHMDd

如果您知道另一种帮助我的方法,我将不胜感激。

最佳答案

使用pyedflib-一个python库来解析.edf文件。 (在文件上运行one of their examples

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



来源-https://github.com/holgern/pyedflib/blob/master/demo/readEDFFile.py

关于python - 在.txt中的Python上转换.EDF文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38145941/

10-14 04:52