pybv - a lightweight I/O utility for the BrainVision data format
Project description
pybv
For documentation, see the:
pybv is a lightweight I/O utility for the BrainVision data format.
The BrainVision data format is a recommended data format for use in the Brain Imaging Data Structure.
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.9 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:
python -m pip install --upgrade pybv
or if you use conda:
conda install --channel conda-forge pybv
For installing the latest (development) version of pyprep, call:
python -m pip install --upgrade https://github.com/bids-standard/pybv/archive/refs/heads/main.zip
Both the stable and the latest installation will additionally install all required dependencies automatically. The dependencies are defined in the pyproject.toml file under the dependencies and project.optional-dependencies sections.
Contributing
The development of pybv is taking place on GitHub.
For more information, please see CONTRIBUTING.md.
Citing
If you use this software in academic work, please cite it using the Zenodo entry. Metadata is encoded in the CITATION.cff file.
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)
Alternatives
The BrainVision data format is very popular and accordingly there are many software packages to read this format, or write to it. The following table is intended as a quick overview of packages similar to pybv. Please let us know if you know of additional packages that should be listed here.
Name of software |
Language |
Notes |
---|---|---|
miscellaneous |
Reading and writing capabilities depend on bindings used, see their overview |
|
MATLAB |
Read and write, search for brainamp in their io functions |
|
n/a, GUI for Windows |
Read and write, by Brain Products, requires commercial license |
|
Julia |
Read |
|
MATLAB / Octave |
Read and write via BVA-IO |
|
MATLAB |
Read and write, search for brainvision in their ft_read_data and ft_write_data functions |
|
Python |
Read (writing via pybv) |
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.7.6.tar.gz
.
File metadata
- Download URL: pybv-0.7.6.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 518dac9bf151601c45787bf0ddcc5e37afd61033058eb734067825f8ae46d51b |
|
MD5 | 1ac645f9aa474d288e20f4eadeca1049 |
|
BLAKE2b-256 | e7356b61dcca1386b14d368b5f927e1babcf8f6c6171a04e4e21a344d159d857 |
Provenance
The following attestation bundles were made for pybv-0.7.6.tar.gz
:
Publisher:
release.yml
on bids-standard/pybv
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pybv-0.7.6.tar.gz
- Subject digest:
518dac9bf151601c45787bf0ddcc5e37afd61033058eb734067825f8ae46d51b
- Sigstore transparency entry: 151468633
- Sigstore integration time:
- Permalink:
bids-standard/pybv@20c36edc4bec14690195a5470fb218c0b91a8812
- Branch / Tag:
refs/tags/v0.7.6
- Owner: https://github.com/bids-standard
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@20c36edc4bec14690195a5470fb218c0b91a8812
- Trigger Event:
release
- Statement type:
File details
Details for the file pybv-0.7.6-py3-none-any.whl
.
File metadata
- Download URL: pybv-0.7.6-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b2816b3547035c8b806fcca7705c67f8be5c6ca5fee26486754bd492f180139 |
|
MD5 | f06c338614257a150fb24c6eee04ba5c |
|
BLAKE2b-256 | 7d7e0041e56e455d26d5fb644dde3976cffa135e658ac5572c2ca7ab40245af2 |
Provenance
The following attestation bundles were made for pybv-0.7.6-py3-none-any.whl
:
Publisher:
release.yml
on bids-standard/pybv
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pybv-0.7.6-py3-none-any.whl
- Subject digest:
5b2816b3547035c8b806fcca7705c67f8be5c6ca5fee26486754bd492f180139
- Sigstore transparency entry: 151468636
- Sigstore integration time:
- Permalink:
bids-standard/pybv@20c36edc4bec14690195a5470fb218c0b91a8812
- Branch / Tag:
refs/tags/v0.7.6
- Owner: https://github.com/bids-standard
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yml@20c36edc4bec14690195a5470fb218c0b91a8812
- Trigger Event:
release
- Statement type: