%% Comparison of spike-spike coherence using the two group coherence comparison test
display('To compare the spike-spike coherence in the baseline period with that in the delay period, press enter');
pause
%
% Preliminary parameter settings
%
params.Fs=1000;
params.fpass=[0 200];
params.tapers=[5 9];
params.trialave=1;
params.err=0;
%
% Extract data and set some parameters necessary to compute Fourier
% transform
delay_times=[1 2];
datasp1=extractdatapt(dsp1t,delay_times,1);
datasp2=extractdatapt(dsp2t,delay_times,1);
N=params.Fs;
t=linspace(0,1,N);
nfft=2048;
[f,findx]=getfgrid(params.Fs,nfft,params.fpass);
tapers=dpss(N,params.tapers(1),params.tapers(2));
%
% Tapered fourier transforms
%
J1c1=mtfftpt(datasp1,tapers,nfft,t,f,findx);
J2c1=mtfftpt(datasp2,tapers,nfft,t,f,findx);
datasp1=dsp1b(1:25);
datasp2=dsp2b(1:25);
J1c2=mtfftpt(datasp1,tapers,nfft,t,f,findx);
J2c2=mtfftpt(datasp2,tapers,nfft,t,f,findx);
J1c1=reshape(J1c1,[size(J1c1,1) size(J1c1,2)*size(J1c1,3)]);
J2c1=reshape(J2c1,[size(J2c1,1) size(J2c1,2)*size(J2c1,3)]);
J1c2=reshape(J1c2,[size(J1c2,1) size(J1c2,2)*size(J1c2,3)]);
J2c2=reshape(J2c2,[size(J2c2,1) size(J2c2,2)*size(J2c2,3)]);
%
% Run the two sample test for comparing two coherences
%
figure;
[dz,vdz,Adz]=two_group_test_coherence(J1c1,J2c1,J1c2,J2c2,p,'y',f);
position_figure
