You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No way to access spikeGLX Digital Channels on the 'nidq' stream #2242
While read_spikeglx(spikeglx_folder, 'nidq') allows you to access the analog I/O channels, the signal on the digital i/O channels (TTL pulses) are missing - these often contain events related to experimental control and would be important to capture from a downstream analysis point of view.
Okay I did some digging and here's what I found:
The digital channels (if present and saved) are encoded as an 8 bit word, where the digital channel 0 refers to the least significant bit. And each sample essentially stores the state of the the 8 digital channels in this word.
I essentially confirmed this by inserting the following code after this line in the neo's spikeglxrawio.py
extracted_word = data[:,8] # Extract the 9th value 8 analog channels, and 1 'digital' word`
all_states = ['{0:08b}'.format(x) for x in extracted_word]
channel0_bits = [int(x[-1]) for x in all_states]
positive_edges0 = [i for i,x in enumerate(np.diff(channel0_bits)) if x == 1]
channel2_bits = [int(x[-3]) for x in all_states]
positive_edges2 = [i for i,x in enumerate(np.diff(channel2_bits)) if x == 1]
negative_edges2 = [i for i,x in enumerate(np.diff(channel2_bits)) if x == -1]
And then seeing if the transitions in the bits based on all_samples made sense.
I am attaching 2 test cases that can help you - 1 of them has only sync pulses on digital channel 0, and the other one has TTL pulses (high for ~1 sec) on channels 2 and 3, in addition to the sync pulses on digital channel 0. Sync0.zip Sync0TTL2and3.zip
P.S: The second zip file contains a .7z compression inside because i was not able to decrease the filesize to less than 25 MB, I apologize in advance for the inconvenience!
Hi! Is there a PR regarding this issue? I am unsure about whether this needs to be implemented on the NEO side and then accordingly in spikeinterface, or everything on the spikeinterface?
@samuelgarcia how could we may be help to get a fix for this going? may be point to few ideas on where to introduce what and then @TheChymera with @manimoh could take a stab at implementing it?
Activity
alejoe91 commentedon Nov 22, 2023
Hi @manimoh
Is there any code to read them in Python? We should need to implement
read_spikeglx_events! (We have one for Open Ephys)manimoh commentedon Nov 22, 2023
Unfortunately all I could find is that the 'XD' (digital) is not really parsed in neo's spikeglxrawio, so I don't know where else to look at :/
samuelgarcia commentedon Nov 23, 2023
There is no clear API on neo side to read digtal stream.
This is on my todo list since very long time.
manimoh commentedon Nov 23, 2023
Okay I did some digging and here's what I found:
The digital channels (if present and saved) are encoded as an 8 bit word, where the digital channel 0 refers to the least significant bit. And each sample essentially stores the state of the the 8 digital channels in this word.
I essentially confirmed this by inserting the following code after this line in the neo's spikeglxrawio.py
And then seeing if the transitions in the bits based on
all_samplesmade sense.I am attaching 2 test cases that can help you - 1 of them has only sync pulses on digital channel 0, and the other one has TTL pulses (high for ~1 sec) on channels 2 and 3, in addition to the sync pulses on digital channel 0.
Sync0.zip
Sync0TTL2and3.zip
P.S: The second zip file contains a .7z compression inside because i was not able to decrease the filesize to less than 25 MB, I apologize in advance for the inconvenience!
manimoh commentedon Dec 4, 2023
Hi! Is there a PR regarding this issue? I am unsure about whether this needs to be implemented on the NEO side and then accordingly in spikeinterface, or everything on the spikeinterface?
yarikoptic commentedon Dec 16, 2023
@samuelgarcia how could we may be help to get a fix for this going? may be point to few ideas on where to introduce what and then @TheChymera with @manimoh could take a stab at implementing it?
alejoe91 commentedon Dec 18, 2023
Hi @yarikoptic, @manimoh and @TheChymera
Yes this will need to be implemented in NEO, specifically in the
SpikeGLXRawIOCan you open an issue there?
Once that is implemented, on the SpikeItnerface side we just need a very thin layer on top of NEO events, similar to this OpenEphys implementation.
manimoh commentedon Jan 29, 2024
Added a PR to spikeinterface, pending merging of PR in NEO
zm711 commentedon Sep 20, 2024
PRs merged so I'm closing this :)