Skip to content

Commit d51dab7

Browse files
committed
Fix tests and array_annotations for SYNC channel
1 parent f7a7c8f commit d51dab7

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

neo/rawio/openephysbinaryrawio.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,17 @@ def _parse_header(self):
513513
if has_sync_trace:
514514
values = values[:-1]
515515

516-
neural_channels = [ch for ch in info["channels"] if "ADC" not in ch["channel_name"]]
517-
num_neural_channels = len(neural_channels)
518-
if is_neural_stream:
519-
values = values[:num_neural_channels]
520-
else:
521-
values = values[num_neural_channels:]
516+
if "SYNC" in stream_name and not self.load_sync_channel:
517+
# This is the sync stream, we only keep the last value
518+
values = values[-1:]
519+
520+
if "OneBox" not in info["stream_name"]:
521+
neural_channels = [ch for ch in info["channels"] if "ADC" not in ch["channel_name"]]
522+
num_neural_channels = len(neural_channels)
523+
if is_neural_stream:
524+
values = values[:num_neural_channels]
525+
else:
526+
values = values[num_neural_channels:]
522527

523528
sig_ann["__array_annotations__"][key] = values
524529

neo/test/rawiotest/test_openephysbinaryrawio.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ class TestOpenEphysBinaryRawIO(BaseTestRawIO, unittest.TestCase):
2121
]
2222

2323
def test_sync(self):
24-
rawio_with_sync = OpenEphysBinaryRawIO(
25-
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"), load_sync_channel=True
26-
)
27-
rawio_with_sync.parse_header()
24+
with self.assertWarns(DeprecationWarning):
25+
rawio_with_sync = OpenEphysBinaryRawIO(
26+
self.get_local_path("openephysbinary/v0.6.x_neuropixels_with_sync"), load_sync_channel=True
27+
)
28+
rawio_with_sync.parse_header()
2829
stream_name = [s_name for s_name in rawio_with_sync.header["signal_streams"]["name"] if "AP" in s_name][0]
2930
stream_index = list(rawio_with_sync.header["signal_streams"]["name"]).index(stream_name)
3031

@@ -70,10 +71,11 @@ def test_sync_channel_access(self):
7071
def test_no_sync(self):
7172
# requesting sync channel when there is none raises an error
7273
with self.assertRaises(ValueError):
73-
rawio_no_sync = OpenEphysBinaryRawIO(
74-
self.get_local_path("openephysbinary/v0.6.x_neuropixels_multiexp_multistream"), load_sync_channel=True
75-
)
76-
rawio_no_sync.parse_header()
74+
with self.assertWarns(DeprecationWarning):
75+
rawio_no_sync = OpenEphysBinaryRawIO(
76+
self.get_local_path("openephysbinary/v0.6.x_neuropixels_multiexp_multistream"), load_sync_channel=True
77+
)
78+
rawio_no_sync.parse_header()
7779

7880
def test_missing_folders(self):
7981
# missing folders should raise an error

0 commit comments

Comments
 (0)