From ffcc39423ea8c872be1f4df8aaeb4867e6497a52 Mon Sep 17 00:00:00 2001 From: Luigi Petrucco Date: Mon, 2 Dec 2024 15:04:57 +0100 Subject: [PATCH] test events reading --- .../rawiotest/test_openephysbinaryrawio.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/neo/test/rawiotest/test_openephysbinaryrawio.py b/neo/test/rawiotest/test_openephysbinaryrawio.py index 7df22e93d..0959ddf62 100644 --- a/neo/test/rawiotest/test_openephysbinaryrawio.py +++ b/neo/test/rawiotest/test_openephysbinaryrawio.py @@ -3,6 +3,8 @@ from neo.rawio.openephysbinaryrawio import OpenEphysBinaryRawIO from neo.test.rawiotest.common_rawio_test import BaseTestRawIO +import numpy as np + class TestOpenEphysBinaryRawIO(BaseTestRawIO, unittest.TestCase): rawioclass = OpenEphysBinaryRawIO @@ -57,6 +59,25 @@ def test_missing_folders(self): ) rawio.parse_header() + def test_multiple_ttl_events_parsing(self): + rawio = OpenEphysBinaryRawIO( + self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"), load_sync_channel=False + ) + rawio.parse_header() + rawio.header = rawio.header + # Testing co + # This is the TTL events from the NI Board channel + ttl_events = rawio._evt_streams[0][0][1] + assert "rising" in ttl_events.keys() + assert "labels" in ttl_events.keys() + assert "durations" in ttl_events.keys() + assert "timestamps" in ttl_events.keys() + + # Check that durations of different event streams are correctly parsed: + assert np.allclose(ttl_events["durations"][ttl_events["labels"] == "1"], 0.5, atol=0.001) + assert np.allclose(ttl_events["durations"][ttl_events["labels"] == "6"], 0.025, atol=0.001) + assert np.allclose(ttl_events["durations"][ttl_events["labels"] == "7"], 0.016666, atol=0.001) + if __name__ == "__main__": unittest.main()