Home > chronux_1_1 > continuous > cohmatrixc.m

cohmatrixc

PURPOSE ^

Multi-taper coherency,cross-spectral matrix - continuous process

SYNOPSIS ^

function [C,phi,S12,f,confC,phierr,Cerr]=cohmatrixc(data,params)

DESCRIPTION ^

 Multi-taper coherency,cross-spectral matrix - continuous process

 Usage:

 [C,phi,S12,f,confC,phierr,Cerr]=cohmatrixc(data,params)
 Input: 
 Note units have to be consistent. See chronux.m for more information.
       data (in form samples x channels) -- required
       params: structure with fields tapers, pad, Fs, fpass, err
       - 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
           err  (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars
                                   [0 p] or 0 - no error bars) - optional. Default 0.
 Output:
       C (magnitude of coherency frequency x channels x channels)
       phi (phase of coherency frequency x channels x channels)
       S12 (cross-spectral matrix frequency x channels x channels)
       f (frequencies)
       confC (confidence level for C at 1-p %) - only for err(1)>=1
       phierr - standard deviation for phi (note that the routine gives phierr as phierr(1,...) and phierr(2,...) 
                in order to incorporate Jackknife (eventually). Currently phierr(1,...)=phierr(2,...). Note that 
                phi + 2 phierr(1,...) and phi -2 phierr(2,...) will give 95% confidence bands for phi - only for err(1)>=1
       Cerr  (Jackknife error bars for C - use only for Jackknife - err(1)=2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [C,phi,S12,f,confC,phierr,Cerr]=cohmatrixc(data,params)
0002 % Multi-taper coherency,cross-spectral matrix - continuous process
0003 %
0004 % Usage:
0005 %
0006 % [C,phi,S12,f,confC,phierr,Cerr]=cohmatrixc(data,params)
0007 % Input:
0008 % Note units have to be consistent. See chronux.m for more information.
0009 %       data (in form samples x channels) -- required
0010 %       params: structure with fields tapers, pad, Fs, fpass, err
0011 %       - optional
0012 %           tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
0013 %                                                 specified, use [NW K]=[3 5]
0014 %            pad            (padding factor for the FFT) - optional. Defaults to 0.
0015 %                       e.g. For N = 500, if PAD = 0, we pad the FFT
0016 %                       to 512 points; if PAD = 2, we pad the FFT
0017 %                       to 2048 points, etc.
0018 %           Fs   (sampling frequency) - optional. Default 1.
0019 %           fpass    (frequency band to be used in the calculation in the form
0020 %                                   [fmin fmax])- optional.
0021 %                                   Default all frequencies between 0 and Fs/2
0022 %           err  (error calculation [1 p] - Theoretical error bars; [2 p] - Jackknife error bars
0023 %                                   [0 p] or 0 - no error bars) - optional. Default 0.
0024 % Output:
0025 %       C (magnitude of coherency frequency x channels x channels)
0026 %       phi (phase of coherency frequency x channels x channels)
0027 %       S12 (cross-spectral matrix frequency x channels x channels)
0028 %       f (frequencies)
0029 %       confC (confidence level for C at 1-p %) - only for err(1)>=1
0030 %       phierr - standard deviation for phi (note that the routine gives phierr as phierr(1,...) and phierr(2,...)
0031 %                in order to incorporate Jackknife (eventually). Currently phierr(1,...)=phierr(2,...). Note that
0032 %                phi + 2 phierr(1,...) and phi -2 phierr(2,...) will give 95% confidence bands for phi - only for err(1)>=1
0033 %       Cerr  (Jackknife error bars for C - use only for Jackknife - err(1)=2)
0034 if nargin < 1; error('need data'); end;
0035 if nargin < 2; params=[]; end;
0036 [N,Ch]=size(data);
0037 if Ch==1; error('Need at least two channels of data'); end;
0038 [tapers,pad,Fs,fpass,err,trialave,params]=getparams(params);
0039 clear trialave params
0040 if nargout > 6 && err(1)~=2; 
0041     error('Cerr computed only for Jackknife. Correct inputs and run again');
0042 end;
0043 if nargout >= 4 && err(1)==0;
0044 %   Errors computed only if err(1) is nonzero. Need to change params and run again.
0045     error('When errors are desired, err(1) has to be non-zero.');
0046 end;
0047 nfft=2^(nextpow2(N)+pad);
0048 [f,findx]=getfgrid(Fs,nfft,fpass); 
0049 tapers=dpsschk(tapers,N,Fs); % check tapers
0050 J=mtfftc(data,tapers,nfft,Fs);
0051 J=J(findx,:,:); 
0052 if err(1)==0;
0053      [C,phi,S12]=cohmathelper(J,err);
0054 elseif err(1)==1;
0055      [C,phi,S12,confC,phierr]=cohmathelper(J,err);
0056 elseif err(1)==2;
0057      [C,phi,S12,confC,phierr,Cerr]=cohmathelper(J,err);
0058 end

Generated on Sun 13-Aug-2006 11:49:44 by m2html © 2003