open-ephys-plugins / neuropixels-pxi

Open Ephys GUI plugin for interfacing with PXIe-based Neuropixels hardware
GNU General Public License v3.0
13 stars 19 forks source link

Sync Events Inconsistent Across NPX Streams #29

Open NDolensek opened 1 year ago

NDolensek commented 1 year ago

We've been running into a strange issue where a TTL sync signal delivered to the trigger/sync port on a npx basestation isn't logged correctly when recording with openephys 0.6.4 with the latest versions of all standard plugins. Specifically, when recording with multiple probes, each probe AP stream logs a different (and incorrect) number of TTL events (diverging >10% between streams and below 50% of the TTLs sent). Strangely, the NI DAQ, which receives the same TTL signal on one of the digital input ports, logs the correct number of events.,

We use multiple NHP NPX v1.0 probes for our recordings, in combination with a standard NI 4 slot PXI chassis with NI DAQ cards and an IMEC card with the latest firmware.

After some testing, it seems that TTL pulses of duration of 5ms or above do not get dropped. Is 1ms too short of a pulse to be reliably captured by openephys? Is the way TTL events are detected in the probe streams different than in the NIDAQ stream or do they differ in the sampling rate? Could a TTL high voltage of ~2.5V cause this? We previously used SpikeGLX with identical hardware and didn't run into this issue, making me think this could be related to how openephys detects events in the npx streams.

jsiegle commented 1 year ago

Hi Nate – the code for adding events to each data stream is the same for the Neuropixels and NIDAQ plugins, and the code for reading events via the Neuropixels API should be the same across Open Ephys and SpikeGLX. This suggests it's a problem with the Neuropixels sync port detecting short 2.5V events, but we can't rule out a software issue yet. There are a few things that would be helpful to check on your end to help us troubleshoot.

Firmware version

There were some changes to the sync port configuration in the most recent firmware update that could possibly account for the missed events. Do the short events appear in the version of SpikeGLX that uses the same basestation firmware? It's the latest version that's compatible with API v3.57, available from the legacy downloads page.

Voltage levels

What's the reason you're using ~2.5V logic levels, rather than 5V? When digital signals are split across multiple input ports, there may be unpredictable voltage drops, so 2.5V may be insufficient to trigger threshold crossings. If you can split off the digital line and check the peak voltage levels of the ~1 ms pulses using an oscilloscope, that would show whether the voltages are actually as high as expected.

Synchronization scheme

We definitely want to figure out what's going on with these missed events, but in the future I recommend switching to a scheme where you use the basestation SMA port in "output" mode, and connect it to one of the NIDAQ digital input terminals. The Record Node will automatically synchronize all of the input streams, and any digital events detected by the NIDAQ will be translated into global timestamps that match those for the Neuropixels streams. That way you won't need to duplicate these short sync pulses across multiple input ports. A tutorial explaining the necessary connections and software configuration is available here.

jsiegle commented 1 year ago

I just ran a test on our development rig, and I found that it recorded 2500 out of 2500 0.5 ms wide 5V pulses sent via the SMA sync port. So it seems like short pulses should be fine, if the voltage is sufficiently high.