savedir = 'C:\Users\USER\Documents\mingfaifong\UpScalingPaper_figures\2013-06-16\';

%% ASDRs with absolute units

set(gcf,'units','centimeters','Position',[0 9 18 2]); % 180mm across, 20mm high
set(gca,'FontSize',9,'FontName','Arial')
xlabel('','FontName','Arial');
ylabel(['MEA-wide Firing Rate (Hz)'],'FontSize',9,'FontName','Arial')
xlim([-6 24]);
ylim([0 1000]);
set(gca,'units','centimeters','Position',[1.5 0.5 18-1.5 1.5]);
set(gca,'LineWidth',0.5)
set(gca,'XTick',[-6:1:24],'YTick',[0:200:1000])

%% exportfig
fid = 'ASDR-APV-vivy21369C';
export_fig([savedir fid],'-pdf','-transparent','-r300');


%% CTZ over Time
box off;
set(gcf,'units','centimeters','Position',[1 10 12 5]); % 10cm across, 5cm high
set(gca,'FontSize',9,'FontName','Arial')
% set(gca,'units','centimeters','Position',[0.1 0.1 4.5-0.1 3-0.1]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'CTZ-over-time_tommy1_charge2';
export_fig([savedir fid],'-pdf','-transparent','-m2');


%% Mini Current Traces
box off;
axis off;
set(gcf,'units','centimeters','Position',[1 10 4.5 3]); % 2cm across, 2cm high
set(gca,'FontSize',6,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 4.5-0.1 3-0.1]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'miniTrace_TTX-bic_rafiki1';
export_fig([savedir fid],'-pdf','-transparent','-m2');


%% Rafiki1 CTZ barplots

subplot(1,4,1); set(gca,'TickDir','out','LineWidth',0.5,'FontSize',6); box off;
subplot(1,4,2); set(gca,'TickDir','out','LineWidth',0.5,'FontSize',6); box off;
subplot(1,4,3); set(gca,'TickDir','out','LineWidth',0.5,'FontSize',6); box off;
subplot(1,4,4); set(gca,'TickDir','out','LineWidth',0.5,'FontSize',6); box off;
% 
% set(gcf,'units','centimeters','Position',[1 10 4.5 3]); % 2cm across, 2cm high
% set(gca,'FontSize',6,'FontName','Arial')
% set(gca,'units','centimeters','Position',[0.1 0.1 4.5-0.1 3-0.1]);
% set(gca,'LineWidth',0.5);
%% exportfig
fid = 'cyclothiazideEffects';
export_fig([savedir fid],'-pdf','-transparent','-m2');

%% Mean Mini Amplitude
box off;
ylim([0 20]);
xlim([0.5 3.5]);
set(gca,'TickDir','out','YTick',[0:5:20],'TickLength',[0.02 0.025]);

set(gcf,'units','centimeters','Position',[1 10 2 2]); % 2cm across, 2cm high
set(gca,'FontSize',6,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 2-0.1 2-0.1]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'MeanAmp_ctrl-TTX-TTXCTZ';
export_fig([savedir fid],'-pdf','-transparent','-m2');

%% Cumulative Histogram of Mini Amplitudes
box off;
ylim([0 1]);
xlim([5 60]);
set(gca,'TickDir','out','YTick',[0:0.2:1],'TickLength',[0.02 0.025],'XTick',[0:10:100]);

set(gcf,'units','centimeters','Position',[1 10 2 2]); % 2cm across, 2cm high
set(gca,'FontSize',6,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 2-0.1 2-0.1]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'CumHist_ctrl-TTX-TTXCTZ';
export_fig([savedir fid],'-pdf','-transparent','-m2');

%% Rank Order of Mini Amplitudes
box off;
ylim([5 100]);
xlim([5 100]);
set(gca,'TickDir','out','YTick',[0:20:100],'TickLength',[0.02 0.025],'XTick',[0:20:100]);

set(gcf,'units','centimeters','Position',[1 10 2 2]); % 2cm across, 2cm high
set(gca,'FontSize',6,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 2-0.1 2-0.1]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'RankOrder_TTX-TTXCTZ';
export_fig([savedir fid],'-pdf','-transparent','-m2');

%% Mini Amplitude vs. FR, BR, IBIFR
box off;
ylim([1 2]);
xlim([0 1]);
set(gca,'TickDir','out','TickLength',[0.02 0.025],...
    'YTick',[1:0.2:2],'YTickLabel',[100:20:200],...
    'XTick',[0:0.2:3],'XTickLabel',[0:20:300]);

set(gcf,'units','centimeters','Position',[1 10 2 2]); % 2cm across, 2cm high
set(gca,'FontSize',6,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 2-0.1 2-0.1]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'miniAmpIBIFR_TTX-CNQX_fixedwidth';
export_fig([savedir fid],'-pdf','-transparent','-m2');
%% ASDR for CNQX only (usain22493), 1sec bins
set(gcf,'Position',[34 600 2504 323]);
xlim([-6 24])

%% ASDR for CNQX only (usain22493), 1hr bins
set(gcf,'Position',[9 575 521 343]);
xlim([-6 24])

%% exportfig
% fid = 'ASDR_CNQX_usain22493-1hr';
fid = 'ASDR_TTX_cinderella19308-1hr';
export_fig([savedir fid],'-pdf','-transparent','-m2');

%% ASDRs with absolute units

set(gcf,'units','centimeters','Position',[0 9 18 2]); % 180mm across, 20mm high
set(gca,'FontSize',9,'FontName','Arial')
% xlabel('Time (hours)','FontSize',9)
% ylabel(['MEA-wide',10,'Firing Rate',10,'(Hz)'],'FontSize',9)
xlabel('','FontName','Arial');
% ylabel('');
ylabel(['MEA-wide Firing Rate (Hz)'],'FontSize',9,'FontName','Arial')
% xlim([-6 24+5/60]);
xlim([-6 24]);
set(gca,'units','centimeters','Position',[1.5 0.5 18-1.5 1.5]);
set(gca,'LineWidth',0.5)
set(gca,'XTick',[-6:1:24])

%% exportfig
fid = 'ASDR-CNQX_bin1sec_cinderella19307b';
export_fig([savedir fid],'-pdf','-transparent','-r300');

%% ASDR or Raster example

set(gcf,'units','centimeters','Position',[0 9 4 1.5]); % 4cm across, 1.5m high
set(gca,'FontSize',9,'FontName','Arial')
xlabel('','FontName','Arial');
ylabel(['MEA-wide Firing Rate (Hz)'],'FontSize',9,'FontName','Arial')
% ylabel(['Electrode Number'],'FontSize',9,'FontName','Arial'); ylim([1 64]);
xlim([3.3 3.3+10/60])
set(gca,'units','centimeters','Position',[0.1 0.1 4-0.1 1.4]);
set(gca,'LineWidth',0.5,'YTick',[0:1000:4000],'XTick',[3.3:1/60:3.3+10/60])
% set(gca,'LineWidth',0.5,'YTick',[1 64],'XTick',[3.3:1/60:3.3+10/60])
% set(gca,'XTick',[-6:1:24])
% 
% xlim([3.4377 3.4377+2/3600])
% set(gca,'LineWidth',0.5,'YTick',[1 64],'XTick',[])

%% exportfig
fid = 'ASDR-example-10min-b';
export_fig([savedir fid],'-pdf','-transparent','-r300');

%% FR over time

xlim([-6 24]); box off;
set(gcf,'units','centimeters','Position',[10 10 8 2.5]); % 8cm across, 2.5m high
set(gca,'FontSize',9,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 8-0.1 2.4]);
set(gca,'LineWidth',0.5);

%% exportfig
fid = 'FR-over-time_blank';
export_fig([savedir fid],'-pdf','-transparent','-r300');

%% FR, BR, IBFR over time
box off;
set(gcf,'units','centimeters','Position',[10 10 3 2]); % 8cm across, 2.5m high
set(gca,'FontSize',9,'FontName','Arial')
set(gca,'units','centimeters','Position',[0.1 0.1 3-0.1 1.9]);
set(gca,'LineWidth',0.5);
%% exportfig
fid = 'FR-BR-IBFR_TTX-TTXCTZ';
export_fig([savedir fid],'-pdf','-transparent','-r300');