Skip to content
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

How to get sync timestamps from spikeglx and open ephys #3425

Open
gabrielstine opened this issue Sep 18, 2024 · 4 comments
Open

How to get sync timestamps from spikeglx and open ephys #3425

gabrielstine opened this issue Sep 18, 2024 · 4 comments
Labels
question General question regarding SI

Comments

@gabrielstine
Copy link

gabrielstine commented Sep 18, 2024

Hi Guys,

I have a simple question that I'm having trouble finding the answer to in the documentation. I am recording simultaneously from a neuropixels probe (recorded in spikeGLX) and a DBC probe (recorded in open ephys). I'd like to extract the timestamps of the sync events from each stream and save them as .npy files. In open ephys, the sync signal is a ttl pulse fed into digital input 1. I imagine there are straightforward functions for extracting and saving these, but I can't find them!

Thanks!
Gabe

@zm711
Copy link
Collaborator

zm711 commented Sep 18, 2024

I feel like @alejoe91 is going to need to be the person to comment on this. I don't actually use ephys or any of the event based code in spikeinterface. So just ping this issue if you don't get a response soon!

@zm711 zm711 added the question General question regarding SI label Sep 18, 2024
@alejoe91
Copy link
Member

Hi @gabrielstine !

You should be able to read the open ephys events with this function:

events = se.read_openephys_events(openephys_folder)

This will return an Event object, which will allow you to interact with the event data. There can be events from multiple channel ids, which you can retrieve with the events.channel_ids field.
In particular, calling evts = events.get_events(channel_id) will return a structured numpy array with the following field:
dtype([('time', '<f8'), ('duration', '<f8'), ('label', '<U100')]). For open ephys, the label is the channel the event was recorded on, so you can select all events from channel 1 as follows:

evts_1 = evts[evts["label"] == "1"]

Let me know if you have other questions!

@gabrielstine
Copy link
Author

Thanks @alejoe91. And is there a way to automatically get the timestamps at which the sync channel went high in the spikeGLX data, or do I need to extract this manually? If not, could be nice to have a built-in function that takes the channel as input and returns timestamps.

@alejoe91
Copy link
Member

You can try the event_spikeglx = se.read_spikeglx_events(spikeglx_folder) ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question regarding SI
Projects
None yet
Development

No branches or pull requests

3 participants