Skip to main content

Python PyPI License

PyBVRF

PyBVRF is a Python package for working with BVRF (BrainVision Recording Format) files.

The package includes the following features:

  • Support for multi-participant recordings
  • Seamless integration with MNE-Python
  • Convenient access to metadata (including the original YAML header)
  • Support for markers and impedance data

A BVRF recording consists of multiple files which are expected to be available in the same directory. The required files are:

  • <fname>.bvrh (header file)
  • <fname>.bvrd (data file)
  • <fname>.bvrm (marker file)

Optionally, <fname>.bvri (impedance file) may also be present.

Basic usage

Use read_bvrf() to load a recording. The file extension is optional (the function accepts any of the four supported extensions or just the base filename).

from pybvrf import read_bvrf

header, data, markers, impedances = read_bvrf("recording")

Here, header is a dict containing metadata about the recording (such as sampling frequency, channel names, and participant information):

print(f"Sampling frequency: {header['fs']} Hz")
print(f"Number of channels: {header['n_channels']}")
print(f"Channel names: {header['ch_names']}")
print(f"Number of participants: {header['n_participants']}")

The entire original header information is available as header["yaml_header"] (a dict parsed from the YAML header file).

Next, data is a 2D NumPy array (channels ⨉ samples) containing the EEG signals:

print(f"Data shape: {data.shape}")

Finally, markers contains information about events in a NumPy structured array:

print(f"Number of markers: {len(markers)}")
print(f"Marker fields: {markers.dtype.names}")

If impedances are available, impedances is a dict mapping channel names to impedance values:

if impedances:
    print(f"Impedances: {impedances}")

Advanced usage

Multi-participant recordings (header["n_participants"] > 1) are available in a single data structure by default, with channels from all participants concatenated together (but suffixed with the participant ID). For example, if there are two participants P1 and P2, the channel names might be "C3 (P1)", "Cz (P1)", "C4 (P1)", "C3 (P2)", "Cz (P2)", and "C4 (P2)". You can use split_participants() to split the data into separate data structures per participant:

from pybvrf import split_participants

participant_data = split_participants(header, data, markers, impedances)

This returns a dict mapping participant IDs to their respective data (a tuple of header, data, markers, and impedances).

MNE-Python integration

PyBVRF optionally integrates with MNE-Python for advanced EEG analysis (to use this feature, make sure to install the mne extra via pybvrf[mne]). You can then use the read_raw_bvrf() function to load a BVRF recording directly into an MNE Raw object:

from pybvrf import read_raw_bvrf

raw = read_raw_bvrf("recording.bvrh")

Like read_bvrf(), read_raw_bvrf() accepts any of the four supported file extensions or just the base filename. It returns a Raw object containing the EEG data, along with the appropriate metadata and annotations.

If a recording includes multiple participants, the function returns a single Raw object by default, with all participants' data concatenated (channel names are suffixed with the participant ID as described above).

You can also load selected participants and/or split multi-participant recordings into separate Raw objects:

from pybvrf import read_raw_bvrf

# load specific participants
raw = read_raw_bvrf("multi_recording.bvrh", participants="P1")
raw = read_raw_bvrf("multi_recording.bvrh", participants=["P1", "P2"])

# split into separate Raw objects per participant
raw_dict = read_raw_bvrf("multi_recording.bvrh", split=True)
for pid, raw in raw_dict.items():
    print(f"Participant {pid}: {raw.info['nchan']} channels")
    
# load specific participants and split
raw_dict = read_raw_bvrf("multi_recording.bvrh", participants=["P1", "P3"], split=True)

Acknowledgements

The initial release of PyBVRF was sponsored by Brain Products.

Metadata

Release files for pybvrf 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybvrf 0.2.0
File Size Uploaded Provenance Actions
pybvrf-0.2.0.tar.gz 13.2 kB Without provenance Details for pybvrf-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pybvrf 0.2.0
File Interpreter ABI Platform Actions
pybvrf-0.2.0-py3-none-any.whl Python 3 none any Details for pybvrf-0.2.0-py3-none-any.whl

Total release size: 28.2 kB

Release files / pybvrf-0.2.0.tar.gz

Download URL pybvrf-0.2.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
048966231734d1be41c7dedbe28041123ae77aae81c264c7308ac1c8e4f85714
BLAKE2b-256 checksum
How to use checksums
a8aea846b3497d0e50a61c234651cbd5e3041d520a4bd03260ec37c964be7d04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pybvrf-0.2.0-py3-none-any.whl

Download URL pybvrf-0.2.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70265a0f34b4c71f6a6d533f906eaa3e13b89af05a2f1edbd2ef05cfaa6526b6
BLAKE2b-256 checksum
How to use checksums
2519dc4355112a20a89212600d1d8da979d0ad91931ac7964b6ae72443b3b886
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pybvrf 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page