%filters data and plots coherence for 64 electrode array
%requires raw data and sampling frequency

function [f] = PlotCohere6( wave );

waveFilt = BudapestbandPass(wave,1000,10,40,1000);
%lessedges = waveFilt (300:9699);
%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
%[waveCohere,f] = cohere(waveFilt(:,35),waveFilt(:,23),256,1000);
%plot(f, waveCohere); axis([0 50 0 1]); 
figure
for n=1:64
[waveCohere,f] = cohere(waveFilt(:,n),waveFilt(:,12),256,1000);
subplot(8,8,n); plot(f, waveCohere); axis([0 50 0 1]); axis off;
[C(n),I(n)]=max(waveCohere);
end
amp=reshape(C,8,8)'
freq=reshape(I,8,8)'
figure
interp_L=interp2(amp,4,'linear');
imagesc(interp_L); colorbar('vert'); %axes off;
%caxis([0 1]) 
axis('image')
axis('off')