clearvars -except ctrl* CNQX*

for i = 1:length(ctrl_nacho)
    mu_ctrl(i) = mean(ctrl_nacho{1,i});
    sigma_ctrl(i) = std(ctrl_nacho{1,i});
    n_ctrl(i) = length(ctrl_nacho{1,i});
end
for j = 1:length(CNQX_nacho)
    mu_CNQX(j) = mean(CNQX_nacho{1,j});
    sigma_CNQX(j) = std(CNQX_nacho{1,j});
    n_CNQX(j) = length(CNQX_nacho{1,j});
end

%figure;
hold off;
bar(1:length(mu_ctrl),mu_ctrl,'FaceColor',[.7 .7 .7],'EdgeColor',[0 0 0]); hold on;
bar((1:length(mu_CNQX))+i,mu_CNQX,'FaceColor',[1 0.6 0.6],'EdgeColor','r'); hold on;
errorbar(1:length(mu_ctrl),mu_ctrl,sigma_ctrl,'.k','LineWidth',2);
errorbar((1:length(mu_CNQX))+i,mu_CNQX,sigma_CNQX,'.r','LineWidth',2);
grid on;


xlim([0 j+i+1])
%ylim([0 max([sigma_ctrl+mu_ctrl,sigma_CNQX+mu_CNQX])+5]);
ylim([0 max([mu_ctrl,mu_CNQX])+5]);

%ylim([0 70]);
set(gca,'FontSize',14,'XTick',1:j+i,'YGrid','on')
xlabel('Cell','FontSize',18);
ylabel('mEPSC Amplitude (pA)','FontSize',18);
xlimits = xlim;
ylimits = ylim;


text(xlimits(2)*.01,ylimits(2)*.98,'treatment window: 16-18DIV');
legend('Control','CNQX-treated','Location','NorthEast')

for ni = 1:i
text(ni,ylimits(2)/13,['n = ' num2str(n_ctrl(ni))],'HorizontalAlignment','center','FontSize',6)
text(ni,ylimits(2)/20,['mu = ' num2str(round(100*mu_ctrl(ni))/100) 'pA'],'HorizontalAlignment','center','FontSize',6)
end

for nj = 1:j
text(ni+nj,ylimits(2)/13,['n = ' num2str(n_CNQX(nj))],'HorizontalAlignment','center','FontSize',6,'Color','r')
text(ni+nj,ylimits(2)/20,['mu = ' num2str(round(100*mu_CNQX(nj))/100) 'pA'],'HorizontalAlignment','center','FontSize',6,'Color','r')
end