Home > chronux_1_15 > continuous > mtdspecgramc.m

mtdspecgramc

PURPOSE ^

Multi-taper derivative of the time-frequency spectrum - continuous process

SYNOPSIS ^

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

DESCRIPTION ^

 Multi-taper derivative of the time-frequency spectrum - continuous process

 Usage:

 [dS,t,f]=mtdspecgramc(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        (in form samples x channels/trials or a single vector) -- 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 - required
       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/channels 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]=mtdspecgramc(data,movingwin,phi,params)
0002 % Multi-taper derivative of the time-frequency spectrum - continuous process
0003 %
0004 % Usage:
0005 %
0006 % [dS,t,f]=mtdspecgramc(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 %
0013 %       data        (in form samples x channels/trials or a single vector) -- required
0014 %       movingwin         (in the form [window winstep] i.e length of moving
0015 %                                                 window and step size.
0016 %                                                 Note that units here have
0017 %                                                 to be consistent with
0018 %                                                 units of Fs - required
0019 %       phi         (angle for evaluation of derivative) -- required
0020 %                       e.g. phi=[0,pi/2] giving the time and frequency
0021 %                       derivatives
0022 %       params: structure with fields tapers, pad, Fs, fpass, trialave
0023 %       -optional
0024 %           tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
0025 %                                                 specified, use [NW K]=[3 5]
0026 %            pad            (padding factor for the FFT) - optional. Defaults to 0.
0027 %                       e.g. For N = 500, if PAD = 0, we pad the FFT
0028 %                       to 512 points; if PAD = 2, we pad the FFT
0029 %                       to 2048 points, etc.
0030 %           Fs   (sampling frequency) - optional. Default 1.
0031 %           fpass    (frequency band to be used in the calculation in the form
0032 %                                   [fmin fmax])- optional.
0033 %                                   Default all frequencies between 0 and Fs/2
0034 %           trialave - (average over trials/channels when 1, don't average when 0) - optional. Default 0
0035 % Output:
0036 %       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)
0037 %       t       (times)
0038 %       f       (frequencies)
0039 
0040 if nargin < 3; error('Need data, window parameters and angle'); end;
0041 if nargin < 4; params=[]; end;
0042 [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params);
0043 clear err
0044 data=change_row_to_column(data);
0045 [N,C]=size(data);
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=getfgrid(Fs,nfft,fpass); Nf=length(f);
0050 params.tapers=dpsschk(tapers,Nwin,Fs); % check tapers
0051 params.tapers=tapers;
0052 winstart=1:Nstep:N-Nwin+1;
0053 nw=length(winstart);
0054 if trialave==0; dS=zeros(length(phi),nw,Nf,C); else dS=zeros(length(phi),nw,Nf); end; 
0055 for n=1:nw;
0056    indx=winstart(n):winstart(n)+Nwin-1;
0057    datawin=data(indx,:);
0058    [ds,f]=mtdspectrumc(datawin,phi,params);
0059    dS(:,n,:,:)=ds;
0060 end;
0061 dS=squeeze(dS);
0062 sz=size(dS);
0063 % if length(sz)==3;
0064 %    dS=permute(dS,[2 1 3 4]);
0065 % elseif length(phi)>1
0066 %    dS=permute(dS,[2 1 3]);
0067 % end;
0068 winmid=winstart+round(Nwin/2);
0069 t=winmid/Fs;

Generated on Tue 15-Aug-2006 22:51:57 by m2html © 2003