Home > chronux_0.5 > pointtimes > mtdspecgrampt.m

mtdspecgrampt

PURPOSE ^

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

SYNOPSIS ^

function [dS,t,f]=mtdspecgrampt(data,movingwin,phi,params)

DESCRIPTION ^

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

 Usage:

 [dS,t,f]=mtdspecgrampt(data,movingwin,phi,params)
 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 with dimension channels/trials; 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
       phi         (angle for evaluation of derivative) -- required.
                       e.g. phi=[0,pi/2] giving the time and frequency
                       derivatives
       params: structure with fields tapers, pad, Fs, fpass, 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
           trialave (average over trials when 1, don't average when 0) -
           optional. Default 0
 Output:
       dS      (spectral derivative in form phi x time x frequency x channels/trials if trialave=0; in form phi x time x frequency if trialave=1)
       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,phi,params)
0002 % Multi-taper derivative time-frequency spectrum - point process times
0003 %
0004 % Usage:
0005 %
0006 % [dS,t,f]=mtdspecgrampt(data,movingwin,phi,params)
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 with dimension channels/trials; 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 %       phi         (angle for evaluation of derivative) -- required.
0019 %                       e.g. phi=[0,pi/2] giving the time and frequency
0020 %                       derivatives
0021 %       params: structure with fields tapers, pad, Fs, fpass, trialave
0022 %       -optional
0023 %           tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
0024 %                                                 specified, use [NW K]=[3 5]
0025 %            pad            (padding factor for the FFT) - optional. Defaults to 0.
0026 %                       e.g. For N = 500, if PAD = 0, we pad the FFT
0027 %                       to 512 points; if PAD = 2, we pad the FFT
0028 %                       to 2048 points, etc.
0029 %           Fs   (sampling frequency) - optional. Default 1.
0030 %           fpass    (frequency band to be used in the calculation in the form
0031 %                                   [fmin fmax])- optional.
0032 %                                   Default all frequencies between 0 and
0033 %                                   Fs/2
0034 %           trialave (average over trials when 1, don't average when 0) -
0035 %           optional. Default 0
0036 % Output:
0037 %       dS      (spectral derivative in form phi x time x frequency x channels/trials if trialave=0; in form phi x time x frequency if trialave=1)
0038 %       t       (times)
0039 %       f       (frequencies)
0040 
0041 if nargin < 3; error('Need data, window parameters and angle'); end;
0042 if nargin < 4; params=[]; end;
0043 [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params);
0044 
0045 [mintime,maxtime]=minmaxsptimes(data);
0046 tn=(mintime+movingwin(1)/2:movingwin(2):maxtime-movingwin(1)/2);
0047 Nwin=round(Fs*movingwin(1)); % number of samples in window
0048 Nstep=round(movingwin(2)*Fs); % number of samples to step through
0049 nfft=2^(nextpow2(Nwin)+pad);
0050 [f,findx]=getfgrid(Fs,nfft,fpass); 
0051 params.tapers=dpsschk(tapers,Nwin,Fs); % check tapers
0052 %K=size(params.tapers,2);
0053 nw=length(tn);
0054 
0055 for n=1:nw;
0056    t=linspace(tn(n)-movingwin(1)/2,tn(n)+movingwin(1)/2,Nwin);
0057    datawin=extractdatapt(data,[t(1) t(end)]);
0058    [ds,f]=mtdspectrumpt(datawin,phi,params,t);
0059    dS(n,:,:,:)=ds;
0060 end;
0061 sz=size(ds);
0062 if length(sz)==3;
0063    dS=permute(dS,[2 1 3 4]);
0064 else
0065    dS=permute(dS,[2 1 3]);
0066 end;
0067 t=tn;

Generated on Tue 16-Aug-2005 21:33:45 by m2html © 2003