%% Plot spike rasters and average LFPs
display('To plot spike rasters, press enter');
pause
%
% Plot spike rasters
% first for the baseline data
figure;
subplot(221);
for n=1:Nbase;
    plot(dsp1b(n).times,n*ones(1,length(dsp1b(n))),'d','Markersize',1.5); hold on;
end;
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('Trials');
title('Cell 1, Baseline');
subplot(222);
for n=1:Nbase;
    plot(dsp2b(n).times,n*ones(1,length(dsp2b(n))),'d','Markersize',1.5); hold on;
end;
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('Trials');
title('Cell 2, Baseline');
%
% Now for the trials
%
subplot(223);
for n=1:Ntrials;
    plot(dsp1t(n).times,n*ones(1,length(dsp1t(n))),'d','Markersize',1.5); hold on;
end;
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('Trials');
title('Cell 1, Trial');
subplot(224);
for n=1:Ntrials;
    plot(dsp2t(n).times,n*ones(1,length(dsp2t(n))),'d','Markersize',1.5); hold on;
end;
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('Trials');
title('Cell 2, Trial');
position_figure
%
% Plot mean LFPs
% first the baseline periods
display('To plot average LFP, press enter');
pause
figure;
subplot(231);
plot((1:NTbase)/1000,mean(dlfp1b,2));
set(gca,'FontName','Times New Roman','Fontsize', 14);
title('LFP 1, Baseline');
xlabel('time s'); ylabel('V(t)');
subplot(232);
plot((1:NTbase)/1000,mean(dlfp2b,2))
set(gca,'FontName','Times New Roman','Fontsize', 14);
title('LFP 2, Baseline');
xlabel('time s'); ylabel('V(t)');
subplot(233);
plot((1:NTbase)/1000,mean(dlfp3b,2));
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('V(t)');
title('LFP 3, Baseline');
%
% Now for the trials
%
subplot(234);
NTtrials=size(dlfp1t,1);
plot((1:NTtrials)/1000,mean(dlfp1t,2));
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('V(t)');xlim([0 3]);
title('LFP 1, Trial');
subplot(235);
plot((1:NTtrials)/1000,mean(dlfp2t,2))
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('V(t)');xlim([0 3]);
title('LFP 2, Trial');
subplot(236);
plot((1:NTtrials)/1000,mean(dlfp3t,2));
set(gca,'FontName','Times New Roman','Fontsize', 14);
xlabel('time s'); ylabel('V(t)');xlim([0 3]);
title('LFP 3, Trial');
position_figure
