Package: pybv
pybvpybvis a lightweight I/O utility for the BrainVision data format.The BrainVision data format is a recommended data format for use in theBrain Imaging Data Structure.The documentation can be found under the following links:for thestable releasefor thelatest (development) versionAbout the BrainVision data formatBrainVision is the name of a file format commonly used for storing electrophysiology data.
Originally, it was put forward by the companyBrain 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 dataA text marker file (.vmrk) containing information about events in the
dataA binary data file (.eeg) containing the voltage values of the EEGBoth text files are based on theMicrosoft Windows INI formatconsisting of:sections marked as[square brackets]comments marked as; commentkey-value pairs marked askey=valueThe binary.eegdata 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 canview the specificationas hosted by Brain Products.Installationpybvruns on Python version 3.7 or higher.pybv’s only dependency isnumpy.
However, we currently recommend that you install MNE-Python for reading BrainVision data.
See theirinstallation instructions.After you have a working installation of MNE-Python (or onlynumpyif you
do not want to read data and only write it), you can installpybvthrough
the following:pip install--upgradepybvor if you useconda:conda install--channelconda-forgepybvContributingThe development ofpybvis taking place onGitHub.For more information, please seeCONTRIBUTING.mdUsageWriting BrainVision filesThe primary functionality provided bypybvis thewrite_brainvisionfunction. This writes a numpy array of data and provided metadata into a
collection of BrainVision files on disk.frompybvimportwrite_brainvision# for further parameters see our API documentationwrite_brainvision(data=data,sfreq=sfreq,ch_names=ch_names,fname_base=fname,folder_out=tmpdir,events=events)Reading BrainVision filesCurrently,pybvrecommends usingMNE-Pythonfor reading BrainVision files.Here is an example of the MNE-Python code required to read BrainVision data:importmne# Import the BrainVision data into an MNE Raw objectraw=mne.io.read_raw_brainvision('tmp/test.vhdr',preload=True)# Reconstruct the original events from our Raw objectevents,event_ids=mne.events_from_annotations(raw)AlternativesThe 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 topybv.
Please let us know if you know of additional packages that should be listed here.Name of softwareLanguageNotesBioSig ProjectmiscellaneousReading and writing capabilities depend on bindings used, see theiroverviewBrainstormMATLABRead and write, search forbrainampin theirio functionsBrainVision Analyzern/a, GUI for WindowsRead and write, by Brain Products, requires commercial licensebrainvisionloader.jlJuliaReadEEGLABMATLAB / OctaveRead and write viaBVA-IOFieldTripMATLABRead and write, search forbrainvisionin theirfileio functionsMNE-PythonPythonRead (writing viapybv)AcknowledgementsThis package was originally adapted from thePhilistine packagebypalday.
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.