csn-le / wave_clus

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

How to force number of clusters with Do_clustering() #103

Closed Tenceto closed 6 years ago

Tenceto commented 6 years ago

When I apply the function Do_clustering() to my data, I want to be able to force the algorithm to find a fixed number of clusters. Is there a way to do this? Namely, to tell WaveClus "fit all the spikes into N clusters".

ferchaure commented 6 years ago

Sorry but it is not possible to do something like that.

ferchaure commented 6 years ago

do you have over-clustering? check to align your spikes better and/or increase the min_clus parameter

Tenceto commented 6 years ago

The thing is that I know the ground-truth so I know how many classes exist in my dataset. For example, I was trying with a dataset that has spikes of 5 classes, and WaveClus was returning 7 or 8 (I don't recall exactly).

The spikes are perfectly aligned (i.e. they all have the minimum value in the same sample). I'll try to increase min_clus and see if that works out.

ferchaure commented 6 years ago

About the alignment, check that using an interpolated spike the peak is in the same sample. min_clus will help but it won't force a certain number of clusters. Maybe you could merge manually the closest ones, but it isn't a real solution.

Tenceto commented 6 years ago

Sorry for my ignorance, but what do you mean by "check that using an interpolated spike the peak is in the same sample"?

ferchaure commented 6 years ago

The spike can be miss aligned for less that a sample, the way to fix that is: interpolate the spike with more samples, align that spike with better temporal precision and then sub-sample to get a spike with the original size. You will get a spike with less samples, because you have to remove 2 samples of each side of the spike to fix the border effect of the interpolation.

Tenceto commented 6 years ago

I got it now. I will try that, but nevertheless I will close this thread as the answer to the original question was already provided by you and it was a simple "no, it's not possible". Thanks for your help!