crossspecpb

PURPOSE ^

Multi-taper cross spectrum - binned point process

SYNOPSIS ^

function [S12,f]=crossspecpb(data1,data2,tapers,pad,Fs,fpass)

DESCRIPTION ^

 Multi-taper cross spectrum - binned point process

 Usage:

 [S12,f]=coherencypb(data1,data2,tapers,pad,Fs,fpass)
 Input: 
       data1 (in form samples x channels/trials) -- required
       data2 (in form samples x channels/trials) -- 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]
        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) - 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
 Output:
       S12 (cross spectrum frequency index x channels/trials)
       f (frequencies)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [S12,f]=crossspecpb(data1,data2,tapers,pad,Fs,fpass)
0002 % Multi-taper cross spectrum - binned point process
0003 %
0004 % Usage:
0005 %
0006 % [S12,f]=coherencypb(data1,data2,tapers,pad,Fs,fpass)
0007 % Input:
0008 %       data1 (in form samples x channels/trials) -- required
0009 %       data2 (in form samples x channels/trials) -- required
0010 %       tapers (precalculated tapers from dpss, or in the form [NW K] e.g [3 5]) -- optional. If not
0011 %                                                 specified, use [NW K]=[3 5]
0012 %        pad            (padding factor for the FFT) - optional. Defaults to 0.
0013 %                       e.g. For N = 500, if PAD = 0, we pad the FFT
0014 %                       to 512 points; if PAD = 2, we pad the FFT
0015 %                       to 2048 points, etc.
0016 %       Fs   (binning frequency) - optional. Default 1.
0017 %       fpass    (frequency band to be used in the calculation in the form
0018 %                                   [fmin fmax])- optional.
0019 %                                   Default all frequencies between 0 and Fs/2
0020 % Output:
0021 %       S12 (cross spectrum frequency index x channels/trials)
0022 %       f (frequencies)
0023 
0024 
0025 [N,C]=size(data1);
0026 if nargin < 2; error('Need data1 and data2'); end;
0027 if nargin < 3; tapers=[3 5]; end;
0028 if nargin < 4;pad=0;end;
0029 if nargin < 5; Fs=1; end;
0030 if nargin < 6; fpass=[0 Fs/2]; end;
0031 if isempty(tapers); tapers=[3 5]; end;
0032 if isempty(pad);pad=0;end;
0033 if isempty(Fs); Fs=1; end;
0034 if isempty(fpass); fpass=[0 Fs/2]; end;
0035 nfft=2^(nextpow2(N)+pad);
0036 [f,findx]=getfgrid(Fs,nfft,fpass); 
0037 tapers=dpsschk(tapers,N); % check tapers
0038 [J1,Msp1,Nsp1]=mtfftpb(data1,tapers,nfft);
0039 [J2,Msp2,Nsp2]=mtfftpb(data2,tapers,nfft);
0040 J1=J1(findx,:,:);
0041 J2=J2(findx,:,:);
0042 S12=squeeze(mean(conj(J1).*J2,2));
0043 if trialave; S12=squeeze(mean(S12,2));end;

Generated on Wed 11-May-2005 16:43:02 by m2html © 2003