A lightweight I/O utility for the BrainVision data format.
Project description
pybv
pybv is a lightweight exporter to the BrainVision data format.
The BrainVision data format is a recommended data format for use in the Brain Imaging Data Structure.
The documentation can be found under the following links:
for the stable release
for the latest (development) version
About the BrainVision data format
BrainVision is the name of a file format commonly used for storing electrophysiology data. Originally, it was put forward by the company Brain Products, however the simplicity of the format has allowed for a diversity of tools reading from and writing to the format.
The format consists of three separate files:
A text header file (.vhdr) containing meta data
A text marker file (.vmrk) containing information about events in the data
A binary data file (.eeg) containing the voltage values of the EEG
Both text files are based on the Microsoft Windows INI format consisting of:
sections marked as [square brackets]
comments marked as ; comment
key-value pairs marked as key=value
The binary .eeg data file is written in little-endian format without a Byte Order Mark (BOM), in accordance with the specification by Brain Products. This ensures that the data file is uniformly written irrespective of the native system architecture.
A documentation for the BrainVision file format is provided by Brain Products. You can view the specification as hosted by Brain Products.
Installation
pybv runs on Python version 3.7 or higher.
pybv’s only dependency is numpy. However, we currently recommend that you install MNE-Python for reading BrainVision data. See their installation instructions.
After you have a working installation of MNE-Python (or only numpy if you do not want to read data and only write it), you can install pybv through the following:
pip install --upgrade pybv
or if you use conda:
conda install --channel conda-forge pybv
Contributing
The development of pybv is taking place on GitHub.
For more information, please see CONTRIBUTING.md
Usage
Writing BrainVision files
The primary functionality provided by pybv is the write_brainvision function. This writes a numpy array of data and provided metadata into a collection of BrainVision files on disk.
from pybv import write_brainvision
# for further parameters see our API documentation
write_brainvision(data=data, sfreq=sfreq, ch_names=ch_names,
fname_base=fname, folder_out=tmpdir,
events=events)
Reading BrainVision files
Currently, pybv recommends using MNE-Python for reading BrainVision files.
Here is an example of the MNE-Python code required to read BrainVision data:
import mne
# Import the BrainVision data into an MNE Raw object
raw = mne.io.read_raw_brainvision('tmp/test.vhdr', preload=True)
# Reconstruct the original events from our Raw object
events, event_ids = mne.events_from_annotations(raw)
Acknowledgements
This package was originally adapted from the Philistine package by palday. It copies much of the BrainVision exporting code, but removes the dependence on MNE. Several features have been added, such as support for individual units for each channel.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pybv-0.6.0.tar.gz
.
File metadata
- Download URL: pybv-0.6.0.tar.gz
- Upload date:
- Size: 255.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef1104cfcd66dafb7383dc539fe688ebcd6822bffe0f0f743292853586e74ffa |
|
MD5 | 62f13ff9166d49b9788a844d8efb41b3 |
|
BLAKE2b-256 | fe26fbb29b363a3828b07c4d089611720d51de24f284337482144b40f0a04350 |
File details
Details for the file pybv-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: pybv-0.6.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bff80d3d44b088a98a7df2877b4d70595dbfbef3a200a10a67acb0c99ba7553 |
|
MD5 | 39d2e7cca96598d2aa4b242e818b299a |
|
BLAKE2b-256 | 48319077784e2d5baa994fb61e266105096b7dc196902134777a3d876ddea412 |