11from __future__ import annotations
22
33from pathlib import Path
4+ import warnings
45
56import probeinterface
67
@@ -61,6 +62,7 @@ def __init__(
6162 all_annotations : bool = False ,
6263 use_names_as_ids : bool = False ,
6364 ):
65+
6466 neo_kwargs = self .map_to_neo_kwargs (folder_path , load_sync_channel = load_sync_channel )
6567 NeoBaseRecordingExtractor .__init__ (
6668 self ,
@@ -71,15 +73,18 @@ def __init__(
7173 ** neo_kwargs ,
7274 )
7375
74- # open the corresponding stream probe for LF and AP
75- # if load_sync_channel=False
76- if "nidq" not in self .stream_id and not load_sync_channel :
77- signals_info_dict = {e ["stream_name" ]: e for e in self .neo_reader .signals_info_list }
78- meta_filename = signals_info_dict [self .stream_id ]["meta_file" ]
79- # Load probe geometry if available
80- if "lf" in self .stream_id :
81- meta_filename = meta_filename .replace (".lf" , ".ap" )
82- probe = probeinterface .read_spikeglx (meta_filename )
76+ self ._kwargs .update (dict (folder_path = str (Path (folder_path ).absolute ()), load_sync_channel = load_sync_channel ))
77+
78+ # Checks if the probe information is available and adds location, shanks and sample shift if available.
79+ signals_info_dict = {e ["stream_name" ]: e for e in self .neo_reader .signals_info_list }
80+ meta_filename = signals_info_dict [self .stream_id ]["meta_file" ]
81+ ap_meta_filename = meta_filename .replace (".lf" , ".ap" ) if "lf" in self .stream_id else meta_filename
82+ ap_meta_file_exists = Path (ap_meta_filename ).exists ()
83+ stream_is_not_nidq = "nidq" not in self .stream_id
84+ add_probe_properties = ap_meta_file_exists and stream_is_not_nidq and not load_sync_channel
85+
86+ if add_probe_properties :
87+ probe = probeinterface .read_spikeglx (ap_meta_filename )
8388
8489 if probe .shank_ids is not None :
8590 self .set_probe (probe , in_place = True , group_mode = "by_shank" )
@@ -111,8 +116,12 @@ def __init__(
111116 sample_shifts = sample_shifts [chans ]
112117
113118 self .set_property ("inter_sample_shift" , sample_shifts )
114-
115- self ._kwargs .update (dict (folder_path = str (Path (folder_path ).absolute ()), load_sync_channel = load_sync_channel ))
119+ else :
120+ warning_message = (
121+ "Unable to find a corresponding metadata file for the recording. "
122+ "The probe information will not be loaded. "
123+ )
124+ warnings .warn (warning_message , UserWarning , stacklevel = 2 )
116125
117126 @classmethod
118127 def map_to_neo_kwargs (cls , folder_path , load_sync_channel = False ):
0 commit comments