Skip to content

Commit ffcc394

Browse files
committed
test events reading
1 parent 540a1ab commit ffcc394

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

neo/test/rawiotest/test_openephysbinaryrawio.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from neo.rawio.openephysbinaryrawio import OpenEphysBinaryRawIO
44
from neo.test.rawiotest.common_rawio_test import BaseTestRawIO
55

6+
import numpy as np
7+
68

79
class TestOpenEphysBinaryRawIO(BaseTestRawIO, unittest.TestCase):
810
rawioclass = OpenEphysBinaryRawIO
@@ -57,6 +59,25 @@ def test_missing_folders(self):
5759
)
5860
rawio.parse_header()
5961

62+
def test_multiple_ttl_events_parsing(self):
63+
rawio = OpenEphysBinaryRawIO(
64+
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"), load_sync_channel=False
65+
)
66+
rawio.parse_header()
67+
rawio.header = rawio.header
68+
# Testing co
69+
# This is the TTL events from the NI Board channel
70+
ttl_events = rawio._evt_streams[0][0][1]
71+
assert "rising" in ttl_events.keys()
72+
assert "labels" in ttl_events.keys()
73+
assert "durations" in ttl_events.keys()
74+
assert "timestamps" in ttl_events.keys()
75+
76+
# Check that durations of different event streams are correctly parsed:
77+
assert np.allclose(ttl_events["durations"][ttl_events["labels"] == "1"], 0.5, atol=0.001)
78+
assert np.allclose(ttl_events["durations"][ttl_events["labels"] == "6"], 0.025, atol=0.001)
79+
assert np.allclose(ttl_events["durations"][ttl_events["labels"] == "7"], 0.016666, atol=0.001)
80+
6081

6182
if __name__ == "__main__":
6283
unittest.main()

0 commit comments

Comments
 (0)