智能视觉数据格式的轻量级I/O实用程序。
pybv的Python项目详细描述
PYBV
pybv是BrainVision数据格式的轻量级导出程序。意思是 用于存储在 Brain Imaging Data Structure。
文档可以在以下链接下找到:
关于脑视觉数据格式
BrainVision是一种文件格式的名称,通常用于存储 电生理数据。最初,它是由 公司Brain Products,但是 格式的简单性使得从 按格式书写。
格式由三个独立的文件组成:
- 包含元数据的文本头文件(.vhdr)
- 文本标记文件(.vmrk)包含有关 数据
- 包含eeg电压值的二进制数据文件(.eeg)
两个文本文件都基于 Microsoft Windows INI format 包括:
- 标记为[square brackets] 的节
- 标记为; comment 的注释
- 标记为key=value 的键值对
Brain Products提供了核心BrainVision文件格式的文档。 你可以view the specification 由大脑产品主办。
安装
pybv的唯一依赖项是numpy。但是,我们目前建议 你可以安装mne python来读取脑视觉数据。看他们的指示 here。
安装mne python之后(或者只有numpy,如果 不想读取数据,只想写入它),您可以安装pybv到 如下:pip install -U pybv
使用量
编写脑视觉文件
pybv提供的主要功能是write_brainvision 功能。这将写入一个numpy数据数组并将元数据提供给 磁盘上的脑视觉文件集合。
frompybvimportwrite_brainvision# for further parameters see our API documentation in the docswrite_brainvision(data,sfreq,ch_names,fname,tmpdir,events,resolution=1e-6,fmt='binary_float32')
阅读脑视觉文件
目前,pybv建议使用 MNE-Python 用于读取用pybv编写的BrainVision文件。这将导致 数据的几乎往返转换(达到您的数字精度 在resolution参数中指定)。
下面是读取脑视觉数据所需的mne代码示例:
importmne# Import the BrainVision data into an MNE Raw objectraw=mne.io.read_raw_brainvision('tmp/test.vhdr',preload=True)# Read in the event information as MNE annotationsannot=mne.read_annotations('tmp/test.vmrk')# Add the annotations to our raw object so we can use them with the dataraw.set_annotations(annot)# Reconstruct the original events from our Raw objectevents,event_ids=mne.events_from_annotations(raw)
确认
这个包最初改编自 Philistine package作者 palday。它复制了很多智慧 导出代码,消除对mne的依赖,并将代码集中在 智能输入/输出。