@@ -370,23 +370,27 @@ def read_kilosort_as_analyzer(
370370 probe .set_contacts (channel_positions )
371371 channel_map = np .load (phy_path / "channel_map.npy" )
372372 probe .set_device_channel_indices (channel_map )
373- probegroup = ProbeGroup ().add_probe (probe )
373+
374+ probegroup = ProbeGroup ()
375+ probegroup .add_probe (probe )
374376 else :
375377 AssertionError (f"Cannot read probe layout from folder { phy_path } ." )
376378
377379 # Check that user-defined recording probe geometry is consistent with phy output
378380 if recording is not None :
381+ user_gave_recording = True
382+ all_contact_positions = np .vstack ([probe .contact_positions for probe in probegroup .probes ])
379383 for recording_channel_location , probe_contact_position in zip (
380- recording .get_channel_locations (), probe . get_global_contact_positions ()
384+ recording .get_channel_locations (), all_contact_positions
381385 ):
382386 if not np .all (recording_channel_location == probe_contact_position ):
383387 raise ValueError (
384388 "Recording channel locations from `recording` do not match probe channel locations from `folder_path/probe.prb`."
385389 "Hence there is an inconsistency between probe layout or wiring between the recording and sorting output."
386390 "Please resolve this inconsistency."
387391 )
388-
389- if recording is None :
392+ else :
393+ user_gave_recording = False
390394 # to make the initial analyzer, we'll use a fake recording and set it to None later
391395 recordings = []
392396 for probe in probegroup .probes :
@@ -418,7 +422,7 @@ def read_kilosort_as_analyzer(
418422 )
419423 _make_locations (sorting_analyzer , phy_path )
420424
421- if recording is None :
425+ if not user_gave_recording :
422426 sorting_analyzer ._recording = None
423427
424428 return sorting_analyzer
0 commit comments