Improve Spikeglx IO to also load datasets with only `lf` files
Also @samuelgarcia , if I try to instantiate from a folder in which there are only 'lf' files, no 'ap' file, I get the following errors
extractor = SpikeGLXRecordingExtractor(
folder_path,
stream_id='imec0.lf'
)
FileNotFoundError Traceback (most recent call last) /home/tbugnon/projects/misc/test_sglx_spikeinterface/test_spikeinterface_sglx.ipynb Cell 6' in <cell line: 1>() ----> 1 extractor = SpikeGLXRecordingExtractor( 2 '/Volumes/neuropixel_archive/Data/chronic/CNPIX13-Al/1-6-2022/SpikeGLX/1-6-2022_g0/1-6-2022_g0_imec0', 3 stream_id='imec0.lf' 4 )
File ~/projects/misc/test_sglx_spikeinterface/spikeinterface/spikeinterface/extractors/neoextractors/spikeglx.py:49, in SpikeGLXRecordingExtractor.init(self, folder_path, stream_id) 47 if "lf" in self.stream_id: 48 meta_filename = meta_filename.replace(".lf", ".ap") ---> 49 probe = pi.read_spikeglx(meta_filename) 51 if probe.shank_ids is not None: 52 self.set_probe(probe, in_place=True, group_mode="by_shank")
File ~/miniconda3/envs/test_sglx_spikeinterface/lib/python3.10/site-packages/probeinterface/io.py:696, in read_spikeglx(file) 694 meta_file = Path(file) 695 assert meta_file.suffix == ".meta", "'meta_file' should point to the .meta SpikeGLX file" --> 696 with meta_file.open(mode='r') as f: 697 lines = f.read().splitlines() 699 meta = {}
File ~/miniconda3/envs/test_sglx_spikeinterface/lib/python3.10/pathlib.py:1117, in Path.open(self, mode, buffering, encoding, errors, newline) 1115 if "b" not in mode: 1116 encoding = io.text_encoding(encoding) -> 1117 return self._accessor.open(self, mode, buffering, encoding, errors, 1118 newline)
FileNotFoundError: [Errno 2] No such file or directory: '/Volumes/neuropixel_archive/Data/chronic/CNPIX13-Al/1-6-2022/SpikeGLX/1-6-2022_g0/1-6-2022_g0_imec0/1-6-2022_g0_t0.imec0.ap.meta'
And with stream_id = 'imec0.ap' (there is no imec0.ap in the folder)
extractor = SpikeGLXRecordingExtractor(
folder_path,
stream_id='imec0.ap'
)
AssertionError Traceback (most recent call last) /home/tbugnon/projects/misc/test_sglx_spikeinterface/test_spikeinterface_sglx.ipynb Cell 6' in <cell line: 1>() ----> 1 extractor = SpikeGLXRecordingExtractor( 2 '/Volumes/neuropixel_archive/Data/chronic/CNPIX13-Al/1-6-2022/SpikeGLX/1-6-2022_g0/1-6-2022_g0_imec0', 3 stream_id='imec0.ap' 4 )
File ~/projects/misc/test_sglx_spikeinterface/spikeinterface/spikeinterface/extractors/neoextractors/spikeglx.py:38, in SpikeGLXRecordingExtractor.init(self, folder_path, stream_id) 36 if HAS_NEO_10_2: 37 neo_kwargs["load_sync_channel"] = False ---> 38 NeoBaseRecordingExtractor.init(self, stream_id=stream_id, **neo_kwargs) 40 # ~ # open the corresponding stream probe 41 if HAS_NEO_10_2 and "nidq" not in self.stream_id:
File ~/projects/misc/test_sglx_spikeinterface/spikeinterface/spikeinterface/extractors/neoextractors/neobaseextractor.py:40, in NeoBaseRecordingExtractor.init(self, stream_id, **neo_kwargs) 38 stream_id = stream_ids[0] 39 else: ---> 40 assert stream_id in stream_ids, f'stream_id {stream_id} is no in {stream_ids}' 42 self.stream_index = list(stream_ids).index(stream_id) 43 self.stream_id = stream_id
AssertionError: stream_id imec0.ap is no in ['imec0.lf']
Originally posted by @TomBugnon in https://github.com/NeuralEnsemble/python-neo/issues/1125#issuecomment-1172533062