Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved brainvision header parsing. #1560

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions neo/rawio/brainvisionrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,22 @@ def _parse_header(self):
channel_desc = channel_infos[f"Ch{c+1}"]
except KeyError:
channel_desc = channel_infos[f"ch{c + 1}"]
name, ref, res, units = channel_desc.split(",")
units = units.replace("µ", "u")
# split up channel description, handling default values
cds = channel_desc.split(",")
name = cds[0]
if len(cds) >= 2:
ref = cds[1]
else:
ref = ""
if len(cds) >= 3:
res = cds[2]
else:
res = "1.0"
if len(cds) == 4:
units = cds[3]
else:
units = "u"
units = units.replace("µ", "u") # Brainvision spec for specific unicode
chan_id = str(c + 1)
if sig_dtype == np.int16 or sig_dtype == np.int32:
gain = float(res)
Expand Down
1 change: 1 addition & 0 deletions neo/test/rawiotest/test_brainvisionrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TestBrainVisionRawIO(
"brainvision/File_brainvision_3_float32.vhdr",
"brainvision/File_brainvision_3_int16.vhdr",
"brainvision/File_brainvision_3_int32.vhdr",
"brainvision/File_brainvision_4_float32.vhdr",
]

entities_to_download = ["brainvision"]
Expand Down
Loading