mtdspecgrampt

PURPOSE ^

Multi-taper derivative time-frequency spectrum - point process times

SYNOPSIS ^

function [dS,t,f]=mtdspecgrampt(data,movingwin,tapers,phi,pad,Fs,fpass,trialave)

DESCRIPTION ^

 Multi-taper derivative time-frequency spectrum - point process times

 Usage:

 [dS,t,f]=mtdspectgrampt(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        (structure array of spike times for each channel; also accepts 1d array of spike times) -- 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 for fft grid used to calculate fft of prolates. 1/Fs is the time between consecutive
                                   points on the grid used for evaluation of the prolates) - 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       (spectrum in form angle x time x frequency x channels/trials)
       t       (times)
       f       (frequencies)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [dS,t,f]=mtdspecgrampt(data,movingwin,tapers,phi,pad,Fs,fpass,trialave)
0002 % Multi-taper derivative time-frequency spectrum - point process times
0003 %
0004 % Usage:
0005 %
0006 % [dS,t,f]=mtdspectgrampt(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        (structure array of spike times for each channel; also accepts 1d array of spike times) -- 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 for fft grid used to calculate fft of prolates. 1/Fs is the time between consecutive
0028 %                                   points on the grid used for evaluation of the prolates) - optional. Default 1.
0029 %       fpass       (frequency band to be used in the calculation in the form
0030 %                                   [fmin fmax])- optional.
0031 %                                   Default all frequencies between 0 and Fs/2
0032 %       trialave    (average over trials when 1, don't average when 0) - optional. Default 0
0033 % Output:
0034 %       dS       (spectrum in form angle x time x frequency x channels/trials)
0035 %       t       (times)
0036 %       f       (frequencies)
0037 
0038 if nargin < 2; error('Need data and window parameters'); end;
0039 if nargin < 3; tapers=[3 5]; end;
0040 if nargin < 4; phi=[0 pi/2];end;
0041 if nargin < 5;pad=0;end;
0042 if nargin < 6; Fs=1; end;
0043 if nargin < 7; fpass=[0 Fs/2]; end;
0044 if nargin < 8; trialave=0; end;
0045 
0046 [mintime,maxtime]=minmaxsptimes(data);
0047 tn=[mintime+movingwin(1)/2:movingwin(2):maxtime-movingwin(1)/2];
0048 Nwin=round(Fs*movingwin(1)); % number of samples in window
0049 Nstep=round(movingwin(2)*Fs); % number of samples to step through
0050 nfft=2^(nextpow2(Nwin)+pad);
0051 [f,findx]=getfgrid(Fs,nfft,fpass); 
0052 tapers=dpsschk(tapers,Nwin)/sqrt(Fs); % check tapers
0053 K=size(tapers,2);
0054 nw=length(tn);
0055 
0056 for n=1:nw;
0057    t=linspace(tn(n)-movingwin(1)/2,tn(n)+movingwin(1)/2,Nwin);
0058    datawin=extractspdata(data,[t(1) t(end)]);
0059    [ds,f]=mtdspectrumpt(datawin,tapers,phi,pad,Fs,fpass,trialave,t);
0060    dS(n,:,:,:)=ds;
0061 end;
0062 sz=size(ds);
0063 if length(sz)==3;
0064    dS=permute(dS,[2 1 3 4]);
0065 else;
0066    dS=permute(dS,[2 1 3]);
0067 end;
0068 t=tn;

Generated on Tue 24-Aug-2004 15:55:33 by m2html © 2003