%% optical stim plots

clear;
load('C:\Users\USER\Documents\mingfaifong\2013-01-21_trouble22468_12-14DIV_MEA_CNQX-ChR2-stim-CL\trouble22468_x1_x2_plottingBursts.mat');

dt = 0.01;

%% zoomed ASDR for pre-drug
fid = 'ASDR_NoDrug_snip1sec';
x1.bin = 0:dt:max(x1.time);
x1.asdr = histc(x1.time,x1.bin)/dt;
x1_peak = 0;
x1_peak = 6.773761000000000e+04;
hold off;
plot(x1.bin-x1_peak,x1.asdr);
xlim([-0.2 0.8]); ylim([0 2.5e4]);
% xlim([6.7735e4 6.7745e4])
% plot(x1.time,x1.channel+0.15*randn(size(x1.channel)),'.k');

%% zoomed Raster for pre-drug
fid = 'Raster_NoDrug_snip1sec';
hold off;
plot(x1.time-x1_peak,x1.channel+0.15*randn(size(x1.channel)),'.k','MarkerSize',0.5);
xlim([-0.2 0.8]); ylim([1 64]);

%% zoomed ASDR for CNQX+stim
fid = 'ASDR_CNQXstim1X_snip1sec';
x2.bin = 0:dt:max(x2.time);
x2.asdr = histc(x2.time,x2.bin)/dt;
x2_peak = 0;
x2_peak = 8.485127000000000e+04-dt;
hold off;
plot(x2.bin-x2_peak,x2.asdr,'-b');
xlim([-0.2 0.8]); ylim([0 2.5e4]);
% xlim([8.485116948000000e+04-0.2 8.485116948000000e+04+0.8]);

%% zoomed Raster for CNQX+stim
fid = 'Raster_CNQXstim1X_snip1sec';
hold off;
plot(x2.time-x2_peak,x2.channel+0.15*randn(size(x2.channel)),'.k','MarkerSize',0.5);
xlim([-0.2 0.8]); ylim([1 64]);


%% overlay burst ASDR for all pre-drug
clear;
load('C:\Users\USER\Documents\mingfaifong\2013-05-28_burstanalysis\trouble22468_burst.mat')
fid = 'ASDR_NoDrug_overlay1sec';
cmap_end = [0.8 0.8 0.8];
tmp.burst.snippet.FR = [pre6to3hr.burst.snippet.FR;pre.burst.snippet.FR]
x_peak = 0.02;
plot(snippetWidth-x_peak,tmp.burst.snippet.FR,'LineWidth',0.1,'Color',cmap_end)
xlim([-0.2 0.8]);
ylim([0 2.5e4]);

%% overlay burst ASDR for all CNQX+stim
fid = 'ASDR_CNQXstim1X_overlay1sec';
x_peak = 0.08;
plot(snippetWidth-x_peak,drug.burst.snippet.FR,'LineWidth',0.1,'Color',cmap_end)
xlim([-0.2 0.8]);
ylim([0 2.5e4]);



%% adjust figure size;
box off;
set(gcf,'units','centimeters','Position',[0 9 23.563*2/10 5.824*2/10]); % 5cm across, 1.5m high
set(gca,'units','centimeters','Position',[0 0 23.563*2/10 5.824*2/10],'XTick',[],'YTick',[]);

%% exportfig

savedir = 'C:\Users\USER\Documents\mingfaifong\UpScalingPaper_figures\2013-06-23\';
export_fig([savedir fid],'-pdf','-transparent','-r300');
