-
Notifications
You must be signed in to change notification settings - Fork 4
/
barplots_DIC_stcoh.m
105 lines (85 loc) · 3.1 KB
/
barplots_DIC_stcoh.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
function barplots_DIC_stcoh()
% Code to fit the history-dependent drift diffusion models as described in
% Urai AE, de Gee JW, Tsetsos K, Donner TH (2019) Choice history biases subsequent evidence accumulation. eLife, in press.
%
% MIT License
% Copyright (c) Anne Urai, 2019
addpath(genpath('~/code/Tools'));
warning off; close all;
global datasets datasetnames mypath
types = {'stimcoding'};
for s = 1:length(types),
% ============================================ %
% DIC COMPARISON BETWEEN DC, Z AND BOTH
% ============================================ %
% 1. STIMCODING, only prevresps
mdls = {'z_prevresp_stcoh', 'dc_prevresp_stcoh', ...
'dc_z_prevresp_stcoh', 'nohist_stcoh'};
for d = 1:length(datasets),
close all;
subplot(4, 5, 1);
getPlotDIC(mdls, types{s}, d);
title(datasetnames{d});
set(gca, 'xtick', 1:3, 'xticklabel', {'z', 'v_{bias}', 'both'});
%if ismember(d, [1 4]),
ylabel({'\Delta DIC from model'; 'without history'}, 'interpreter', 'tex');
%else
% ylabel({' '; ' '});
%end
drawnow; tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/figure1b_HDDM_DIC_%s_prevresp_stcoh_d%d.pdf', types{s}, d));
end
end
close all;
end
% ============================================ %
% DIC COMPARISON BETWEEN DC, Z AND BOTH
% ============================================ %
function getPlotDIC(mdls, s, d)
global datasets mypath colors
axis square; hold on;
mdldic = nan(1, length(mdls));
for m = 1:length(mdls),
if ~exist(sprintf('%s/summary/%s/%s_%s_all.mat', ...
mypath, datasets{d}, s, mdls{m}), 'file'),
disp('cant find this model')
continue;
end
load(sprintf('%s/summary/%s/%s_%s_all.mat', ...
mypath, datasets{d}, s, mdls{m}));
if (isnan(dic.full) || isempty(dic.full)) && ~all(isnan(dic.chains)),
dic.full = nanmean(dic.chains);
end
mdldic(m) = dic.full;
end
% everything relative to the full model
mdldic = bsxfun(@minus, mdldic, mdldic(end));
mdldic = mdldic(1:end-1);
[~, bestMdl] = min(mdldic);
for i = 1:length(mdldic),
b = bar(i, mdldic(i), 'facecolor', colors(i, :), 'barwidth', 0.6, 'BaseValue', 0, ...
'edgecolor', 'none');
end
% [ptchs,ptchGrp] = createPatches(i+1,mdldic(end),0.3, colors(2, :), 0, 0.5);
% hatch(ptchs, [0 3 1], colors(1, :));
% ptchs.EdgeColor = [0 0 0];
% fill the last one
%# Add a text string above/below each bin
for i = 1:length(mdldic),
if mdldic(i) < 0,
text(i, mdldic(i) + 0.12*range(get(gca, 'ylim')), ...
num2str(round(mdldic(i))), ...
'VerticalAlignment', 'top', 'FontSize', 4, 'horizontalalignment', 'center', 'color', 'w');
elseif mdldic(i) > 0,
text(i, mdldic(i) + 0.12*range(get(gca, 'ylim')), ...
num2str(round(mdldic(i))), ...
'VerticalAlignment', 'top', 'FontSize', 4, 'horizontalalignment', 'center', 'color', 'w');
end
end
axis square; axis tight;
xlim([0.5 length(mdldic)+0.5]);
offsetAxes; box off;
set(gca, 'color', 'none');
set(gca, 'xcolor', 'k', 'ycolor', 'k');s
end