DetectSpikes_Amp.m 1.6 KB

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