wave_clus icon indicating copy to clipboard operation
wave_clus copied to clipboard

Selecting optimal temperature

Open laczobence opened this issue 2 years ago • 15 comments

Hi,

I first would like to thank you for this wonderful spike sorting tool. I have just started using wave_clus on my data and I have faced some problems.

image

  1. My raw data with the threshold line does not appear in the gui. Do you have an idea why is that happen?
  2. With the automatic detection I got 4 clusters (the 4th is not appearing on the pic below). After pressing the FORCE button, in the 1st and 3rd clusters some positive spikes appear. Why is that happen?

image

  1. The 1st and the 3rd clusters are very similar. If I reduce the temperature the number of clusters reduce to two, which are more clearly distinct from each other. According to your opinion which temperature should I use?

image

Thanks for your help in advance!

laczobence avatar Mar 14 '22 18:03 laczobence

Hi,

  1. That's a bit odd. Are you loading from raw data or extracted spikes?
  2. Try reducing par.template_sdnum to 2.5 The peak is quite small and it doesn't weigh enough when the rest of the spike is quite similar. Notice that cluster 3 looks like just a peak in the noise and not a real neuron. And I would use just a positive threshold, it's better for the alignment and will reduce the noise detections you have. (double threshold is useful just in some particular cases where the relative position of one neuron and the electrode generates an inversion of the polarity of the spike).
  3. My best take on selecting temperatures is the current automatic one. For example, the temperature you chose, removes cluster 4 which is different from cluster 2. On the other hand, cluster 3 doesn't have the slow slop after the peak like cluster 1, and for that reason cluster 1 looks more like a real neuron.

ferchaure avatar Mar 15 '22 12:03 ferchaure

Thanks for your fast comment!

image

I'm loading raw data. After the automated clustering if I plot the raw data with the Matlab GUI it appears in wave_clus GUI, but offcourse without the threshold level. This is the result after changing par.template_sdnum to 2.5 and with 'pos' par.detection. There are still some positive spikes. Is that a problem?

laczobence avatar Mar 19 '22 08:03 laczobence

That's really odd. Did you edit the set_parameters.m file and run again the sorting? If wave_clus finds a Xx_spikes or tkmes_Xx file in the path will try to load from there and not recalculate the sorting.

ferchaure avatar Mar 19 '22 12:03 ferchaure

I have edited set_parameters.m in the GUI, than I loaded the data again. I have also tried to quit from matlab than run the analysis again, but the result was the same.

Here is my set_parameters file: % LOAD PARAMS
par.segments_length = 5; % length (in minutes) of segments in which the data is cutted (default 5min).
par.sr = 24000; % sampling rate (in Hz). This parameter will be only used if the data file don't have a sr.

% PLOTTING PARAMETERS
par.cont_segment = true;
par.max_spikes_plot = 1000; % max. number of spikes to be plotted
par.print2file = true; % If is not true, print the figure (only for batch scripts).
par.cont_plot_samples = 100000; % number of samples used in the one-minute (maximum) sample of continuous data to plot.
par.to_plot_std = 1; % # of std from mean to plot
par.all_classes_ax = 'mean'; % 'mean'/'all'. If it's 'mean' only the mean waveforms will be ploted in the axes with all the classes par.plot_feature_stats = false;

% SPC PARAMETERS
par.mintemp = 0.00; % minimum temperature for SPC
par.maxtemp = 0.251; % maximum temperature for SPC
par.tempstep = 0.01; % temperature steps
par.SWCycles = 100; % SPC iterations for each temperature (default 100)
par.KNearNeighb = 11; % number of nearest neighbors for SPC
par.min_clus = 20; % minimum size of a cluster (default 20)
par.randomseed = 0; % if 0, random seed is taken as the clock value (default 0)
%par.randomseed = 147; % If not 0, random seed
%par.temp_plot = 'lin'; % temperature plot in linear scale
par.temp_plot = 'log'; % temperature plot in log scale

par.c_ov = 0.7; % Overlapping coefficient to use for the inclusion criterion.
par.elbow_min = 0.4; %Thr_border parameter for regime border detection.

% DETECTION PARAMETERS
par.tmax = 'all'; % maximum time to load
%par.tmax= 180; % maximum time to load (in sec)
par.tmin= 0; % starting time for loading (in sec)
par.w_pre = 20; % number of pre-event data points stored (default 20)
par.w_post = 44; % number of post-event data points stored (default 44))
par.alignment_window = 10; % number of points around the sample expected to be the maximum
par.stdmin = 5; % minimum threshold for detection
par.stdmax = 50; % maximum threshold for detection
par.detect_fmin = 300; % high pass filter for detection
par.detect_fmax = 3000; % low pass filter for detection (default 3000)
par.detect_order = 4; % filter order for detection. 0 to disable the filter.
par.sort_fmin = 300; % high pass filter for sorting
par.sort_fmax = 3000; % low pass filter for sorting (default 3000)
par.sort_order = 2; % filter order for sorting. 0 to disable the filter.
par.ref_ms = 1.5; % detector dead time, minimum refractory period (in ms)
par.detection = 'pos'; % type of threshold ('pos','neg','both')
%par.detection = 'neg';
%par.detection = 'both';

% INTERPOLATION PARAMETERS
par.int_factor = 5; % interpolation factor
par.interpolation = 'y'; % interpolation with cubic splines (default 'y')
% par.interpolation = 'n';

% FEATURES PARAMETERS
par.min_inputs = 10; % number of inputs to the clustering
par.max_inputs = 0.75; % number of inputs to the clustering. if < 1 it will the that proportion of the maximum.
par.scales = 4; % number of scales for the wavelet decomposition
par.features = 'wav'; % type of feature ('wav' or 'pca')
%par.features = 'pca'

% FORCE MEMBERSHIP PARAMETERS
par.template_sdnum = 2.5; % max radius of cluster in std devs.
par.template_k = 10; % # of nearest neighbors
par.template_k_min = 10; % min # of nn for vote
%par.template_type = 'mahal'; % nn, center, ml, mahal
par.template_type = 'center'; % nn, center, ml, mahal
%par.force_feature = 'spk'; % feature use for forcing (whole spike shape)
par.force_feature = 'wav'; % feature use for forcing (wavelet coefficients).
par.force_auto = true; %automatically force membership (only for batch scripts).

% TEMPLATE MATCHING
par.match = 'y'; % for template matching
%par.match = 'n'; % for no template matching
par.max_spk = 40000; % max. # of spikes before starting templ. match.
par.permut = 'y'; % for selection of random 'par.max_spk' spikes before starting templ. match.
% par.permut = 'n'; % for selection of the first 'par.max_spk' spikes before starting templ. match.

% HISTOGRAM PARAMETERS
par.nbins = 100; % # of bins for the ISI histograms
par.bin_step = 1; % percentage number of bins to plot

laczobence avatar Mar 21 '22 09:03 laczobence

do you have another set_parameters.m file in the folder where your data is? (in that case wave_clus will use that one). Check if the par struct inside the times file has par.detection = 'pos'

are you using the last code available?

ferchaure avatar Mar 21 '22 13:03 ferchaure

In my folder there is one set_parameters.m file and a set_parameters_ui.m and a set_parameters_DEFAULT.m. I don't think these two can be the problem as they have different names. IN the folder where my data is there is no set_parameters file.

I downloaded the code at the end of 2021. 3.0.3 version. Is there a newer version?

laczobence avatar Mar 23 '22 09:03 laczobence

It looks like you have the version. Can you save that sorting in look inside the times file, there should be a par struct with the par.detection used. Is there a XXX_spikes.mat file in that folder (like the one created after using Get_spikes() )?

ferchaure avatar Mar 23 '22 11:03 ferchaure

In the par struct the par detection's value is 'both'. This could be the problem. How can I change it if not in the set_parameters? There is no XXX_spikes.mat file. Until present I always used the GUI and have not tried using the batch files.

laczobence avatar Mar 24 '22 09:03 laczobence

ok, just to check run in Matlab: which('set_parameters.m')

That should give you the path of the parameters that will be used. Check if that file is the one on the waveclus folder and if the detection parameter is 'pos' .

ferchaure avatar Mar 24 '22 15:03 ferchaure

I have checked the path of the set_parameter.m file and it is in the waveclus folder. I have realised that the negative spikes appear in the clusters only after I press the force button.

laczobence avatar Apr 10 '22 13:04 laczobence

It makes sense, the issue is why that spikes are detected. Are you removing the times_NN.mat file from that folder after changing the parameters? The GUI will try to open the result if the times_NN.mat file is there.

ferchaure avatar Apr 10 '22 13:04 ferchaure

Sorry but I don't know what is that times_NN.mat. I don't have a file with that name. Do you mean the the file which contains the times of the spikes? Here it is called times_data.mat.

laczobence avatar Apr 14 '22 10:04 laczobence

Yes, I mean times_data.mat in your case

ferchaure avatar Apr 14 '22 11:04 ferchaure

I have put my data into a new empty folder than I ran wave_clus again. Now I got the below results with only one cluster. This time the raw data with the threshold also appeared.

image

Is that possible that I saved the clustering data of two data sets in the same times_data.mat?

Can you tell me where can I find the interspike intervals? Are they included in the times_data.mat file or do I have to calculate it from the times of the spikes?

laczobence avatar Apr 19 '22 15:04 laczobence

Is that possible that I saved the clustering data of two data sets in the same times_data.mat?

No, but if waveclus finds in the current folder (or path) a file with the same name as the raw data but starting with "times_" it will open that result.

Can you tell me where can I find the interspike intervals? Are they included in the times_data.mat file or do I have to calculate it from the times of the spikes?

You have to calculated them from the cluster_class variable in the "times_" file.

ferchaure avatar Apr 19 '22 16:04 ferchaure