Skip to main content

A lightweight I/O utility for the BrainVision data format.

Project description

CircleCI codecov pypi Downloads Documentation Status

pybv

pybv is a lightweight exporter to the BrainVision data format. It is meant for use with electrophysiology datasets stored in the Brain Imaging Data Structure.

The documentation can be found under the following links:

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:

  1. A text header file (.vhdr) containing meta data

  2. A text marker file (.vmrk) containing information about events in the data

  3. 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

A documentation for core BrainVision file format is provided by Brain Products. You can view the specification as hosted by Brain Products.

Installation

pybv’s only dependency is numpy. However, we currently recommend that you install MNE-Python for reading BrainVision data. See their instructions here.

After you have a working installation of MNE-Python (or only numpy if you don’t want to read data and only write it), you can install pybv through the following: pip install -U 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 in the docs
write_brainvision(data, sfreq, ch_names, fname, tmpdir, events,
                  resolution=1e-6, unit='µV', fmt='binary_float32')

Reading BrainVision files

Currently, pybv recommends using MNE-Python for reading BrainVision files written with pybv. This results in a nearly-round-trip conversion of the data (up to the numerical precision you specify in the resolution parameter).

Here is an example of the MNE code required to read in BrainVision data:

import mne

# Import the BrainVision data into an MNE Raw object
raw = mne.io.read_raw_brainvision('tmp/test.vhdr', preload=True)

# Read in the event information as MNE annotations
annot = mne.read_annotations('tmp/test.vmrk')

# Add the annotations to our raw object so we can use them with the data
raw.set_annotations(annot)

# 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, removes the dependence on MNE, and focuses the code around BrainVision I/O.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybv-0.3.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

pybv-0.3.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file pybv-0.3.0.tar.gz.

File metadata

  • Download URL: pybv-0.3.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.10

File hashes

Hashes for pybv-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f9060eaa7950c94e36653ee68138e4662cd840d40e5c0e981f99240aab28f48a
MD5 7a12f0662bf210c712d17538ac6426f2
BLAKE2b-256 72d75294e91189d0317da46fb47ca93f6e67041d1a92c3b9bca1f3914592f7f2

See more details on using hashes here.

File details

Details for the file pybv-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pybv-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.10

File hashes

Hashes for pybv-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22085b8f7dca90388b1fb00894a07d298ac6aed602aede84b2748ba3d3f719ea
MD5 06823ca315d3cc9bdf76701c90155aa8
BLAKE2b-256 f0fc9431e681042609af2878215523f4f82f4c1a1514e890cca1ec4853f06d7c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page