99
1010from probeinterface import read_openephys
1111from probeinterface .neuropixels_tools import _parse_openephys_settings , _select_openephys_probe_info
12- from probeinterface .neuropixels_tools import _slice_catalogue_probe , build_neuropixels_probe , read_openephys_binary
12+ from probeinterface .neuropixels_tools import _slice_catalogue_probe , build_neuropixels_probe
1313from probeinterface .testing import validate_probe_dict
1414
1515data_path = Path (__file__ ).absolute ().parent .parent / "data" / "openephys"
@@ -469,7 +469,7 @@ def _read_oebin_electrode_indices(oebin_file, stream_name):
469469 return []
470470
471471
472- def test_read_openephys_binary_wiring ():
472+ def test_read_openephys_with_oebin_wiring ():
473473 """Verify wiring invariant: for each contact, the oebin's electrode_index at the
474474 assigned binary column matches the contact's electrode index."""
475475 settings = data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml"
@@ -478,7 +478,7 @@ def test_read_openephys_binary_wiring():
478478 )
479479 stream_name = "Neuropix-PXI-100.ProbeA"
480480
481- probe = read_openephys_binary (settings , oebin , stream_name )
481+ probe = read_openephys (settings , stream_name = stream_name , oebin_file = oebin )
482482
483483 assert probe .get_contact_count () == 384
484484 assert probe .device_channel_indices is not None
@@ -494,31 +494,36 @@ def test_read_openephys_binary_wiring():
494494 )
495495
496496
497- def test_read_openephys_binary_contact_ids_match_canonical_pattern ():
498- """Verify that read_openephys_binary contact_ids are consistent with SpikeGLX (issue #394)."""
497+ def test_read_openephys_with_oebin_contact_ids_match_canonical_pattern ():
498+ """Verify that contact_ids with oebin are consistent with SpikeGLX (issue #394)."""
499499 # NP2014 single-shank
500- probe = read_openephys_binary (
500+ probe = read_openephys (
501501 data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml" ,
502- data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "experiment1" / "recording1" / "structure.oebin" ,
503- "Neuropix-PXI-100.ProbeA" ,
502+ stream_name = "Neuropix-PXI-100.ProbeA" ,
503+ oebin_file = data_path
504+ / "OE_Neuropix-PXI-NP1-binary"
505+ / "Record_Node_101"
506+ / "experiment1"
507+ / "recording1"
508+ / "structure.oebin" ,
504509 )
505510 _assert_contact_ids_match_canonical_pattern (probe , "NP2014 binary" )
506511
507512 # NP1032 4-shank
508- probe = read_openephys_binary (
513+ probe = read_openephys (
509514 data_path / "OE_Neuropix-PXI-NP2-4shank-binary" / "Record_Node_101" / "settings.xml" ,
510- data_path
515+ stream_name = "Neuropix-PXI-100.ProbeA-AP" ,
516+ oebin_file = data_path
511517 / "OE_Neuropix-PXI-NP2-4shank-binary"
512518 / "Record_Node_101"
513519 / "experiment4"
514520 / "recording2"
515521 / "structure.oebin" ,
516- "Neuropix-PXI-100.ProbeA-AP" ,
517522 )
518523 _assert_contact_ids_match_canonical_pattern (probe , "NP1032 binary" )
519524
520525
521- def test_read_openephys_binary_sync_channel_filtered ():
526+ def test_read_openephys_with_oebin_sync_channel_filtered ():
522527 """Verify that the oebin sync channel (385 channels) is filtered, producing 384 contacts."""
523528 settings = data_path / "OE_Neuropix-PXI-NP2-4shank-binary" / "Record_Node_101" / "settings.xml"
524529 oebin = (
@@ -530,90 +535,34 @@ def test_read_openephys_binary_sync_channel_filtered():
530535 / "structure.oebin"
531536 )
532537
533- probe = read_openephys_binary (settings , oebin , "Neuropix-PXI-100.ProbeA-AP" )
538+ probe = read_openephys (settings , stream_name = "Neuropix-PXI-100.ProbeA-AP" , oebin_file = oebin )
534539 assert probe .get_contact_count () == 384
535540
536541
537- def test_read_openephys_binary_plugin_channel_key ():
538- """Verify that plugin_channel_key annotation is set."""
542+ def test_read_openephys_with_oebin_plugin_channel_key ():
543+ """Verify that plugin_channel_key annotation is set when using oebin_file ."""
539544 settings = data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml"
540545 oebin = (
541546 data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "experiment1" / "recording1" / "structure.oebin"
542547 )
543548 stream_name = "Neuropix-PXI-100.ProbeA"
544549
545- probe = read_openephys_binary (settings , oebin , stream_name )
550+ probe = read_openephys (settings , stream_name = stream_name , oebin_file = oebin )
546551 keys = probe .contact_annotations .get ("plugin_channel_key" , None )
547552 assert keys is not None , "plugin_channel_key annotation not set"
548553 assert len (keys ) == probe .get_contact_count ()
549- # Keys should be like "CH0", "CH1", etc.
550554 assert all (k .startswith ("CH" ) for k in keys )
551555
552556
553- def test_read_openephys_binary_no_matching_stream ():
554- """Verify error when stream_name doesn't match any oebin stream ."""
557+ def test_read_openephys_with_oebin_no_matching_stream ():
558+ """Verify error when stream_name doesn't match any probe in settings ."""
555559 settings = data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml"
556560 oebin = (
557561 data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "experiment1" / "recording1" / "structure.oebin"
558562 )
559563
560564 with pytest .raises (Exception , match = "Inconsistency between provided stream" ):
561- read_openephys_binary (settings , oebin , "NonExistentStream" )
562-
563-
564- def test_read_openephys_with_oebin_file ():
565- """Verify read_openephys(..., oebin_file=...) matches read_openephys_binary results."""
566- settings = data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml"
567- oebin = (
568- data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "experiment1" / "recording1" / "structure.oebin"
569- )
570- stream_name = "Neuropix-PXI-100.ProbeA"
571-
572- probe = read_openephys (settings , stream_name = stream_name , oebin_file = oebin )
573-
574- assert probe .get_contact_count () == 384
575- assert probe .device_channel_indices is not None
576-
577- # Wiring invariant
578- oebin_electrode_indices = _read_oebin_electrode_indices (oebin , stream_name )
579- for i , contact_id in enumerate (probe .contact_ids ):
580- electrode_index = int (contact_id .split ("e" )[- 1 ])
581- column = probe .device_channel_indices [i ]
582- assert oebin_electrode_indices [column ] == electrode_index
583-
584-
585- def test_read_openephys_with_oebin_file_4shank ():
586- """Verify read_openephys(..., oebin_file=...) works for 4-shank probes."""
587- settings = data_path / "OE_Neuropix-PXI-NP2-4shank-binary" / "Record_Node_101" / "settings.xml"
588- oebin = (
589- data_path
590- / "OE_Neuropix-PXI-NP2-4shank-binary"
591- / "Record_Node_101"
592- / "experiment4"
593- / "recording2"
594- / "structure.oebin"
595- )
596- stream_name = "Neuropix-PXI-100.ProbeA-AP"
597-
598- probe = read_openephys (settings , stream_name = stream_name , oebin_file = oebin )
599-
600- assert probe .get_contact_count () == 384
601- _assert_contact_ids_match_canonical_pattern (probe , "NP1032 oebin_file" )
602-
603-
604- def test_read_openephys_with_oebin_file_plugin_channel_key ():
605- """Verify that plugin_channel_key annotation is set when using oebin_file."""
606- settings = data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml"
607- oebin = (
608- data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "experiment1" / "recording1" / "structure.oebin"
609- )
610- stream_name = "Neuropix-PXI-100.ProbeA"
611-
612- probe = read_openephys (settings , stream_name = stream_name , oebin_file = oebin )
613- keys = probe .contact_annotations .get ("plugin_channel_key" , None )
614- assert keys is not None , "plugin_channel_key annotation not set"
615- assert len (keys ) == probe .get_contact_count ()
616- assert all (k .startswith ("CH" ) for k in keys )
565+ read_openephys (settings , stream_name = "NonExistentStream" , oebin_file = oebin )
617566
618567
619568def test_read_openephys_oebin_file_requires_stream_name ():
@@ -668,18 +617,6 @@ def test_read_openephys_multishank_wiring():
668617 )
669618
670619
671- def test_read_openephys_binary_deprecation_warning ():
672- """Verify that read_openephys_binary emits a DeprecationWarning."""
673- settings = data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "settings.xml"
674- oebin = (
675- data_path / "OE_Neuropix-PXI-NP1-binary" / "Record_Node_101" / "experiment1" / "recording1" / "structure.oebin"
676- )
677- stream_name = "Neuropix-PXI-100.ProbeA"
678-
679- with pytest .warns (DeprecationWarning , match = "read_openephys_binary is deprecated" ):
680- read_openephys_binary (settings , oebin , stream_name )
681-
682-
683620if __name__ == "__main__" :
684621 # test_multiple_probes()
685622 # test_NP_Ultra()
0 commit comments