% Example MATLAB script exemplarily read experimental data gathered for 
% Ambisonics Book, Franz Zotter, 2018
close all
clear all
if 0
fname='wendtMA2013.txt';
cnames={'FL-FR','FLD-FRU','FD-FU','FLd-FRd-FU','FLd-FLu-FR','FLu-FRu-FD','FL-FR-FD-FU','FLD-FLU-FRD-FRU'};
phi=linspace(0,2*pi);
for cn=1:length(cnames)
    cname=cnames{cn};
    [data,data_labels,headers]=read_experimental_data(fname,2,3,{{},{},{cname}});
    %%
    figure
    plot(cos(phi(:))*[20 10],sin(phi(:))*[20 10],'k:')
    hold on
    plot([-1 1 NaN 0 0 NaN -.7 .7 NaN -.7 .7]*20,...
         [0 0 NaN -1 1 NaN -.7 .7 NaN .7 -.7]*20,'k:')
    switch cname
        case 'FL-FR'
            plot([-1 1]*20,[0 0],'k--')
        case 'FLD-FRU'
            plot([-.7 .7]*20,[-.7 .7]*20,'k--')
        case 'FD-FU'
            plot([0 0]*20,[-1 1]*20,'k--')
        case 'FLd-FRd-FU'
            plot([-.87 .87 0 -.87]*20,[-.5 -.5 1 -.5]*20,'k--')
        case 'FLu-FRu-FD'
            plot([-.87 .87 0 -.87]*20,[.5 .5 -1 .5]*20,'k--')
        case 'FLd-FLu-FR'
            plot([-.5 -.5 1 -.5]*20,[-.87 .87 0 -.87]*20,'k--')
        case 'FL-FR-FD-FU'
            plot([-1 0 1 0 -1]*20,[0 1 0 -1 0]*20,'k--')
        case 'FLD-FLU-FRD-FRU'
            plot([-.7 -.7 .7 .7 -.7]*20,[-.7 .7 .7 -.7 -.7]*20,'k--')
    end
    for k=1:size(data,4)
        X=-squeeze(data(:,1,:,k));
        Y=squeeze(data(:,2,:,k));
        [xm,xs,xc,R,kept] = robust_multivariate_confidence_region([X(:) Y(:)]',.05,3);
        xyc = [cos(phi(:))*xs(1), sin(phi(:))*xs(2)]*R' + repmat(xm,length(phi),1);
        plot(xyc(:,1),xyc(:,2),'b:','linewidth',1),
        xyc = [cos(phi(:))*xc(1), sin(phi(:))*xc(2)]*R' + repmat(xm,length(phi),1);
        plot(xyc(:,1),xyc(:,2),'b','linewidth',1),
    end
    axis equal
    set(gca,'Visible','off')
    set(gcf,'Name',cname)
end
end
%%
fname='zotterfrank60TMT2015.txt';
figure
[data,data_labels,headers]=read_experimental_data(fname,1,3,{{'-15','0','15'},{'0'},{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data=data(:,:)';
[Median, LowNotch, HiNotch] = CI2p(data);
errorbar(Median,[-15 0 15],LowNotch-Median,HiNotch-Median,'horizontal')
set(gca,'YDir','reverse')
grid on
title('zotterTMT2015')
xlim([-8 8])
ylim([-30 30])
%%
figure
fname='frankDAGA2017.txt';
[data,data_labels,headers]=read_experimental_data(fname,1,2,{{},{'75','90','105'}});
data=squeeze(data);
data=permute(data,[3 1 2]);
data=data(:,:)';
[Median, LowNotch, HiNotch] = CI2p(data);
errorbar(Median,90+[-15 0 15],LowNotch-Median,HiNotch-Median,'horizontal')
title('frankDAGA2017')
ylim([-30 30]+90)
xlim([-8 8])
grid on
%%
fname='helmkurzTMT2016.txt';
cnames={'125Hz','250Hz','500Hz','1kHz','2kHz','4kHz','8kHz','broadb.','lp1k','hp1k'};
figure
x=[0 3 6 9 12];
for cn=1:length(cnames)
    cname=cnames{cn};
    [data,data_labels,headers]=read_experimental_data(fname,1,3,{{'0','3','6','9','12'},{cname},{}});
    data=squeeze(data);
    data=permute(data,[2 1 3]);
    data=data(:,:)';
    [Median, LowNotch, HiNotch] = CI2p(data);
    errorbar(x+cn/20,Median,LowNotch-Median,HiNotch-Median)
    hold on
end
legend(cnames,'location','nw')
set(gca,'XTick',x)
grid on
ylim([-2 35])
title('Helm Kurz 2016')
%%
fname='frankPhD2013width123.txt';
cnames={'C','10','20','30','40','50','60','70','80',...
       'C','C10','C20','C30','C40','C50','C60','C70','C80'};
vpn={'1','2','3','4','5','6','7','8','9','10','11','12','13','14'};
figure
[data,data_labels,headers]=read_experimental_data(fname,1,2,{cnames,vpn});
data=squeeze(data);
data=permute(data,[2 1 3]);
data=data(:,:)';
[Median, LowNotch, HiNotch] = CIMEAN(data);
Median=reshape(Median,[9 2]);

LowNotch=reshape(LowNotch,[9 2]);
HiNotch=reshape(HiNotch,[9 2]);
idx=0:8;
errorbar(idx,Median(:,1),LowNotch(:,1)-Median(:,1),HiNotch(:,1)-Median(:,1),'k--')
hold on
errorbar(idx+.1,Median(:,2),LowNotch(:,2)-Median(:,2),HiNotch(:,2)-Median(:,2),'--','Color',[1 1 1]*.5)
ylim([0 60])
xlim([0 9])
grid on
title('Frank width')
%%
fname='frankDAGA2017complete.txt';

% 60deg, ls1 at 0
figure
method={'VBAP'};
pan={'0','15','30','45','60','75','90','105','120','135','150','165','180',...
    '345','330','315','300','255','285','270','240','225','210','195'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'60'},{'0'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
plot([0 0 60 60 120 120 180],...
    [0 60 60 120 120 180 180],'k:')
hold on
plot([0 60 60 120 120 180 180],...
    [0 0 60 60 120 120 180],'k:')
plot([0 180],[0 180],'k--')
[Median, LowNotch, HiNotch] = CI2p(data);
v=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'g');

method={'MDAP'};
pan={'0','15','30','45','60','75','90','105','120','135','150','165','180',...
    '345','330','315','300','255','285','270','240','225','210','195'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'60'},{'0'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
plot([0 0 60 60 120 120 180],...
    [0 60 60 120 120 180 180],'k:')
hold on
plot([0 60 60 120 120 180 180],...
    [0 0 60 60 120 120 180],'k:')
plot([0 180],[0 180],'k--')
[Median, LowNotch, HiNotch] = CI2p(data);
m=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'b');


method={'Ambi'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'60'},{'0'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
[Median, LowNotch, HiNotch] = CI2p(data);
a=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'r');

ylim([-5 185])
xlim([-5 185])
grid on
legend([v,m,a],'VBAP','MDAP','Ambi','location','nw')
title('Frank DAGA 2017 - 60Â° spacing staring at 0Â°')


% 60deg, ls1 at 30
figure
method={'VBAP'};
pan={'0','15','30','45','60','75','90','105','120','135','150','165','180',...
    '345','330','315','300','255','285','270','240','225','210','195'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'60'},{'30'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
plot([0 30 30 90 90 150 150],...
    [30 30 90 90 150 150 180],'k:')
hold on
plot([30 30 90 90 150 150 180],...
    [0 30 30 90 90 150 150],'k:')
plot([0 180],[0 180],'k--')
[Median, LowNotch, HiNotch] = CI2p(data);
v=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'g');

method={'MDAP'};
pan={'0','15','30','45','60','75','90','105','120','135','150','165','180',...
    '345','330','315','300','255','285','270','240','225','210','195'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'60'},{'30'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
plot([0 30 30 90 90 150 150],...
    [30 30 90 90 150 150 180],'k:')
hold on
plot([30 30 90 90 150 150 180],...
    [0 30 30 90 90 150 150],'k:')
plot([0 180],[0 180],'k--')
[Median, LowNotch, HiNotch] = CI2p(data);
m=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'b');

method={'Ambi'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'60'},{'30'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
[Median, LowNotch, HiNotch] = CI2p(data);
a=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'r');

ylim([-5 185])
xlim([-5 185])
grid on
legend([v,m,a],'VBAP','MDAP','Ambi','location','nw')
title('Frank DAGA 2017 - 60Â° spacing staring at 30Â°')


% 45deg, ls1 at 0
figure
method={'VBAP'};
pan={'0','15','30','45','60','75','90','105','120','135','150','165','180',...
    '345','330','315','300','255','285','270','240','225','210','195'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'45'},{'0'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
plot([0 0 45 45 90 90 135 135 180],...
    [0 45 45 90 90 135 135 180 180],'k:')
hold on
plot([0 45 45 90 90 135 135 180 180],...
    [0 0 45 45 90 90 135 135 180],'k:')
plot([0 180],[0 180],'k--')
[Median, LowNotch, HiNotch] = CI2p(data);
v=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'g');

method={'MDAP'};
pan={'0','15','30','45','60','75','90','105','120','135','150','165','180',...
    '345','330','315','300','255','285','270','240','225','210','195'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'45'},{'0'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
plot([0 0 45 45 90 90 135 135 180],...
    [0 45 45 90 90 135 135 180 180],'k:')
hold on
plot([0 45 45 90 90 135 135 180 180],...
    [0 0 45 45 90 90 135 135 180],'k:')
plot([0 180],[0 180],'k--')
[Median, LowNotch, HiNotch] = CI2p(data);
m=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'b');

method={'Ambi'};
[data,data_labels,headers]=read_experimental_data(fname,1,5,...
    {pan,{'45'},{'0'},method,{}});
data=squeeze(data);
data=permute(data,[2 1 3]);
data(2:12,3:4,:)=360-data(14:24,1:2,:);
data=data(1:13,:,:);
data=data(:,:)';
data=mod(data+90,360)-90;
[Median, LowNotch, HiNotch] = CI2p(data);
a=errorbar(0:15:180,Median,LowNotch-Median,HiNotch-Median,'r');

ylim([-5 185])
xlim([-5 185])
grid on
legend([v,m,a],'VBAP','MDAP','Ambi','location','nw')
title('Frank DAGA 2017 - 45Â° spacing staring at 0Â°')

%%
fname='frankPhD2013lococ.txt';
method={'VBAP','MDAP','max-r_E','basic'};
pan={'-0.000','-5.625','-11.250','-16.875','-22.500','-28.125','-33.750','-39.375','-45.000'};
ang=-(0:45/8:45);
for m = 1:4
    figure
    p2 = plot([-45 0],[-45 0],'k:','Linewidth',1.5);
    hold on
    grid on
    set(gca,'xdir','reverse')
    set(gca,'ydir','reverse')
    set(gca,'XTick',-45:5:90,'YTick',-45:5:0)
    ylabel('left          panning angle in Â°          right')
    switch method{m}
        case {'VBAP','MDAP'}
            axis([-49 34 -49 4])
            xlabel('left                             perceived angle in Â°                                right')
            set(gcf,'Units','pixels','Position',[100 100 350*1.6 350],'PaperPositionMode','auto');
        case {'basic','max-r_E'}
            axis([-49 94 -49 4])
            xlabel('left                                                                             perceived angle in Â°                                                                       right')
            set(gcf,'Units','pixels','Position',[100 100 350*2.75 350],'PaperPositionMode','auto');
    end
    % off-center listening position
    [data,data_labels,headers]=read_experimental_data(fname,1,4,{pan,{'1.25'},method(m),{}});
    data = squeeze(data);
    data = permute(data,[2 1 3]);
    data = data(:,:);
    bubbleplot(data,5,ang);

    % center listening position
    [data,data_labels,headers]=read_experimental_data(fname,1,4,{pan,{'0.00'},method(m),{}});
    data = squeeze(data);
    data = permute(data,[2 1 3]);
    data = data(:,:)';
    [Median, LowNotch, HiNotch] = CI2(data);
    errorbar(Median,ang,LowNotch-Median, HiNotch-Median,'horizontal','ko','Linewidth',1.5,'markerfacecolor','w')
    title(['Frank Phd 2013 center/offcenter: ' method{m}])
end

%% Zaunschirm+Schoerkhuber DAGA 2018 high-frequency-modified ITD experiment

cos={'orig','0',' 500','1k','1.5k','2k','3k','4k','5k','7k'};
% ros={'dry','room'};
% sgs={'speech','speech',' drums','drums',' pink'};
% drs={'10','-45','80', '-130'};
styles = {'o','o','d','s','x'};

fname='zaunschirmDAGA2018.txt';
[data,data_labels,headers]=read_experimental_data(fname,1,5,{cos,{},{},{},{},{}});
data=squeeze(data);
for m = 1:4
    [Median, LowNotch, HiNotch] = CI2(squeeze(data(:,m,:))');
    Median_MTXDiffDrums(m,:) = Median;
    errorbar(0.5+((m)*0.2):1:9.5+((m)*0.2),Median, LowNotch-Median, HiNotch-Median,styles{m},'Linewidth',1.5,'color',...
        [1 1 1]*((m)/11-1/11)^(1/3),'markerfacecolor','w','markersize',6);
    hold on
end

for m = 1:4
    [Median, LowNotch, HiNotch] = CI2(squeeze(data(:,m,:))');
    Median_MTXDiffDrums(m,:) = Median;
    plot(0.5+((m)*0.2):1:9.5+((m)*0.2),Median, styles{m},'Linewidth',1.5,'color',...
        [1 1 1]*((m)/11-1/11)^(1/3),'markerfacecolor','w','markersize',6);
end

ylim([-0.05 1.05]);
y_label = {'no difference','severe difference'};
text(0.2,-0.05,'no difference','rotation',90,'fontsize',9,'horizontalalignment','left');
text(0.2,1.05,'severe difference','rotation',90,'fontsize',9,'horizontalalignment','right')
% set(gca,'ytick',0:1,'yticklabel',y_label,'xtick',0.9:1:9.9,'xticklabel',xtick_name)
set(gca,'ytick',0:1,'yticklabel',[],'xtick',1:1:10,'xticklabel',cos)

ytickangle(90)
xlim([0.5 10.5])
grid off
for m=1:9
    plot([(m)+0.5 (m)+0.5],[-0.05 1.05],'color',[1 1 1]*0.7,'linestyle','--');
end
legend('10Â°','-45Â°','80Â°','-130Â°','location','ne');

set(gcf,'PaperUnits','centimeters','PaperPosition',[0 0 14 7]);

%% Zaunschirm+Zotter+Frank MDPI 2020 Binaural Rendering with Measured Room Responses:
% First-order Ambisonic Microphone vs. Dummy Head 

%% MOBRIR static 
fname = 'zaunschirm2020MDPI_MOBRIR_Static.txt';
cos = {'ref','8°/4k','15°/2k','30°/2k','60°/1k','8°lin','15°lin','30°lin','60°lin'};
directions={'12','21','37','78'};
attribute={'coloration/pink','sp.mapping/music'};

[data,data_labels,headers]=read_experimental_data(fname,1,4,{cos,directions,attribute,{}});
data=squeeze(data);
choice = permute(data,[1 4 2 3]);

CC = [1 1 1];
fonts = 10;
cond={'ref','8°/4k','15°/2k','30°/2k','60°/1k','8°lin','15°lin','30°lin','60°lin'};
styles = {'o','d','s','x'};
% plot for all pooled directions
figure
pp1=[];
pp2=[];
for ori=1:2
    choiceTemp = squeeze(choice(:,:,:,ori));
    [mi,lo,hi]=CI2(choiceTemp(:,:)');
    p=errorbar((1:9)+(ori-1.25)/3,mi,lo-mi,hi-mi,'color',CC*((ori-1)*.7),'linestyle',':','Marker',styles{ori},'MarkerFaceColor',[1 1 1],'LineWidth',2);
    pp1=[pp1 p];
    hold all
    axis([.5 9.5 -.05 1.05])
    set(gca,'XTick',1:10,'XTickLabel',cond)
    grid on        
end
legend(pp1,{'timbre','spatial mapping'},'location','best','fontsize',fonts);

set(gca,'ylim',[-0.05 1.05],'ytick',0:1,'yticklabel',[],'fontsize',fonts)
% y_label = {'very good','poor'};
text(0.2,0,'poor','rotation',90,'fontsize',fonts,'HorizontalAlignment','left');
text(0.2,1,'very good','rotation',90,'fontsize',fonts,'HorizontalAlignment','right')
grid off
set(gcf,'Units','pixels','Position',[100 100 600 400],'PaperPositionMode','auto');
box on;
for m=1:9
    plot([m+0.5 m+0.5],[-0.05 1.05],'color',[1 1 1]*0.7,'linestyle','--');
end

%% MOBRIR dynamic
fname = 'zaunschirm2020MDPI_MOBRIR_Dynamic.txt';
cos = {'ref','8°/4k','15°/2k','30°/2k','60°/1k','8°lin','15°lin','30°lin','60°lin'};
directions={'0°/pink','0°/music','90°/pink','90°/music'};

[data,data_labels,headers]=read_experimental_data(fname,1,3,{cos,directions,{}});
data=squeeze(data);
choice1 = permute(data,[2 1 3]);

CC = [1 1 1];
fonts = 10;
cond={'ref','8°/4k','15°/2k','30°/2k','60°/1k','8°lin','15°lin','30°lin','60°lin'};
styles = {'o','d','s','x'};


pp1=[];
for ori=1:2
    choiceTemp = choice1([1 3]+(ori-1),:,:);
    choiceTemp = permute(choiceTemp,[2 3 1]);
    figure(4)
    [mi,lo,hi]=CI2(choiceTemp(:,:)');
    p=errorbar((1:9)+(ori-1.25)/3,mi,lo-mi,hi-mi,'color',CC*(((ori-1))*.7),'linestyle',':','Marker',styles{ori},'MarkerFaceColor',[1 1 1],'LineWidth',2);
    pp1=[pp1 p];
    hold all
    axis([.5 9.5 -.05 1.05])
    set(gca,'XTick',1:9,'XTickLabel',cond)
    grid on    
    legend(pp1,{'pink','music'},'location','sw','fontsize',fonts);
    set(gca,'ylim',[-0.05 1.05],'ytick',0:1,'yticklabel',[],'fontsize',fonts)
    text(0.2,0,'poor','rotation',90,'fontsize',fonts,'HorizontalAlignment','left');
    text(0.2,1,'very good','rotation',90,'fontsize',fonts,'HorizontalAlignment','right')
    grid off
    set(gcf,'Units','pixels','Position',[100 100 600 400],'PaperPositionMode','auto');
    box on;
    for m=1:9
        plot([m+0.5 m+0.5],[-0.05 1.05],'color',[1 1 1]*0.7,'linestyle','--');
    end
end

%% MOBRIRvsARIR static
fname = 'zaunschirm2020MDPI_MOBRIRvsARIR_Static.txt';
cos = {'ref','30°lin','45°lin','60°lin','30°/2k','45°/1.5k','60°/1k', '5th','3rd','1st'};
directions={'loudsp./front','loudsp./side'};
attribute={'coloration/pink','sp.mapping/music'};

[data,data_labels,headers]=read_experimental_data(fname,1,4,{cos,directions,attribute,{}});
data=squeeze(data); % condi x orientation x col/spat x vpn
choice = permute(data,[1 4 2 3]);
CC = [1 1 1];
fonts = 10;
cos={'ref','8°/4k','15°/2k','30°/2k','60°/1k','8°lin','15°lin','30°lin','60°lin'};
styles = {'o','d','s','x'};

pp1=[];
pp2=[];
figure()
for ori=1:2   
    choiceTemp = squeeze(choice(:,:,:,ori));
    [mi,lo,hi]=CI2(choiceTemp(:,:)');
    p=errorbar((1:10)+(ori-1.25)/3,mi,lo-mi,hi-mi,'color',CC*((ori-1)*.7),'linestyle',':','Marker',styles{ori},'MarkerFaceColor',[1 1 1],'LineWidth',2);
    pp1=[pp1 p];
    hold all
    axis([.5 10.5 -.05 1.05])
    set(gca,'XTick',1:10,'XTickLabel',cos)
    grid on         
end
legend(pp1,{'timbre','spatial mapping'},'location','best','fontsize',fonts);

set(gca,'ylim',[-0.05 1.05],'ytick',0:1,'yticklabel',[],'fontsize',fonts)
% y_label = {'very good','poor'};
text(0.2,0,'poor','rotation',90,'fontsize',fonts,'HorizontalAlignment','left');
text(0.2,1,'very good','rotation',90,'fontsize',fonts,'HorizontalAlignment','right')
grid off
set(gcf,'Units','pixels','Position',[100 100 600 400],'PaperPositionMode','auto');
box on;
for m=1:9
    plot([m+0.5 m+0.5],[-0.05 1.05],'color',[1 1 1]*0.7,'linestyle','--');
end

%% MOBRIRvsARIR dynamic
fname = 'zaunschirm2020MDPI_MOBRIRvsARIR_Dynamic.txt';
cos = {'ref','30°lin','45°lin','60°lin','30°/2k','45°/1.5k','60°/1k', '5th','3rd','1st'};
directions={'0°/pink','0°/music','90°/pink','90°/music'};

[data,data_labels,headers]=read_experimental_data(fname,1,3,{cos,directions,{}});
data=squeeze(data);
choice1 = permute(data,[2 1 3]);
CC = [1 1 1];
fonts = 10;
cos={'ref','8°/4k','15°/2k','30°/2k','60°/1k','8°lin','15°lin','30°lin','60°lin'};
styles = {'o','d','s','x'};

pp1=[];
for ori=1:2
    choiceTemp = choice1([1 3]+(ori-1),:,:);
    choiceTemp = permute(choiceTemp,[2 3 1]);
    figure(4)
    [mi,lo,hi]=CI2(choiceTemp(:,:)');
    p = errorbar((1:10)+(ori-1.25)/3,mi,lo-mi,hi-mi,'color',CC*(((ori-1))*.7),'linestyle',':','Marker',styles{ori},'MarkerFaceColor',[1 1 1],'LineWidth',2);
    pp1=[pp1 p];
    hold all
    axis([.5 9.5 -.05 1.05])
    set(gca,'XTick',1:10,'XTickLabel',cos)
    grid on    
    legend(pp1,{'pink','music'},'location','sw','fontsize',fonts);
    set(gca,'ylim',[-0.05 1.05],'ytick',0:1,'yticklabel',[],'fontsize',fonts)
    text(0.2,0,'poor','rotation',90,'fontsize',fonts,'HorizontalAlignment','left');
    text(0.2,1,'very good','rotation',90,'fontsize',fonts,'HorizontalAlignment','right')
    grid off
    set(gcf,'Units','pixels','Position',[100 100 600 400],'PaperPositionMode','auto');
    box on;
    for m=1:10
        plot([m+0.5 m+0.5],[-0.05 1.05],'color',[1 1 1]*0.7,'linestyle','--');
    end
end
