mtdspectrumpt

PURPOSE ^

Multi-taper spectral derivative - point process times

SYNOPSIS ^

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

DESCRIPTION ^

 Multi-taper spectral derivative - point process times

 Usage:

 [dS,f]=mtdspectrumpt(data,tapers,phi,pad,Fs,fpass,trialave,t)
 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 channels/trials with spike times) -- required
       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
       t        (time grid over which the tapers are to be calculated:
                      this argument is useful when calling the spectrum
                      calculation routine from a moving window spectrogram
                      calculation routine). If left empty, the spike times
                      are used to define the grid.
 Output:
       dS       (spectrum in form angle x frequency x taper index x channels/trials)
       f       (frequencies)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [dS,f]=mtdspectrumpt(data,tapers,phi,pad,Fs,fpass,trialave,t)
0002 % Multi-taper spectral derivative - point process times
0003 %
0004 % Usage:
0005 %
0006 % [dS,f]=mtdspectrumpt(data,tapers,phi,pad,Fs,fpass,trialave,t)
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 channels/trials with spike times) -- required
0013 %       tapers      (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
0014 %                                                 specified, use [NW K]=[3 5]
0015 %       phi         (angle for evaluation of derivative) -- optional.
0016 %                       Default phi=[0,pi/2] giving the time and frequency derivatives
0017 %        pad            (padding factor for the FFT) - optional. Defaults to 0.
0018 %                       e.g. For N = 500, if PAD = 0, we pad the FFT
0019 %                       to 512 points; if PAD = 2, we pad the FFT
0020 %                       to 2048 points, etc.
0021 %       Fs          (binning frequency for fft grid used to calculate fft of prolates. 1/Fs is the time between consecutive
0022 %                                   points on the grid used for evaluation of the prolates) - optional. Default 1.
0023 %       fpass       (frequency band to be used in the calculation in the form
0024 %                                   [fmin fmax])- optional.
0025 %                                   Default all frequencies between 0 and Fs/2
0026 %       trialave (average over trials when 1, don't average when 0) -
0027 %       optional. Default 0
0028 %       t        (time grid over which the tapers are to be calculated:
0029 %                      this argument is useful when calling the spectrum
0030 %                      calculation routine from a moving window spectrogram
0031 %                      calculation routine). If left empty, the spike times
0032 %                      are used to define the grid.
0033 % Output:
0034 %       dS       (spectrum in form angle x frequency x taper index x channels/trials)
0035 %       f       (frequencies)
0036 if nargin < 1; error('Need data'); end;
0037 if nargin < 2; tapers=[3 5]; end;
0038 if nargin < 3; phi=[0 pi/2];end;
0039 if nargin < 4;pad=0;end;
0040 if nargin < 5; Fs=1; end;
0041 if nargin < 6; fpass=[0 Fs/2]; end;
0042 if nargin < 7; trialave=0; end;
0043 dt=1/Fs; % sampling time
0044 if nargin < 8;
0045    [mintime,maxtime]=minmaxsptimes(data);
0046    t=mintime:dt:maxtime+dt; % time grid for prolates
0047 end;
0048 N=length(t); % number of points in grid for dpss
0049 nfft=2^(nextpow2(N)+pad); % number of points in fft of prolates
0050 [f,findx]=getfgrid(Fs,nfft,fpass); % get frequency grid for evaluation
0051 tapers=dpsschk(tapers,N)*sqrt(Fs); % check tapers
0052 K=size(tapers,2);
0053 [J,Msp,Nsp]=mtfftpt(data,tapers,nfft,t,f,findx); % mt fft for point process times
0054 S=squeeze(mean(J(:,1:K-1,:).*conj(J(:,2:K,:)),2));
0055 if trialave; S=squeeze(mean(S,2));end;
0056 nphi=length(phi);
0057 for p=1:nphi;
0058     dS(p,:,:)=real(exp(i*phi(p))*S);
0059 end;
0060 dS=squeeze(dS);

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