%filters data and plots crosscorrelations for 7 electrode array
%requires raw data and sampling frequency

function [data] = PlotCrossCorr7Ch( wave, S );

waveFilt = BudapestbandPass(wave,1000,5,200);
[waveCorr,lags] = xcov(waveFilt(200:700,2:8),200,'coeff');
%[waveCorr,lags] = xcorr(waveFilt(1:100,2:65),200,'coeff');

%Lrotate=ones(8,8);
%for m=1:8
 %   for n=1:8
  %      Lrotate(m,n)=n*8-m+1;
  % end
  %end
%Lrotate=reshape(Lrotate,1,64);

%Rrotate=ones(8,8);
%for n=1:8
 %   for m=1:8
  %      Rrotate(m,n)=8*(8-m)+n;
  % end
  %end
%Rrotate=reshape(Rrotate,1,64);

%figure
%plot(lags,waveCorr(:,7.*2+7)); axis([-10 10 -1 1]); grid on;
%figure
%for n=1:7
%subplot(4,2,n); plot(lags, waveCorr(:,7.*(n-1)+6)); axis([-10 10 -1 1]); grid on; %axis off;
%end

for n=1:7
[C(n),I(n)]=max(waveCorr(:,7*(n-1)+3))
end
J=I-I(3)

%figurew
%plot(lags,waveCorr(:,7.*2+7)); axis([-100 100 -1 1]); grid on;
%figure
%for n=1:7
%subplot(4,2,n); plot(lags, waveCorr(:,7.*(n-1)+6)); axis([-100 100 -1 1]); grid on; %axis off;
%end