Skip to content

Commit

Permalink
Merge pull request #1560 from PeterNSteinmetz/BrainvisionHeaderParse
Browse files Browse the repository at this point in the history
Improved brainvision header parsing.
  • Loading branch information
zm711 authored Sep 23, 2024
2 parents 4f9cc85 + 08ca180 commit eaa6903
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit eaa6903

Please sign in to comment.