


Multi-taper event triggered time-frequency spectrum - binned point process
Usage:
[S,f,R,Serr]=mtspectrumtrigpb(data,E,win,params,fscorr)
Input:
data (single channel data in a column vector) -- required
E (event times) - required
win (in the form [winl winr] i.e window around each event
required
Note that units here have
to be consistent with
units of Fs
params: structure with fields tapers, pad, Fs, fpass, err, trialave
- optional
tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
specified, use [NW K]=[3 5]
pad (padding factor for the FFT) - optional. Defaults to 0.
e.g. For N = 500, if PAD = 0, we pad the FFT
to 512 points; if PAD = 2, we pad the FFT
to 2048 points, etc.
Fs (sampling frequency) - optional. Default 1.
fpass (frequency band to be used in the calculation in the form
[fmin fmax])- optional.
Default all frequencies between 0 and Fs/2
err (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars
[0 p] or 0 - no error bars) - optional. Default 0.
trialave (average over events when 1, don't average when 0) -
optional. Default 0
fscorr (finite size corrections, 0 (don't use finite size corrections) or 1 (use finite size corrections) - optional
(available only for spikes). Defaults 0.
Output:
S (triggered spectrum in form frequency x events for trialave=0, or as a function of frequency for trialave=1)
f (frequencies)
R (spike rate)
Serr (error bars) - only for err(1)>=1

0001 function [S,f,R,Serr]=mtspectrumtrigpb(data,E,win,params,fscorr) 0002 % Multi-taper event triggered time-frequency spectrum - binned point process 0003 % 0004 % Usage: 0005 % 0006 % [S,f,R,Serr]=mtspectrumtrigpb(data,E,win,params,fscorr) 0007 % Input: 0008 % data (single channel data in a column vector) -- required 0009 % E (event times) - required 0010 % win (in the form [winl winr] i.e window around each event 0011 % required 0012 % Note that units here have 0013 % to be consistent with 0014 % units of Fs 0015 % params: structure with fields tapers, pad, Fs, fpass, err, trialave 0016 % - optional 0017 % tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not 0018 % specified, use [NW K]=[3 5] 0019 % pad (padding factor for the FFT) - optional. Defaults to 0. 0020 % e.g. For N = 500, if PAD = 0, we pad the FFT 0021 % to 512 points; if PAD = 2, we pad the FFT 0022 % to 2048 points, etc. 0023 % Fs (sampling frequency) - optional. Default 1. 0024 % fpass (frequency band to be used in the calculation in the form 0025 % [fmin fmax])- optional. 0026 % Default all frequencies between 0 and Fs/2 0027 % err (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars 0028 % [0 p] or 0 - no error bars) - optional. Default 0. 0029 % trialave (average over events when 1, don't average when 0) - 0030 % optional. Default 0 0031 % fscorr (finite size corrections, 0 (don't use finite size corrections) or 1 (use finite size corrections) - optional 0032 % (available only for spikes). Defaults 0. 0033 % Output: 0034 % S (triggered spectrum in form frequency x events for trialave=0, or as a function of frequency for trialave=1) 0035 % f (frequencies) 0036 % R (spike rate) 0037 % Serr (error bars) - only for err(1)>=1 0038 0039 if nargin < 3; error('Need data, events and window parameters'); end; 0040 if nargin < 2; params=[]; end; 0041 [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params); 0042 if nargin < 5 || isempty(fscorr); fscorr=0; end; 0043 if nargout > 3 && err(1)==0; 0044 % Cannot compute errors if err(1)=0. Need to change params and run again. 0045 error('When Serr is desired, err(1) has to be non-zero.'); 0046 end; 0047 0048 data=createdatamatpb(data,E,Fs,win); 0049 if nargout==4; [S,f,R,Serr]=mtspectrumpb(data,params,fscorr); 0050 else [S,f,R]=mtspectrumpb(data,params,fscorr);end