将眼动仪.edf文件转换为ASC / CSV格式 [英] convert eye-tracking .edf file to ASC/CSV format

查看:812
本文介绍了将眼动仪.edf文件转换为ASC / CSV格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以.edf格式(SR-RESEARCH眼线)记录了跟踪数据。我想将其转换为python中的ASC / CSV格式。我有GUI应用程序,但我想以编程方式(在Python中)进行操作。
我找到了pyEDFlib包,但找不到将眼动追踪的.edf文件转换为.asc或.csv的示例。

I have a recording of tracking data in .edf format (SR-RESEARCH eyelink). I want to convert it to ASC/CSV format in python. I have the GUI application but I want to do it programmatically (in Python). I found the package pyEDFlib but couldn't find an example to how convert the eye-tracking .edf file to .asc or .csv.

做到这一点的最佳方法是什么?

What will the best best way to do it?

谢谢

推荐答案

如果我信任此处的页面: http ://pyedflib.readthedocs.io/en/latest ,您可以通过以下方式遍历文件中的所有信号:

If I trust the page here: http://pyedflib.readthedocs.io/en/latest, you can run through all the signals in the file this way:

import pyedflib
import numpy as np

f = pyedflib.EdfReader("data/test_generator.edf")
n = f.signals_in_file
signal_labels = f.getSignalLabels()
sigbufs = np.zeros((n, f.getNSamples()[0]))
for i in np.arange(n):
    sigbufs[i, :] = f.readSignal(i)

pyEDFlib 库只是将文件读入EdfReader对象。
然后,您只需要遍历每个行。

The pyEDFlib library simply reads the file into an EdfReader object. Then you just need to go through and make row for each.

我假设 signal_labels (在上面的代码中)将是一个包含所有标签的数组,因此请使用逗号分隔字符串

I assume that signal_labels (in the code above) will be an array with all the labels so make a comma separated string out of them

signal_labels_row = ",".join(signal_labels)

然后对每个信号执行相同操作,每个逗号分隔1个字符串

Then do the same for each signal, 1 comma separated String for each

然后只需将它们写到文件中即可。

Then simply write them in a file.

我可以看到它们提供了如何读取文件的示例并在此处提取您需要的所有数据
https:// github.com/holgern/pyedflib/blob/master/demo/readEDFFile.py

I can see they provide an example of how to read a file and extract all the data you need here https://github.com/holgern/pyedflib/blob/master/demo/readEDFFile.py

这篇关于将眼动仪.edf文件转换为ASC / CSV格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆