{"id":16331134,"url":"https://github.com/robertoostenveld/brainvision","last_synced_at":"2025-06-22T20:38:09.768Z","repository":{"id":256302301,"uuid":"854630780","full_name":"robertoostenveld/brainvision","owner":"robertoostenveld","description":"Python implementation to read and write EEG data in the BrainVision Core data format","archived":false,"fork":false,"pushed_at":"2024-09-12T08:05:42.000Z","size":238,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T10:51:16.162Z","etag":null,"topics":["bids","brainvision","eeg","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/brainvision/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertoostenveld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-BSD.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T14:08:48.000Z","updated_at":"2025-01-01T19:30:07.000Z","dependencies_parsed_at":"2024-09-12T13:34:23.517Z","dependency_job_id":null,"html_url":"https://github.com/robertoostenveld/brainvision","commit_stats":null,"previous_names":["robertoostenveld/brainvision"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertoostenveld%2Fbrainvision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertoostenveld%2Fbrainvision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertoostenveld%2Fbrainvision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertoostenveld%2Fbrainvision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertoostenveld","download_url":"https://codeload.github.com/robertoostenveld/brainvision/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238216906,"owners_count":19435614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bids","brainvision","eeg","python"],"created_at":"2024-10-10T23:25:44.161Z","updated_at":"2025-02-11T01:30:40.508Z","avatar_url":"https://github.com/robertoostenveld.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Read and write EEG data in the BrainVision Core data format\n\nThis is a Python implementation to read and write EEG data in the BrainVision Core data format as defined by [BrainProducts](https://www.brainproducts.com/) and as used in [BIDS](https://bids.neuroimaging.io/).\n\nThe BrainVision Core data format consists of three files: the `.vhdr` file with header information, the `.vmrk` with markers or events, and the data in a file that usually has the extension `.eeg`. All files have to be in the same folder.\n\nThe information from the header and marker is not parsed but retained as a dictionary with strings. Below some examples are given to get for example the channel names as list\n\nThis implementation can read from 16 and 32 bit integer formats and 32 bit float formats. It supports multiplexed and vectorized orientations. The data is returned as a channels-by-samples Numpy array with float32 values.\n\n## Installation\n\nThis package is maintained on [PyPi](https://pypi.org/project/brainvision/) and can be installed with pip.\n\n```console\npip install brainvision\n```\n\n## Example\n\nThe following example reads data from disk.\n\n```python\nimport brainvision\n\n# read the data\n(vhdr, vmrk, eeg) = brainvision.read('test/input.vhdr')\n\n# check the size of the data\n(nchans, nsamples) = eeg.shape\nprint(nchans, nsamples)\n\n# parse the header\nnchans = int(vhdr['Common Infos']['NumberOfChannels'])\nfsample = 1000000.0 / float(vhdr['Common Infos']['SamplingInterval'])\nlabels = [item.split(',')[0] for item in vhdr['Channel Infos'].values()]\nunits  = [item.split(',')[3] for item in vhdr['Channel Infos'].values()]\nprint(nchans, fsample, labels, units)\n\n# parse the markers\ntype        = [item.split(',')[0] for item in vmrk['Marker Infos'].values()]\ndescription = [item.split(',')[1] for item in vmrk['Marker Infos'].values()]\nsample      = [int(item.split(',')[2])-1 for item in vmrk['Marker Infos'].values()]   # in data points, 0-based\nduration    = [int(item.split(',')[3])   for item in vmrk['Marker Infos'].values()]   # in data points\nchannel     = [int(item.split(',')[4])   for item in vmrk['Marker Infos'].values()]   # note that this is 1-based\nprint(type, description, sample, duration, channel)\n```\n\nThe following example constructs data from scratch and writes it to disk. Upon writing the header and markerfile, the vhdr and vmrk dictionaries will be validated to ensure that they contain the required fields.\n\n```python\nimport numpy as np\nimport brainvision\n\nvhdr = {'Common Infos': {'Codepage': 'UTF-8', 'DataFile': 'output.eeg', 'MarkerFile': 'output.vmrk', 'DataFormat': 'BINARY', 'DataOrientation': 'MULTIPLEXED', 'NumberOfChannels': '1', 'SamplingInterval': '1000'}, 'Binary Infos': {'BinaryFormat': 'IEEE_FLOAT_32'}, 'Channel Infos': {'Ch1': '1,,0.5,µV'}}\n\nvmrk = {'Common Infos': {'Codepage': 'UTF-8', 'DataFile': 'output.eeg'}, 'Marker Infos': {'Mk1': 'New Segment,,1,1,0'}}\n\nnchans = 1\nnsamples = 1000\nrng = np.random.default_rng()\neeg = rng.standard_normal((nchans, nsamples))\n\n# write the data\nbrainvision.write('output.vhdr', vhdr, vmrk, eeg) \n```\n\n## Known limitations\n\nThis implementation currently cannot read ASCII data.\n\nThis implementation currently cannot deal with little to big endian conversions, hence reading and writing the binary data is only supported on little endian architectures. Apple silicon and Intel-based Mac computers are both little endian. Also Raspberry PI's ARM and Intel NUC's processors are little endian.\n\n## Copyright\n\nCopyright (C) 2024, Robert Oostenveld\n\nThis code is dual-licensed under the BSD 3-Clause \"New\" or \"Revised\" License and under the GPLv3 license, the choice is up to you.\n\nWhen you make changes/iomprovements, please share them back to us so that others benefit as well.\n\n## Acknowledgements\n\nThe test data that is included to demonstrate the functionality and to test the reading and writing originates from the pybv package.\n\n## See also\n\n- https://www.brainproducts.com/support-resources/brainvision-core-data-format-1-0/\n- https://pybv.readthedocs.io/en/stable/\n- https://github.com/bids-standard/pybv/\n- https://github.com/bids-standard/pyedf/\n- https://github.com/fieldtrip/fieldtrip/blob/master/fileio/private/read_brainvision_vhdr.m \n- https://github.com/fieldtrip/fieldtrip/blob/master/fileio/private/read_brainvision_vmrk.m \n- https://github.com/fieldtrip/fieldtrip/blob/master/fileio/private/read_brainvision_eeg.m \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertoostenveld%2Fbrainvision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertoostenveld%2Fbrainvision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertoostenveld%2Fbrainvision/lists"}