csn-le / wave_clus

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

Error in spike_alignment.m #225

Closed YGUO29 closed 1 year ago

YGUO29 commented 1 year ago

It seems there are some errors for line 30-31 in spike_alignment.m Line 30 does not have the same length on the two sides; line 31 is missing a ":" I think. Just wanted to confirm how to modify this section before I go ahead.. thanks!

image
ferchaure commented 1 year ago

Hi, you are right. I guess you have already extracted spikes with a lot of samples and you want to realign them? To be honest, I guess you don't even need that two lines. I would replace them with something like:

rm_borders = floor((size(spikes,2)-ls-2*align_window-4)/2);
rm_odd_spike = rem(size(spikes,2), 2) == 1
spikes1 = spikes(:,(1+rm_borders ):end-(rm_borders+rm_odd_spike ) );

The following code is expectring spikes of ls+2*align_window+4 samples (final spike+aligments[align_window on each side]+extra samples for interpolation borders), with a code like the one above, you remove the additional samples.

Can you do a test and do a pull request?

YGUO29 commented 1 year ago

Just did! Thank you!