Skip to content

No way to access spikeGLX Digital Channels on the 'nidq' stream #2242

Closed

Description

@manimoh

Hi,

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.

Activity

  1. alejoe91 commented on Nov 22, 2023

    @alejoe91
    Member

    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)

  2. added
    enhancement
    extractors
    on Nov 22, 2023
  3. manimoh commented on Nov 22, 2023

    @manimoh
    ContributorAuthor

    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 :/

  4. samuelgarcia commented on Nov 23, 2023

    @samuelgarcia
    Member

    There is no clear API on neo side to read digtal stream.
    This is on my todo list since very long time.

  5. manimoh commented on Nov 23, 2023

    @manimoh
    ContributorAuthor

    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!

  6. manimoh commented on Dec 4, 2023

    @manimoh
    ContributorAuthor

    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?

  7. yarikoptic commented on Dec 16, 2023

    @yarikoptic
    Contributor

    @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?

  8. alejoe91 commented on Dec 18, 2023

    @alejoe91
    Member

    Hi @yarikoptic, @manimoh and @TheChymera

    Yes this will need to be implemented in NEO, specifically in the SpikeGLXRawIO
    Can 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.

  9. added
    NEO
    on Dec 18, 2023
  10. manimoh commented on Jan 29, 2024

    @manimoh
    ContributorAuthor

    Added a PR to spikeinterface, pending merging of PR in NEO

  11. zm711 commented on Sep 20, 2024

    @zm711
    Member

    PRs merged so I'm closing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    NEOenhancementextractors

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions