clear;
load miniDB;
amplitude = amplitude(decay<=6);
fid = fid(decay<=6);
culture = culture(decay<=6);

%% mini amplitudes TTX donkeylips
figure
ind_d363 = strfind(culture,'donkeylips363');
for i = 1:length(ind_d363)
    if isempty(ind_d363{i})
        ind_d363{i} = [0];
    end
end
ind_d363 = logical(cell2mat(ind_d363));

ind_d360 = strfind(culture,'donkeylips360');
for i = 1:length(ind_d360)
    if isempty(ind_d360{i})
        ind_d360{i} = [0];
    end
end
ind_d360 = logical(cell2mat(ind_d360));

ctrl.amp = amplitude(ind_d360);
ctrl.fid = fid(ind_d360);

fid_tmp = unique(ctrl.fid);
for j = 1:length(fid_tmp)
    ind = strfind(fid_tmp{j},'_');
    if numel(ind)>=2
        fidlist{j} = fid_tmp{j}(1:ind(2)-1);
    else
        fidlist{j} = fid_tmp{j}
    end
end
fidlist = unique(fidlist);
hold off;
for k = 1:length(fidlist);
    amp_tmp = ctrl.amp(strmatch(fidlist{k},ctrl.fid));
    plot(ones(size(amp_tmp))*k*0.01+0.001*randn(size(amp_tmp)),amp_tmp,'k.');
    hold on;
end
keyboard;



TTX.amp = amplitude(ind_d363);
TTX.fid = fid(ind_d363);

clear fid*
fid_tmp = unique(TTX.fid);
for j = 1:length(fid_tmp)
    ind = strfind(fid_tmp{j},'_');
    if numel(ind)>=2
        fidlist{j} = fid_tmp{j}(1:ind(2)-1);
    else
        fidlist{j} = fid_tmp{j};
    end
end
fidlist = unique(fidlist);

for k = 1:length(fidlist);
    amp_tmp = TTX.amp(strmatch(fidlist{k},TTX.fid));
    plot(0.08+ones(size(amp_tmp))*k*0.01+0.001*randn(size(amp_tmp)),amp_tmp,'.','Color',[0.8 0.2 0.7]);
    hold on;
end

ylim([0 150]);
set(gca,'XTick',[]);
set(gca,'YTick',0:25:150);

%% mini amplitude CNQX buster
figure;
ind_buster359 = strfind(culture,'buster359');
for i = 1:length(ind_buster359)
    if isempty(ind_buster359{i})
        ind_buster359{i} = [0];
    end
end
ind_buster359 = logical(cell2mat(ind_buster359));

ind_buster364 = strfind(culture,'buster364');
for i = 1:length(ind_buster364)
    if isempty(ind_buster364{i})
        ind_buster364{i} = [0];
    end
end
ind_buster364 = logical(cell2mat(ind_buster364));

ctrl.amp = amplitude(ind_buster364);
ctrl.fid = fid(ind_buster364);

fid_tmp = unique(ctrl.fid);
for j = 1:length(fid_tmp)
    ind = strfind(fid_tmp{j},'_');
    if numel(ind)>=2
        fidlist{j} = fid_tmp{j}(1:ind(2)-1);
    else
        fidlist{j} = fid_tmp{j}
    end
end
fidlist = unique(fidlist);
hold off;
for k = 1:length(fidlist);
    amp_tmp = ctrl.amp(strmatch(fidlist{k},ctrl.fid));
    plot(ones(size(amp_tmp))*k*0.01+0.001*randn(size(amp_tmp)),amp_tmp,'k.');
    hold on;
end
keyboard;

CNQX.amp = amplitude(ind_buster359);
CNQX.fid = fid(ind_buster359);

clear fid*
fid_tmp = unique(CNQX.fid);
for j = 1:length(fid_tmp)
    ind = strfind(fid_tmp{j},'_');
    if numel(ind)>=2
        fidlist{j} = fid_tmp{j}(1:ind(2)-1);
    else
        fidlist{j} = fid_tmp{j};
    end
end
fidlist = unique(fidlist);

for k = 1:length(fidlist);
    amp_tmp = CNQX.amp(strmatch(fidlist{k},CNQX.fid));
    plot(0.06+ones(size(amp_tmp))*k*0.01+0.001*randn(size(amp_tmp)),amp_tmp,'.','Color',[0.8 0.2 0.7]);
    hold on;
end

ylim([0 140]);
set(gca,'XTick',[]);
set(gca,'YTick',0:25:150);


%%
subplot(2,1,1)
hold off;
bar(bins+0.25,prebic.hist);
xlim([0 25]);
subplot(2,1,2)
hold off;
bar(bins+0.25,buster359.hist);
xlim([0 25]);