Skip to content

Commit 97b12ee

Browse files
authored
Merge pull request #1933 from aaronkanzer/fix/brainvision-marker-positions
BrainVisionRawIO: read marker positions as 1-based
2 parents 80e8d6b + da9912e commit 97b12ee

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

‎doc/source/authors.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ and may not be the current affiliation of a contributor.
107107
* Stanley C.
108108
* Axel Coiffard-Donaty
109109
* Anthony Mercer
110+
* Aaron Kanzer [53]
110111

111112
1. Centre de Recherche en Neuroscience de Lyon, CNRS UMR5292 - INSERM U1028 - Université Claude Bernard Lyon 1
112113
2. Unité de Neuroscience, Information et Complexité, CNRS UPR 3293, Gif-sur-Yvette, France
@@ -160,6 +161,7 @@ and may not be the current affiliation of a contributor.
160161
50. Ludwig-Maximilians-Universität München, Munich, Germany
161162
51. Stony Brook University, Stony Brook, NY, USA
162163
52. University of Sussex, Brighton, UK
164+
53. Scigantic, USA
163165

164166

165167

‎neo/rawio/brainvisionrawio.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ def _parse_header(self):
166166
for i in range(len(all_info)):
167167
ev_type, ev_label, pos, size, channel = all_info[f"Mk{i+1}"].split(",")[:5]
168168
ev_types.append(ev_type)
169-
ev_timestamps.append(int(pos))
169+
# Marker positions are 1-based (the first data point is position 1), see
170+
# section 4.3 of the BrainVision Core Data Format 1.0 specification:
171+
# https://www.brainproducts.com/download/specification-of-brainvision-core-data-format-1-0/
172+
ev_timestamps.append(int(pos) - 1)
170173
ev_labels.append(ev_label)
171174
ev_types = np.array(ev_types)
172175
ev_timestamps = np.array(ev_timestamps)

‎neo/test/rawiotest/test_brainvisionrawio.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import unittest
44

5+
import numpy as np
6+
57
from neo.rawio.brainvisionrawio import BrainVisionRawIO
68

79
from neo.test.rawiotest.common_rawio_test import BaseTestRawIO
@@ -23,6 +25,14 @@ class TestBrainVisionRawIO(
2325

2426
entities_to_download = ["brainvision"]
2527

28+
def test_marker_positions_are_one_based(self):
29+
# SegmentDataPoints=294 in the .vhdr and a "New Segment" marker on the first sample of each of the 34 segments
30+
reader = BrainVisionRawIO(self.get_local_path("brainvision/File_brainvision_3_int16.vhdr"))
31+
reader.parse_header()
32+
event_names = list(reader.header["event_channels"]["name"])
33+
timestamps, _, _ = reader.get_event_timestamps(event_channel_index=event_names.index("New Segment"))
34+
np.testing.assert_array_equal(timestamps, np.arange(34) * 294)
35+
2636

2737
if __name__ == "__main__":
2838
unittest.main()

0 commit comments

Comments
 (0)