Skip to content

Fix loading data from the sync stream in spikeglx #3959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

h-mayorquin
Copy link
Collaborator

After this PR on neo:
NeuralEnsemble/python-neo#1683

the sync channel is separated into its own stream. However, if someone wants to load the stream-sync there is an error:

from pathlib import Path

from spikeinterface.extractors import SpikeGLXRecordingExtractor

recording = SpikeGLXRecordingExtractor(folder_path=folder_path, stream_name="imec0.ap-SYNC")
recording


KeyError: 'imec0.ap-SYNC'
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[4], line 5
      1 from pathlib import Path
      3 from spikeinterface.extractors import SpikeGLXRecordingExtractor
----> 5 recording = SpikeGLXRecordingExtractor(folder_path=folder_path, stream_name="imec0.ap-SYNC")
      6 recording

File ~/development/spikeinterface/src/spikeinterface/extractors/neoextractors/spikeglx.py:80, in SpikeGLXRecordingExtractor.__init__(self, folder_path, load_sync_channel, stream_id, stream_name, all_annotations, use_names_as_ids)
     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()

KeyError: 'imec0.ap-SYNC'

The reason for this is that stream id is built on the fly for the synch data and therefore is not available in the neo_reader.signals_info_list so this fails.

This PR fixes it by just avoiding this lookup when the sync stream is requested. It also adds a test and removes a test for loading the sync channel as that feature is going to be removed.

@h-mayorquin h-mayorquin self-assigned this May 27, 2025
@h-mayorquin h-mayorquin added the extractors Related to extractors module label May 27, 2025
@samuelgarcia
Copy link
Member

Merci.

@h-mayorquin h-mayorquin merged commit f3bfd84 into SpikeInterface:main Jun 3, 2025
15 checks passed
@h-mayorquin h-mayorquin deleted the fix_loading_sync_stream_in_spikeinterface branch June 3, 2025 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extractors Related to extractors module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants