Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

mtspecgramtrigpb.m 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function [S,t,f,R,Serr]=mtspecgramtrigpb(data,E,win,movingwin,params,fscorr)
  2. % Multi-taper event triggered time-frequency spectrum - binned point process
  3. %
  4. % Usage:
  5. %
  6. % [S,t,f,R,Serr]=mtspecgramtrigpb(data,E,win,movingwin,params,fscorr)
  7. % Input:
  8. % data (single channel data vector) -- required
  9. % E (event times) - required
  10. % win (in the form [winl,winr] i.e window around each event
  11. % required
  12. % movingwin (in the form [window,winstep] i.e length of moving
  13. % window and step size) -
  14. % required
  15. % Note that units for the windows have
  16. % to be consistent with
  17. % units of Fs
  18. % params: structure with fields tapers, pad, Fs, fpass, err, trialave
  19. % - optional
  20. % tapers : precalculated tapers from dpss or in the one of the following
  21. % forms:
  22. % (1) A numeric vector [TW K] where TW is the
  23. % time-bandwidth product and K is the number of
  24. % tapers to be used (less than or equal to
  25. % 2TW-1).
  26. % (2) A numeric vector [W T p] where W is the
  27. % bandwidth, T is the duration of the data and p
  28. % is an integer such that 2TW-p tapers are used. In
  29. % this form there is no default i.e. to specify
  30. % the bandwidth, you have to specify T and p as
  31. % well. Note that the units of W and T have to be
  32. % consistent: if W is in Hz, T must be in seconds
  33. % and vice versa. Note that these units must also
  34. % be consistent with the units of params.Fs: W can
  35. % be in Hz if and only if params.Fs is in Hz.
  36. % The default is to use form 1 with TW=3 and K=5
  37. % Note that T has to be equal to movingwin(1).
  38. %
  39. % pad (padding factor for the FFT) - optional (can take values -1,0,1,2...).
  40. % -1 corresponds to no padding, 0 corresponds to padding
  41. % to the next highest power of 2 etc.
  42. % e.g. For N = 500, if PAD = -1, we do not pad; if PAD = 0, we pad the FFT
  43. % to 512 points, if pad=1, we pad to 1024 points etc.
  44. % Defaults to 0.
  45. % Fs (sampling frequency) - optional. Default 1.
  46. % fpass (frequency band to be used in the calculation in the form
  47. % [fmin fmax])- optional.
  48. % Default all frequencies between 0 and Fs/2
  49. % err (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars
  50. % [0 p] or 0 - no error bars) - optional. Default 0.
  51. % trialave (average over events when 1, don't average when 0) - optional. Default 0
  52. % fscorr (finite size corrections, 0 (don't use finite size corrections) or
  53. % 1 (use finite size corrections) - optional
  54. % (available only for spikes). Defaults 0.
  55. % Output:
  56. % S (triggered time-frequency spectrum in form time x frequency x events if segave=0;
  57. % or in the form time x frequency segave=1)
  58. % t (times)
  59. % f (frequencies)
  60. % R (spike rate)
  61. % Serr (error bars) - only for err(1)>=1
  62. if nargin < 4; error('Need data, events and parameters for the windows'); end;
  63. if nargin < 5; params=[]; end;
  64. if length(params.tapers)==3 & movingwin(1)~=params.tapers(2);
  65. error('Duration of data in params.tapers is inconsistent with movingwin(1), modify params.tapers(2) to proceed')
  66. end
  67. [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params);
  68. clear tapers pad fpass err trialave
  69. if nargin < 6 || isempty(fscorr); fscorr=0; end;
  70. data=change_row_to_column(data);
  71. data=createdatamatpb(data,E,Fs,win);
  72. if nargout==5;[S,t,f,R,Serr]=mtspecgrampb(data,movingwin,params,fscorr);
  73. else [S,t,f,R]=mtspecgrampb(data,movingwin,params,fscorr);end;