Skip to content

Commit da9912e

Browse files
committed
Test 1-based marker positions on the gin BrainVision file instead of generated files
1 parent 27008b7 commit da9912e

1 file changed

Lines changed: 6 additions & 45 deletions

File tree

‎neo/test/rawiotest/test_brainvisionrawio.py‎

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
""" """
22

3-
import tempfile
43
import unittest
5-
from pathlib import Path
64

75
import numpy as np
86

@@ -27,50 +25,13 @@ class TestBrainVisionRawIO(
2725

2826
entities_to_download = ["brainvision"]
2927

30-
31-
class TestBrainVisionRawIOMarkers(unittest.TestCase):
3228
def test_marker_positions_are_one_based(self):
33-
vhdr = (
34-
"Brain Vision Data Exchange Header File Version 1.0\n"
35-
"[Common Infos]\n"
36-
"Codepage=UTF-8\n"
37-
"DataFile=test.eeg\n"
38-
"MarkerFile=test.vmrk\n"
39-
"DataFormat=BINARY\n"
40-
"DataOrientation=MULTIPLEXED\n"
41-
"NumberOfChannels=1\n"
42-
"SamplingInterval=1000\n"
43-
"[Binary Infos]\n"
44-
"BinaryFormat=INT_16\n"
45-
"[Channel Infos]\n"
46-
"Ch1=Fp1,,1,µV\n"
47-
)
48-
vmrk = (
49-
"Brain Vision Data Exchange Marker File, Version 1.0\n"
50-
"[Marker Infos]\n"
51-
"Mk1=New Segment,,1,1,0\n"
52-
"Mk2=Stimulus,S 1,11,1,0\n"
53-
)
54-
with tempfile.TemporaryDirectory() as tmp_dir:
55-
tmp_dir = Path(tmp_dir)
56-
(tmp_dir / "test.vhdr").write_text(vhdr, encoding="utf8")
57-
(tmp_dir / "test.vmrk").write_text(vmrk, encoding="utf8")
58-
np.arange(20, dtype="int16").tofile(tmp_dir / "test.eeg")
59-
60-
reader = BrainVisionRawIO(filename=tmp_dir / "test.vhdr")
61-
reader.parse_header()
62-
event_names = list(reader.header["event_channels"]["name"])
63-
64-
# position 1 is the first data point, so it is sample 0 and time 0 s
65-
timestamps, _, _ = reader.get_event_timestamps(event_channel_index=event_names.index("New Segment"))
66-
np.testing.assert_array_equal(timestamps, [0])
67-
68-
# position 11 is sample 10, 10 ms into the recording at 1 kHz
69-
timestamps, _, labels = reader.get_event_timestamps(event_channel_index=event_names.index("Stimulus"))
70-
np.testing.assert_array_equal(timestamps, [10])
71-
np.testing.assert_array_equal(labels, ["S 1"])
72-
times = reader.rescale_event_timestamp(timestamps, event_channel_index=event_names.index("Stimulus"))
73-
np.testing.assert_allclose(times, [0.010])
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)
7435

7536

7637
if __name__ == "__main__":

0 commit comments

Comments
 (0)