


Multi-taper derivatives of time-frequency spectrum - binned point process
Usage:
[dS,t,f]=mtdspecgrampb(data,movingwin,tapers,phi,pad,Fs,fpass,trialave)
Input:
Note that all times can be in arbitrary units. But the units have to be
consistent. So, if E is in secs, win, t have to be in secs, and Fs has to
be Hz. If E is in samples, so are win and t, and Fs=1. In case of spike
times, the units have to be consistent with the units of data as well.
data (in form samples x channels/trials) -- required
movingwin (in the form [window winstep] i.e length of moving
window and step size.
Note that units here have
to be consistent with
units of Fs
tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
specified, use [NW K]=[3 5]
phi (angle for evaluation of derivative) -- optional.
Default phi=[0,pi/2] giving the time and frequency
derivatives
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 (binning 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
trialave (average over trials when 1, don't average when 0) - optional. Default 0
Output:
dS (spectral derivatives in form angle x time x frequency x channels/trials)
t (times)
f (frequencies)

0001 function [dS,t,f]=mtdspecgrampb(data,movingwin,tapers,phi,pad,Fs,fpass,trialave) 0002 % Multi-taper derivatives of time-frequency spectrum - binned point process 0003 % 0004 % Usage: 0005 % 0006 % [dS,t,f]=mtdspecgrampb(data,movingwin,tapers,phi,pad,Fs,fpass,trialave) 0007 % Input: 0008 % Note that all times can be in arbitrary units. But the units have to be 0009 % consistent. So, if E is in secs, win, t have to be in secs, and Fs has to 0010 % be Hz. If E is in samples, so are win and t, and Fs=1. In case of spike 0011 % times, the units have to be consistent with the units of data as well. 0012 % data (in form samples x channels/trials) -- required 0013 % movingwin (in the form [window winstep] i.e length of moving 0014 % window and step size. 0015 % Note that units here have 0016 % to be consistent with 0017 % units of Fs 0018 % tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not 0019 % specified, use [NW K]=[3 5] 0020 % phi (angle for evaluation of derivative) -- optional. 0021 % Default phi=[0,pi/2] giving the time and frequency 0022 % derivatives 0023 % pad (padding factor for the FFT) - optional. Defaults to 0. 0024 % e.g. For N = 500, if PAD = 0, we pad the FFT 0025 % to 512 points; if PAD = 2, we pad the FFT 0026 % to 2048 points, etc. 0027 % Fs (binning frequency) - optional. Default 1. 0028 % fpass (frequency band to be used in the calculation in the form 0029 % [fmin fmax])- optional. 0030 % Default all frequencies between 0 and Fs/2 0031 % trialave (average over trials when 1, don't average when 0) - optional. Default 0 0032 % Output: 0033 % dS (spectral derivatives in form angle x time x frequency x channels/trials) 0034 % t (times) 0035 % f (frequencies) 0036 0037 if nargin < 2; error('Need data and window parameters'); end; 0038 if nargin < 3; tapers=[3 5]; end; 0039 if nargin < 4; phi=[0 pi/2];end; 0040 if nargin < 5;pad=0;end; 0041 if nargin < 6; Fs=1; end; 0042 if nargin < 7; fpass=[0 Fs/2]; end; 0043 if nargin < 9; trialave=0; end; 0044 0045 N=size(data,1); 0046 Nwin=round(Fs*movingwin(1)); % number of samples in window 0047 Nstep=round(movingwin(2)*Fs); % number of samples to step through 0048 nfft=2^(nextpow2(Nwin)+pad); 0049 [f,findx]=getfgrid(Fs,nfft,fpass); 0050 tapers=dpsschk(tapers,Nwin,Fs); % check tapers 0051 0052 winstart=[1:Nstep:N-Nwin+1]; 0053 nw=length(winstart); 0054 for n=1:nw; 0055 indx=winstart(n):winstart(n)+Nwin-1; 0056 datawin=data(indx,:); 0057 [ds,f]=mtdspectrumpb(datawin,tapers,phi,pad,Fs,fpass,trialave); 0058 dS(n,:,:,:)=ds; 0059 end; 0060 sz=size(ds); 0061 if length(sz)==3; 0062 dS=permute(dS,[2 1 3 4]); 0063 else; 0064 dS=permute(dS,[2 1 3]); 0065 end; 0066 winmid=winstart+round(Nwin/2); 0067 t=winmid/Fs;