跳转到主要内容

Python库,用于导入XDF(可扩展数据格式)

项目描述

Latest PyPI Release Latest Conda Release Python 3.9+ License

pyXDF

pyXDF是XDF文件的Python导入器。

示例用法

import matplotlib.pyplot as plt
import numpy as np

import pyxdf

data, header = pyxdf.load_xdf("test.xdf")

for stream in data:
    y = stream["time_series"]

    if isinstance(y, list):
        # list of strings, draw one vertical line for each marker
        for timestamp, marker in zip(stream["time_stamps"], y):
            plt.axvline(x=timestamp)
            print(f'Marker "{marker[0]}" @ {timestamp:.2f}s')
    elif isinstance(y, np.ndarray):
        # numeric data, draw as lines
        plt.plot(stream["time_stamps"], y)
    else:
        raise RuntimeError("Unknown stream format")

plt.show()

命令行示例

pyxdf有一个examples模块,可以从命令行运行以执行基本功能。

  • print_metadata 将启用 DEBUG 记录器记录读取的消息,然后它会打印出每个找到的流的基本元数据。
    • python -m pyxdf.examples.print_metadata -f=/path/to/my.xdf
  • playback_lsl 将打开一个 XDF 文件,然后以无限循环的形式回放其数据,但使用当前的时间戳。这对于原型在线处理很有用。
    • python -m pyxdf.examples.playback_lsl /path/to/my.xdf

安装

可以使用 pip install pyxdf 安装最新稳定版本。

对于最新开发版本,使用 pip install git+https://github.com/xdf-modules/pyxdf.git

对于维护者

新版本会自动上传到 PyPI。因此,一旦在 GitHub 上(使用标记例如 v1.16.3)创建了新版本,就会创建一个与版本标签匹配的 PyPI 软件包。

项目详情


下载文件

下载适合您平台文件的文件。如果您不确定选择哪个,请了解有关 安装软件包 的更多信息。

源代码发行版

pyxdf-1.16.8.tar.gz (21.7 kB 查看哈希)

上传时间 源代码

构建发行版

pyxdf-1.16.8-py2.py3-none-any.whl (17.1 kB 查看哈希)

上传时间 Python 2 Python 3

支持者