function plotBehaviours(DataB)
%keyboard;
%Simple averages etc

% Agent Ratings
figure('color',[1 1 1],'name','AgentRating by ability (red low, blue high)');hold on;
%set(gca,'Linewidth',5);
for l=1:length(DataB.agent_rating.AbilityspecAgents)
    AverageRatingacrosstime=squeeze(mean(DataB.agent_rating.AbilityspecAgents{l},2));
    errorbar(mean(AverageRatingacrosstime,2),std(AverageRatingacrosstime,0,2)./((size(AverageRatingacrosstime,2)^.5)),'Linewidth',5);
end
set(gca,'fontsize',20);
ylabel('Other Agent Rating')
xlabel('Rating Number')

saveas(gcf,fullfile(DataB.Basepath,'SEAFigures','AgentRating.jpg'))
savefig(gcf,fullfile(DataB.Basepath,'SEAFigures','AgentRating'))

% Binned Plot of Red Choices Self
lowerbound=[-100 -60 -40 -20 0 20 40 60];
higherbound=[-60 -40 -20 0 20 40 60 100];
allbounds=[lowerbound higherbound(end)];
for Isub=1:size(DataB.evidence.Overall,2)
    Binvariable=DataB.evidence.Overall(:,Isub);
    Dependentvariable=~DataB.decision.self.redchoice(:,Isub);
    for b=1:length(lowerbound)
        index=(Binvariable>=lowerbound(b)) & (Binvariable<higherbound(b));
        binnedValues(b)=mean(Dependentvariable(index));
    end
    AllBinnedValues(:,Isub)=binnedValues;
end
figure('color',[1 1 1],'name','Red Choices relevant Evidence');
subplot(1,2,1);hold on
errorbar(mean(AllBinnedValues,2),std(AllBinnedValues,0,2)./((size(AllBinnedValues,2)^.5)),'Linewidth',5);
set(gca,'XTick',0.5:1:length(lowerbound)+.5,'XTicklabel',allbounds)
xlim([0 length(lowerbound)+.5])
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
title('Other Choices')
ylabel('Probability of Red Choice')
xlabel('Overall Evidence')


% Binned Plot of Red Choices Self
lowerbound=[     -40  -20 -10 0 10 20    ];
higherbound=[  -20 -10 0 10 20 40    ];
allbounds=[lowerbound higherbound(end)];
for Isub=1:size(DataB.evidence.Other,2)
    Binvariable=DataB.evidence.Other(:,Isub);
    Dependentvariable=~DataB.decision.other.redchoice(:,Isub);
    for b=1:length(lowerbound)
        index=(Binvariable>=lowerbound(b)) & (Binvariable<higherbound(b));
        binnedValues(b)=mean(Dependentvariable(index));
    end
    AllBinnedValues(:,Isub)=binnedValues;
end
subplot(1,2,2);hold on
errorbar(mean(AllBinnedValues,2),std(AllBinnedValues,0,2)./((size(AllBinnedValues,2)^.5)),'Linewidth',5);
set(gca,'XTick',0.5:1:length(lowerbound)+.5,'XTicklabel',allbounds)
xlim([0 length(lowerbound)+.5])
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
title('Other Choices')
ylabel('Probability of Red Choice')
xlabel('Shared Evidence')

saveas(gcf,fullfile(DataB.Basepath,'SEAFigures','Choices_Softmax.jpg'))
savefig(gcf,fullfile(DataB.Basepath,'SEAFigures','Choices_Softmax'))
% Binned Plot of Accuracy Self
lowerbound=[0 10 20 30 60];
higherbound=[10 20 30 60  100];
allbounds=[lowerbound higherbound(end)];binnedValues=[];AllBinnedValues=[];
for Isub=1:size(DataB.evidence.Overall,2)
    Binvariable=abs(DataB.evidence.Overall(:,Isub));
    Dependentvariable=DataB.decision.self.correct(:,Isub);
    for b=1:length(lowerbound)
        index=(Binvariable>=lowerbound(b)) & (Binvariable<higherbound(b));
        binnedValues(b)=mean(Dependentvariable(index));
    end
    AllBinnedValues(:,Isub)=binnedValues;
end
figure('color',[1 1 1],'name','Accuracy with relevant evidence');
subplot(1,2,1);hold on
set(gca,'Linewidth',5);
errorbar(mean(AllBinnedValues,2),std(AllBinnedValues,0,2)./((size(AllBinnedValues,2)^.5)),'Linewidth',5);
set(gca,'XTick',0.5:1:length(lowerbound)+.5,'XTicklabel',allbounds)
xlim([0 length(lowerbound)+.5])
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
ylabel('Accuracy in Self-Choice')
xlabel('absolute overall Evidence')

title('Self-Choices ')
 

% Binned Plot of Accuracy Other
lowerbound=[0 10 20 30  ];
higherbound=[10 20 30 60   ];
allbounds=[lowerbound higherbound(end)];binnedValues=[];AllBinnedValues=[];
for Isub=1:size(DataB.evidence.Other,2)
    Binvariable=abs(DataB.evidence.Other(:,Isub));
    Dependentvariable=DataB.decision.other.correct(:,Isub);
    for b=1:length(lowerbound)
        index=(Binvariable>=lowerbound(b)) & (Binvariable<higherbound(b));
        binnedValues(b)=mean(Dependentvariable(index));
    end
    AllBinnedValues(:,Isub)=binnedValues;
end
subplot(1,2,2);hold on
set(gca,'Linewidth',5);
errorbar(mean(AllBinnedValues,2),std(AllBinnedValues,0,2)./((size(AllBinnedValues,2)^.5)),'Linewidth',5);
set(gca,'XTick',0.5:1:length(lowerbound)+.5,'XTicklabel',allbounds)
xlim([0 length(lowerbound)+.5])
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
title('Other-Choices')
ylabel('Accuracy in Other-Choice')
xlabel('absolute shared Evidence')

saveas(gcf,fullfile(DataB.Basepath,'SEAFigures','Accuracy_relevantEvidence.jpg'))
savefig(gcf,fullfile(DataB.Basepath,'SEAFigures','Accuracy_relevantEvidence'))
 
FigureTypeErrorbars=figure('color',[1 1 1],'name','Split Plots');hold on

lowerbound1=[ -30  -15 0 15    ];
higherbound1=[ -15 0  15   30 ];
lowerbound2=[ -30   0    ];
higherbound2=[    0    30 ];
allbounds1=[lowerbound1 higherbound1(end)];
allbounds2=[lowerbound2 higherbound2(end)];
binnedValues=[];AllBinnedValues=[];
for Isub=1:size(DataB.evidence.Other,2)
    Binvariable1=(DataB.evidence.Other(:,Isub));
    Binvariable2=(DataB.evidence.Overall(:,Isub)-DataB.evidence.Other(:,Isub));
    Dependentvariable=DataB.decision.self.redchoice(:,Isub);
    for b1=1:length(lowerbound1)
        for b2=1:length(lowerbound2)
            index=(Binvariable1>=lowerbound1(b1)) & (Binvariable1<higherbound1(b1)) & (Binvariable2>=lowerbound2(b2)) & (Binvariable2<higherbound2(b2));
            binnedValues(b1,b2)=mean(Dependentvariable(index));
        end
    end
    AllBinnedValues(:,:,Isub)=binnedValues;
end
 

figure(FigureTypeErrorbars);
subplot(1,2,1);
title('Self Choices');hold on;
%errorbar(mean(AllBinnedValues,3),std(AllBinnedValues,0,3)./(size(AllBinnedValues,3).^.5),'Linewidth',5)
errorbar(mean(AllBinnedValues(:,1,:),3),std(AllBinnedValues(:,1,:),0,3)./(size(AllBinnedValues(:,1,:),3).^.5),'r','Linewidth',5)
errorbar(mean(AllBinnedValues(:,2,:),3),std(AllBinnedValues(:,2,:),0,3)./(size(AllBinnedValues(:,2,:),3).^.5),'b','Linewidth',5)
set(gca,'XTick',.5:length(lowerbound1)+.5,'XTicklabel',allbounds1)
xlim([0 length(lowerbound1)+.5])
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
legend({'OcclEvid Red';'OcclEvid Blue'})
ylabel('Probability of red choice')
xlabel('amount of shared Evidence')

lowerbound1=[ -30  -15 0 15    ];
higherbound1=[ -15 0  15   30 ];
lowerbound2=[ -30   0     ];
higherbound2=[   0    30 ];
allbounds1=[lowerbound1 higherbound1(end)];
allbounds2=[lowerbound2 higherbound2(end)];
binnedValues=[];AllBinnedValues=[];
for Isub=1:size(DataB.evidence.Other,2)
    Binvariable1=(DataB.evidence.Other(:,Isub));
    Binvariable2=(DataB.evidence.Overall(:,Isub)-DataB.evidence.Other(:,Isub));
    Dependentvariable=DataB.decision.other.redchoice(:,Isub);
    for b1=1:length(lowerbound1)
        for b2=1:length(lowerbound2)
            index=(Binvariable1>=lowerbound1(b1)) & (Binvariable1<higherbound1(b1)) & (Binvariable2>=lowerbound2(b2)) & (Binvariable2<higherbound2(b2));
            binnedValues(b1,b2)=mean(Dependentvariable(index));
        end
    end
    AllBinnedValues(:,:,Isub)=binnedValues;
end

 
figure(FigureTypeErrorbars);
subplot(1,2,2);
title('Other Choices');hold on;
%errorbar(mean(AllBinnedValues,3),std(AllBinnedValues,0,3)./(size(AllBinnedValues,3).^.5),'Linewidth',5)
errorbar(mean(AllBinnedValues(:,1,:),3),std(AllBinnedValues(:,1,:),0,3)./(size(AllBinnedValues(:,1,:),3).^.5),'r','Linewidth',5)
errorbar(mean(AllBinnedValues(:,2,:),3),std(AllBinnedValues(:,2,:),0,3)./(size(AllBinnedValues(:,2,:),3).^.5),'b','Linewidth',5)

set(gca,'XTick',.5:length(lowerbound1)+.5,'XTicklabel',allbounds1)
xlim([0 length(lowerbound1)+.5])
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
legend({'OcclEvid Red';'OcclEvid Blue'})
ylabel('Probability of red choice')
xlabel('amount of shared Evidence')

saveas(gcf,fullfile(DataB.Basepath,'SEAFigures','Evidencesplits.jpg'))
savefig(gcf,fullfile(DataB.Basepath,'SEAFigures','Evidencesplits'))

choicedivergance=DataB.decision.other.redchoice~=DataB.decision.self.redchoice;
divprop=sum(choicedivergance,1)./size(choicedivergance,1);
figure('color',[1 1 1],'name','choice divergence proportion');hold on
%title('proportion of trials with choice divergence frequency histogram')
hist(divprop)
set(gca,'XTicklabelrotation',45)
set(gca,'fontsize',20);
xlabel('proportion of Choice Divergence (Self vs Other)')
ylabel('Number of participants')
