Skip to content

Commit 3e1716f

Browse files
authored
Merge pull request #1552 from nikhilchandra/add_test_for_pl2_channel_enabled_bug
Added unit test to check whether channels that contain data are ident…
2 parents e8ea631 + d0acc4b commit 3e1716f

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

neo/test/rawiotest/test_plexon2rawio.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from neo.test.rawiotest.common_rawio_test import BaseTestRawIO
1111

12+
from numpy.testing import assert_equal
1213

1314
try:
1415
from neo.rawio.plexon2rawio.pypl2 import pypl2lib
@@ -25,8 +26,45 @@ class TestPlexon2RawIO(
2526
):
2627
rawioclass = Plexon2RawIO
2728
entities_to_download = ["plexon"]
28-
entities_to_test = ["plexon/4chDemoPL2.pl2"]
29+
entities_to_test = ["plexon/4chDemoPL2.pl2",
30+
"plexon/NC16FPSPKEVT_1m.pl2"
31+
]
32+
2933

34+
def test_check_enabled_flags(self):
35+
"""
36+
This test loads a 1-minute PL2 file with 16 channels' each
37+
of field potential (FP), and spike (SPK) data. The channels
38+
cycle through 4 possible combinations of m_ChannelEnabled
39+
and m_ChannelRecordingEnabled - (True, True), (True, False),
40+
(False, True), and (False, False). With 16 channels for each
41+
source, each combination of flags occurs 4 times. Only the
42+
first combination (True, True) causes data to be recorded to
43+
disk. Therefore, we expect the following channels to be loaded by
44+
Neo: FP01, FP05, FP09, FP13, SPK01, SPK05, SPK09, and SPK13.
45+
46+
Note: the file contains event (EVT) data as well. Although event
47+
channel headers do contain m_ChannelEnabled and m_ChannelRecording-
48+
Enabled flags, the UI for recording PL2 files does not expose any
49+
controls by which these flags can be changed from (True, True).
50+
Therefore, no test for event channels is necessary here.
51+
"""
52+
53+
# Load data from NC16FPSPKEVT_1m.pl2, a 1-minute PL2 recording containing
54+
# 16-channels' each of field potential (FP), spike (SPK), and event (EVT)
55+
# data.
56+
reader = Plexon2RawIO(filename=self.get_local_path("plexon/NC16FPSPKEVT_1m.pl2"))
57+
reader.parse_header()
58+
59+
# Check that the names of the loaded signal channels match what we expect
60+
signal_channel_names = reader.header["signal_channels"]["name"].tolist()
61+
expected_signal_channel_names = ["FP01","FP05","FP09","FP13"]
62+
assert_equal(signal_channel_names, expected_signal_channel_names)
63+
64+
# Check that the names of the loaded spike channels match what we expect
65+
spike_channel_names = reader.header["spike_channels"]["name"].tolist()
66+
expected_spike_channel_names = ["SPK01.0", "SPK05.0", "SPK09.0", "SPK13.0"]
67+
assert_equal(spike_channel_names, expected_spike_channel_names)
3068

3169
if __name__ == "__main__":
3270
unittest.main()

0 commit comments

Comments
 (0)