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

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

waveFilt = bandFilter(wave,10,40,S/1000);
wavefft = fft(waveFilt);
wavemag = abs(wavefft);
%wavemag(1,:)=0;
f = (0:length(wavefft)-1)'*S/length(wavefft);

%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(f(1:100), wavemag(1:100,23)); axis([0 50 0 25]); xlabel ('Frequency (Hz)'); ylabel ('Magnitude');

figure
for n=1:64
subplot(8,8,n); plot(f(1:100), wavemag(1:100, n+1)); axis([0 50 0 25]); axis off;
end