DetectSpikes_Amp.m 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. function [index, spikes, thr, thrmax, noise_std_detect, noise_std_sorted] = DetectSpikes_Amp(Data, handles)
  2. % DetectSpikes_Amp Detect spikes based on amplitude thresholding. Adapted
  3. % from WaveClus
  4. % Detailed explanation goes here
  5. % index - spike times in ms
  6. % spikes - spike waveforms
  7. index_all=[];
  8. spikes_all=[];
  9. % SPIKE DETECTION WITH AMPLITUDE THRESHOLDING
  10. % korjaa sampleratella
  11. % julkaisun defaultit: 24000Hz, pre 20 events, post 44 events
  12. sr_factor = 24000;
  13. handles.w_pre = ceil(handles.w_pre/sr_factor*handles.sr); %number of pre-event data points stored (def. 20)
  14. handles.w_post = ceil(handles.w_post/sr_factor*handles.sr); %number of post-event data points stored (def. 44)
  15. handles.ref = floor(handles.min_ref_per*handles.sr/1000); %number of counts corresponding to the dead time
  16. [spikes,thr,thrmax, noise_std_detect, noise_std_sorted, index] = amp_detect(Data,handles); %detection with amp. thresh. --> voiko Data olla taulukkona?
  17. index = index';
  18. index_all = [index_all index];
  19. spikes_all = [spikes_all; spikes];
  20. index = index_all/handles.sr; %spike times in ms --> now in s
  21. spikes = spikes_all;
  22. end