load('CtrlDreaddCumValsNew.mat', 'untrained','pre_norm_last', 'post_norm_last','Ctrl','Exp')


%%
%%                                                 % Mean
%dci  = std(data)*tinv(0.975,size(data,1)-1);                        % Confidence Intervals
xt = [1:5];                                                         % X-Ticks

lb = [xt'-ones(5,1)*0.2,  xt'+ones(5,1)*0.2]; % Long Bar X
figure
plot(xt(1), untrained, 'o', 'color', [0.5 0.5 0.5],'MarkerSize', 10)
hold on
plot(xt(2),Ctrl , 'ko','MarkerSize', 10)
plot(xt(3), Exp, 'ro','MarkerSize', 10)
plot(xt(4), pre_norm_last, 'ro','MarkerSize', 10)
plot(xt(5), post_norm_last, 'ro','MarkerSize', 10)


dmean = [mean(untrained), mean(Ctrl), mean(Exp),  mean(pre_norm_last), mean(post_norm_last)];
%dmedian = [median(untrained), median(Ctrl), median(Exp),  median(expert)];

for k1 = 1:5
    %plot(lb(k1,:), [1 1]*dmedian(k1), '-k')
    plot(lb(k1,:), [1 1]*dmean(k1), '-b')
end
hold off
set(gca, 'XTick', xt, 'XTickLabel', {'Untrained','Ctrl','hM4Di/CNO', 'Expert preCNO','Expert postCNO'})
xlabel('Group')
ylabel('Normalized learning score')

xlim([0.5 5.5])
ylim([-1 1])
set(gca,'YTick', [-1:0.5:1])

%% Statistics
[h, p] = swtest(Ctrl)
[h, p] = swtest(Exp)


% Parametric
group = [ones(20,1); ones(12,1)+1; ones(5,1)+2];
[p,tbl,stats] = anova1([Ctrl; Exp ; untrained],group,'off')

c = multcompare(stats,'CType', 'bonferroni')


[h p] =ttest2(Ctrl, Exp)

%% non-parametric
[p,tbl,stats] = kruskalwallis([Ctrl; Exp ; untrained],group,'off')

c = multcompare(stats,'CType', 'dunn-sidak')


[p h] =ranksum(Ctrl, Exp)

[p h] = ranksum(Ctrl, untrained)
[p h] = ranksum(untrained, Exp)  
[p h] = ranksum(Ctrl, post_norm_last)
