Home > chronux_code > exploratory > correlations > pointtimes > coherencysegpt.m

coherencysegpt

PURPOSE ^

Multi-taper coherency computed by segmenting two univariate point processes

SYNOPSIS ^

function [C,phi,S12,S1,S2,f,zerosp]=coherencysegpt(data1,data2,win,tapers,pad,Fs,fpass,segave)

DESCRIPTION ^

 Multi-taper coherency computed by segmenting two univariate point processes
 into chunks

 Usage:
 [C,phi,S12,S1,S2,f,zerosp]=coherencysegpt(data1,data2,tapers,nfft,Fs,fpass,err,trialave)
 Input: 
 Note units have to be consistent. See chronux.m for more information.
       data1 (1d structure array of spike times; also accepts 1d array of spike times) -- required
       data2 (1d structure array of spike times; also accepts 1d array of spike times) -- required
       win   (length of segments) - 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   (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
       segave (average over segments for 1, don't average for 0)
 Output:
       C (abs of coherency as a function of frequency x segments if no segment averaging)
       phi (phase of coherency as a function of frequency x segments if no segment averaging)
       S12 (cross spectrum - frequencies x segments if no segment averaging)
       S1 (spectrum 1- frequencies x segments if no segment averaging)
       S2 (spectrum 2- frequencies x segments if no segment averaging)
       f (frequencies)
       zerosp (1 for segments where no spikes were found, 0 otherwise)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [C,phi,S12,S1,S2,f,zerosp]=coherencysegpt(data1,data2,win,tapers,pad,Fs,fpass,segave)
0002 % Multi-taper coherency computed by segmenting two univariate point processes
0003 % into chunks
0004 %
0005 % Usage:
0006 % [C,phi,S12,S1,S2,f,zerosp]=coherencysegpt(data1,data2,tapers,nfft,Fs,fpass,err,trialave)
0007 % Input:
0008 % Note units have to be consistent. See chronux.m for more information.
0009 %       data1 (1d structure array of spike times; also accepts 1d array of spike times) -- required
0010 %       data2 (1d structure array of spike times; also accepts 1d array of spike times) -- required
0011 %       win   (length of segments) - required
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 %       segave (average over segments for 1, don't average for 0)
0023 % Output:
0024 %       C (abs of coherency as a function of frequency x segments if no segment averaging)
0025 %       phi (phase of coherency as a function of frequency x segments if no segment averaging)
0026 %       S12 (cross spectrum - frequencies x segments if no segment averaging)
0027 %       S1 (spectrum 1- frequencies x segments if no segment averaging)
0028 %       S2 (spectrum 2- frequencies x segments if no segment averaging)
0029 %       f (frequencies)
0030 %       zerosp (1 for segments where no spikes were found, 0 otherwise)
0031 
0032 if nargin < 3; error('Need data1 and data2 and size of segment'); end;
0033 if nargin < 4; tapers=[3 5]; end;
0034 if nargin < 5;pad=0;end;
0035 if nargin < 6; Fs=1; end;
0036 if nargin < 7; fpass=[0 Fs/2]; end;
0037 if isempty(tapers); tapers=[3 5]; end;
0038 if isempty(pad);pad=0;end;
0039 if isempty(Fs); Fs=1; end;
0040 if isempty(fpass); fpass=[0 Fs/2]; end;
0041 
0042 [N1,C1,N2,C2]=check_consistency(data1,data2);
0043 [mintime1,maxtime1]=minmaxsptimes(data1);
0044 [mintime2,maxtime2]=minmaxsptimes(data2);
0045 mintime=min(mintime1,mintime2);
0046 maxtime=max(maxtime1,maxtime2);
0047 dt=1/Fs;
0048 t=mintime:dt:maxtime+dt; % time grid for prolates
0049 N=length(t); % number of points in grid for dpss
0050 
0051 E=[mintime:win:maxtime]; % fictitious event triggers
0052 win=[0 win]; % use window length to define left and right limits of windows around triggers
0053 data1=createdatamatpt(data1,E,Fs,win); % segmented data 1
0054 data2=createdatamatpt(data2,E,Fs,win); % segmented data 2
0055 [C,phi,S12,S1,S2,f,zerosp]=coherencypt(data1,data2,tapers,pad,Fs,fpass,0,segave); % compute coherency for segmented data

Generated on Tue 07-Jun-2005 12:20:32 by m2html © 2003