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.

mtspectrumtrigpt.m 3.6 KB

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