forked from mesoscale-activity-map/map-ephys
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
When aligning unit spike times to timestamps for the "go" cue in BehavioralEvents, there is a consistent ~ 7.5 ms drift per trial clear visible in the event-aligned raster attached below. This issue was submitted by a user performing secondary analysis on the NWB files exported from the MAP pipeline on DANDI archive. The following script was used for generating the raster plots:
import os
from pynwb import NWBHDF5IO
import numpy as np
import matplotlib.pyplot as plt
dataDir = r""
sub = r'sub-484677'
date = r'sub-484677_ses-20210420T170516_behavior+ecephys+ogen.nwb'
fpath = os.path.join(dataDir,sub,date)
nwbfile = NWBHDF5IO(fpath).read()
unit = 0
alignEvent = 'go_start_times'
before = 3 # in seconds
after = 3
alignTimes = nwbfile.acquisition['BehavioralEvents'][alignEvent].timestamps[:]
spkwv = nwbfile.units['waveform_mean'][unit]
spktm = nwbfile.units['spike_times'][unit]
N = len(spktm)
trial_spikes = []
nspks = 0
for trix,time in enumerate(alignTimes):
# align spike times
spktm_aligned = spktm - time - 0.0075*trix # estimated drift correction
# spktm_aligned = spktm - time
# Keep only spike times in a given time window around the stimulus onset
spktm_aligned = spktm_aligned[
(-before < spktm_aligned) & (spktm_aligned < after)
]
trial_spikes.append(spktm_aligned)
fig, axs = plt.subplots(2, 1, sharex="all", figsize=(6,3))
plt.xlabel("time from go cue (s)")
axs[0].eventplot(trial_spikes)
axs[0].set_ylabel("trial")
quality = nwbfile.units['unit_quality'].data[:][unit]
axs[0].set_title(f"unit {unit} | quality: {quality} | nSpikes: {N}")
axs[0].axvline(0, color=[0.5, 0.5, 0.5])
axs[1].hist(np.hstack(trial_spikes), 100)
axs[1].axvline(0, color=[0.5, 0.5, 0.5])
axs[1].set_ylabel('Spikes / bin')
plt.show()
fig, ax = plt.subplots(1, 1, figsize=(2,1))
ax.plot(spkwv)
plt.xlabel("samples")
ax.set_ylabel("mV")
plt.show()
Metadata
Metadata
Assignees
Labels
No labels

