plotLFP = 1;
Rows = 10;%size(allch,2)/nShanks;
wavespec.freqs = [20 300];

figure
title ('waveform average')
hold on
for i = 1:size(allch,2)
subplot(Rows,nShanks,i);
contourf(waveAverage{i+48}.timestamps*1000,waveAverage{i+48}.freqs,waveAverage{i+48}.data',30,'LineColor','none');hold on;
hold on
%set(gca,'YScale','log');
colorbar;
ylim([wavespec.freqs(1) wavespec.freqs(2)]);
colormap jet;
ylabel([num2str(allch(i))])

if plotLFP
   fmin =  wavespec.freqs(round(length(wavespec.freqs)/4)); 
   fmax =  fmin*2;
   lfpSc =(lfpAverage{i+48}.data-min(lfpAverage{i+48}.data))*(fmax-fmin)/(max(lfpAverage{i+48}.data)-min(lfpAverage{i+48}.data))+fmin;
   plot(wavAvg.timestamps*1000,lfpSc,'w','LineWidth',2);hold on; 
   
end
 %clim([0 max(maxPow)])
clim([0 1500])
% if i ==size(allch,2)
%      xlabel('time (ms)'); ylabel('frequency (Hz)');
%  else
% set(gca, 'YTickLabel', [],'XTickLabel', []);
 %end
end
