@@ -85,6 +85,39 @@ def test_neuropixels_2_4shank_reader():
8585 assert abs ((dv_rec_2 - dv_cat_2 ) - offset_dv ) < 1e-6 , "dv offset must be constant across rows"
8686
8787
88+ def test_stereotactic_annotations_np1 ():
89+ # SpikeChannel coord_ml/dv/ap from the .rec are stored as per-contact
90+ # annotations on the output probe. Sentinel: chind 383 (id "1384" on probe
91+ # 1) maps to catalogue idx 383 (e383) under identity remap; the matching
92+ # SpikeChannel has coord_ml="-8" coord_dv="3920" coord_ap="0".
93+ probe_group = read_spikegadgets_neuropixels (data_path / test_file )
94+ probe = probe_group .probes [0 ]
95+ n_contacts = probe .get_contact_count ()
96+ for key in ("stereotactic_ml" , "stereotactic_dv" , "stereotactic_ap" ):
97+ assert key in probe .contact_annotations
98+ assert probe .contact_annotations [key ].shape == (n_contacts ,)
99+ i = list (probe .contact_ids ).index ("e383" )
100+ assert probe .contact_annotations ["stereotactic_ml" ][i ] == - 8.0
101+ assert probe .contact_annotations ["stereotactic_dv" ][i ] == 3920.0
102+ assert probe .contact_annotations ["stereotactic_ap" ][i ] == 0.0
103+
104+
105+ def test_stereotactic_annotations_np2_4shank ():
106+ # Same check for NP2.0 4-shank: chind 1671 maps to catalogue idx 416
107+ # (s0e416) via the row-major-to-shank-major remap; the matching SpikeChannel
108+ # has coord_ml="-383" coord_dv="3295" coord_ap="0".
109+ probe_group = read_spikegadgets_neuropixels (data_path / test_file_np2_4shank )
110+ probe = probe_group .probes [0 ]
111+ n_contacts = probe .get_contact_count ()
112+ for key in ("stereotactic_ml" , "stereotactic_dv" , "stereotactic_ap" ):
113+ assert key in probe .contact_annotations
114+ assert probe .contact_annotations [key ].shape == (n_contacts ,)
115+ i = list (probe .contact_ids ).index ("s0e416" )
116+ assert probe .contact_annotations ["stereotactic_ml" ][i ] == - 383.0
117+ assert probe .contact_annotations ["stereotactic_dv" ][i ] == 3295.0
118+ assert probe .contact_annotations ["stereotactic_ap" ][i ] == 0.0
119+
120+
88121def test_has_spikegadgets_neuropixels_probes_np2 ():
89122 # NP2.0 4-shank .rec should also report True.
90123 assert has_spikegadgets_neuropixels_probes (data_path / test_file_np2_4shank ) is True
@@ -110,6 +143,8 @@ def test_has_spikegadgets_neuropixels_probes_missing_file():
110143 test_parse_meta ()
111144 test_neuropixels_1_reader ()
112145 test_neuropixels_2_4shank_reader ()
146+ test_stereotactic_annotations_np1 ()
147+ test_stereotactic_annotations_np2_4shank ()
113148 test_has_spikegadgets_neuropixels_probes_np2 ()
114149 test_read_spikegadgets_deprecation_warning ()
115150 test_has_spikegadgets_neuropixels_probes_positive ()
0 commit comments