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.

mtspecgramtrigc.m 4.3 KB

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