12345678910111213141516171819202122232425262728293031323334353637383940 |
- function [index, spikes, thr, thrmax, noise_std_detect] = DetectSpikes_Amp(Data, handles)
- % DetectSpikes_Amp Detect spikes based on amplitude thresholding. Adapted
- % from WaveClus
- % INPUT
- % Data - raw waveform from the electrode
- % handles - detection parameters
- % OUTPUT
- % index - spike times (the only output written into result .csv files)
- % spikes - spike waveforms (not in use outside of the function currently)
- % thr - minimum threshold used for detection (not in use outside of the function)
- % thrmax - maximum threshold used for artefact removal (not in use outside of the function)
- % noise_std_detect - estimate of the standard deviation of the background
- % noise for detection (not in use outside of the function)
- index_all=[];
- spikes_all=[];
- %% ACTUAL SAMPLE RATE BASED PRE/POST correction and REFRACTORY PERIOD calculation
- % default: 24000Hz, pre 20 events, post 44 events, actual sr is read and
- % the values are corrected
- sr_factor = 24000;
- handles.w_pre = ceil(handles.w_pre/sr_factor*handles.sr); %number of pre-event data points stored (def. 20)
- handles.w_post = ceil(handles.w_post/sr_factor*handles.sr); %number of post-event data points stored (def. 44)
- handles.ref = floor(handles.min_ref_per*handles.sr/1000); %number of counts corresponding to the dead time
- %% SPIKE DETECTION
- [spikes,thr,thrmax, noise_std_detect, index] = amp_detect(Data,handles); %detection with amp. thresh. --> voiko Data olla taulukkona?
- index = index';
- index_all = [index_all index];
- spikes_all = [spikes_all; spikes];
- index = index_all/handles.sr;
- spikes = spikes_all;
- end
|