csn-le / wave_clus

A fast and unsupervised algorithm for spike detection and sorting using wavelets and super-paramagnetic clustering
121 stars 65 forks source link

Spike Alignment Question #223

Open PatrickHonma opened 1 year ago

PatrickHonma commented 1 year ago

Hi Ferchaure,

I have been using wave_clus to sort .pl2 files. Using raw WB signals collected on an OmniPlex, we filtered and digital filtered in matlab to create .mat files that are then fed into Wave_clus. The sorting has been working well; example results here: fig2print_data_354_Ch14

This data was collected during optogenetic stimulation, in which we are stimulating in periods of 2 minutes at 40 Hz (1 ms light on every 25 ms). When aligning the sorted spikes to the laser timestamps, we have noticed that some units appear ~1 ms before the laser turns on. Note that Cluster 3 is likely a light artifact. I have an alignment_window=10, w_pre = 30, w_post=44, interpolation='y', and par_detection='neg'. Will the spike_alignment with these parameters cause a shift in any of the timestamps or do you know what may be accounting for the shift in timing of these units?

ferchaure commented 1 year ago

Hi Patrick, I don't think that spike_alignment could add a shift, maybe your filtering step? are you using zero phase filters?

PatrickHonma commented 1 year ago

I am using the 4th order ellip filter, which should be zero phase?

ferchaure commented 1 year ago

If you applied with the function filtfilt it should be zero phase

PatrickHonma commented 1 year ago

Here is what I used to filter, which I believe should match up with the Wave_clus filter:

if exist('ellip','file') %Checks for the signal processing toolbox [b,a] = ellip(4,0.1,40,[300 7500].*2./fs); if exist('FiltFiltM','file') filtWBdata = FiltFiltM(b, a, rawWBdata); else filtWBdata = filtfilt(b, a, rawWBdata); end

The timestamps of my laser stimulations are in seconds. Do you think the conversion of the wave_clus (ms) to seconds may be causing a shift in the timestamps? #143 and #210 also mention similar issues

ferchaure commented 1 year ago

Then the filtering is fine. I would recommend to check the alignment between recording and laser timestamps

143 was mainly about tetrodes (and the sr parameters). Do you have your sampling rate in the file set_parameters?

210 just didn't realised that the output as in ms