hold off;

filenames = {'nacho364','nacho361'};
minimum_n_minis = 30;

clear subset;
subset.amplitude = amplitude(strmatch('bicuculline',bath));
subset.area = area(strmatch('bicuculline',bath));
subset.bath = bath(strmatch('bicuculline',bath));
subset.culture = culture(strmatch('bicuculline',bath));
subset.decay = decay(strmatch('bicuculline',bath));
subset.div = div(strmatch('bicuculline',bath));
subset.fid = fid(strmatch('bicuculline',bath));
subset.rise = rise(strmatch('bicuculline',bath));
subset.time = time(strmatch('bicuculline',bath));
subset.treatment = treatment(strmatch('bicuculline',bath));

[x1 x2] = getMiniAmpByCell(filenames{1},subset.culture,subset.fid,subset.amplitude);
[y1 y2] = getMiniAmpSample(x1,x2,minimum_n_minis);
z1 = [];
for i = 1:length(y2)
    z1 = [z1; cell2mat(y1(i,1))];
end
%close all;
%figure;
plotAmpCumHist(z1,'r');

[x3 x4] = getMiniAmpByCell(filenames{2},subset.culture,subset.fid,subset.amplitude);
[y3 y4] = getMiniAmpSample(x3,x4,minimum_n_minis);
z2 = [];
for i = 1:length(y4)
    z2 = [z2; cell2mat(y3(i,1))];
end
hold on;
xmin = 0; xmax = max([z1;z2]); xlim([xmin xmax]);
plotAmpCumHist(z2,'k');
title([filenames{1} ' (TTX-treated) and ' filenames{2} ' (control)']);
xlimits = xlim; ylimits = ylim;
text(xlimits(2)*0.99,ylimits(2)*0.01,['n_{' filenames{1} '} = ' num2str(length(y2)),...
    10,'n_{' filenames{2} '} = ' num2str(length(y4))],'HorizontalAlignment','right','VerticalAlignment','bottom');
% print(gcf,'-depsc',char(strcat(filenames{1},'_',filenames{2},'_',num2str(minimum_n_minis),'minis_decay',num2str(thres(1)),'to',num2str(thres(2)),'ms.eps')));
% print(gcf,'-dpng',char(strcat(filenames{1},'_',filenames{2},'_',num2str(minimum_n_minis),'minis_decay',num2str(thres(1)),'to',num2str(thres(2)),'ms.png')));
% hgexport(gcf,char(strcat(filenames{1},'_',filenames{2},'_',num2str(minimum_n_minis),'minis_decay',num2str(thres(1)),'to',num2str(thres(2)),'ms.fig')));
print(gcf,'-depsc',char(strcat(filenames{1},'_',filenames{2},'_',num2str(minimum_n_minis),'minis_AMPAergic.eps')));
print(gcf,'-dpng',char(strcat(filenames{1},'_',filenames{2},'_',num2str(minimum_n_minis),'minis_AMPAergic.png')));
hgexport(gcf,char(strcat(filenames{1},'_',filenames{2},'_',num2str(minimum_n_minis),'_minis_AMPAergic.fig')));

%%
subset.amplitude = amplitude(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.area = area(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.bath = bath(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.culture = culture(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.decay = decay(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.div = div(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.fid = fid(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.rise = rise(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.time = time(strmatch('nacho364',culture) & strmatch('bicuculline',bath));
subset.treatment = treatment(strmatch('nacho364',culture) & strmatch('bicuculline',bath));