csn-le / wave_clus

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

Run wave_clus #3

Closed mina65 closed 8 years ago

mina65 commented 8 years ago

Is there anyway I run wave_clus without GUI, i.e., I want to give wave_clus my data and set of parameters (e.g., temperature, min cluster size, threshold and so on ) and then get the clustered data as output. Also how can I have the shape of each cluster that has been clustered as an out-put. Thanks

ferchaure commented 8 years ago

Use the files _Batch_files/Getspikes.m and _Batch_files/Doclustering.m to run Wave_clus without the Gui. Are you asking about the shape in the features space? In that case you can use the spikes and the 'par' variable inside the output file to recalculate the features calling: _Batch_files/wavefeatures.m. Then, using the clustering results is possible to get the N-dimensional shape of each cluster.

mina65 commented 8 years ago

Thanks for your answer. I was wondering how I should use wave_clust when each of my Tetrode has 4 electodes. Should do the clustering for each electrode separately, or is there any function which would do this job in some specific way? Thanks

ferchaure commented 8 years ago

You can use _Batch_files/Get_spikespol.m and then _Batch_files/Doclustering.m like before.

mina65 commented 8 years ago

I am a bit confused with how I should give the input: For Get_spikes.m I call it as follow Get_spikes([{'TT1E1.ncs'; 'TT1E2.ncs'}]); and it gives me two output files.

However when I call Get_spikes_pol([{'TT1E1.ncs'; 'TT1E2.ncs'}]); it gives me an error. Do I need to convert TT1E1.ncs to TT1E1.txt and TT1E2.ncs to TT1E2.txt and give those two text files as an input to Get_spikes_pol?

ferchaure commented 8 years ago

The polytrode support will be rewrite, but for now, you can follow the instructions from the old documentation:

First, write the name of the files you want to process as polytrode (in ascii format) in a text file named as polytrode1.txt. The spike detection is done by typing in the Matlab command window the batch file Get_spikes_pol(1) which will produce the output file polytrode1_spikes.mat containing the spike times and shapes. In case you may want to process for example 2 polytrodes you just have to type Get_spikes_pol(1:2)

mina65 commented 8 years ago

Thanks. It works now. I was trying to run the code on real data which is uploaded on the website. I have one problem though. 1- In amp_detect the thrmeax is defined as thrmax = stdmax * noise_std_sorted, however in Do_cluster we have thrmax = 15 * noise_std_detect; I was wondering if there is a reason you have two different formula for computing thrmax.

2- I have set both thrmax as thrmax = stdmax * noise_std_detect; par.stdmax = 15; and par.detection = 'neg'; and ran the code on CSC4. I have an example for a spike which I can't make sense out of it. based on the data and stdmax the thrmax would be 85.2812 (I also have changed the order of filter to 4th order and par.sr =32556;) and I have got a spike which has a maximum> 200. I thought that those spikes which are greater than 85.2812 would be considered as artifacts and excluded from spikes!?

Another question is when I ran Do_clustering on the data I always get 2 classes in cluster_class. How can I find out what is the temperature for these classes, and how can I get different clusters for different temperature. Do I need to run it separately for each temperature??

Thanks

ferchaure commented 8 years ago

1- Inside that part of _Doclustering, thrmax is only an internal variable to define the limits of the plots.

2- As you said before: thrmax = stdmax * noise_std_sorted. Check the par.detect_fmax/fmin parameters, probably _noise_stdsorted is bigger than _noise_stddetect .

3- For analyse the results: open the raw data using the GUI, its will find the results and show them.

mina65 commented 8 years ago

Thank you. I have been trying to apply use the code for clustering my data and I came across tow problems: 1- With one Tetrode I don't get any errors for both detecting spikes and clustering (although I only get one cluster and the size of the other clusters are less than 10), do you have any suggestions on how I can get more clusters from my data

2- When I use the code for another Tetrode I can still detect spikes with (Get_spikes) but when I run Do_cluster I get an error, and I figured out that the number of classes are less than number of index by two. Which I am guessing it has to do with this part of the code but I might be wrong:

if par.permut == 'y'

    clu_aux = zeros(size(clu,1),size(spikes,1)) -1;% + 1000; %when update classes from clu, not selected go to cluster 1001  

    clu_aux(:,ipermut+2) = clu(:,(1:length(ipermut))+2);  

    clu_aux(:,1:2) = clu(:,1:2);  

    clu = clu_aux;  

    clear clu_aux  

end  

classes = clu(temp,3:end)+1;  

Could you please help me in these issues?

Thanks

ferchaure commented 8 years ago

1- You can try with more inputs to improve the discrimination (par.inputs) or with a smaller par.min_clus to accept smaller clusters.

2- I'm not sure, what is exactly the error? Are you using the latests version of the code? (https://github.com/csn-le/wave_clus)