-
Notifications
You must be signed in to change notification settings - Fork 4
/
correlate_z_vbias.m
83 lines (63 loc) · 2.76 KB
/
correlate_z_vbias.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
function correlate_z_vbias
% 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
close all; clc;
addpath(genpath('~/code/Tools'));
global mypath datasets datasetnames colors
% ============================================ %
% ONE LARGE PLOT WITH PANEL FOR EACH DATASET
% ============================================ %
for d = length(datasets):-1:1
results = readtable(sprintf('%s/summary/%s/allindividualresults.csv', mypath, datasets{d}));
results = results(results.session == 0, :);
whichmdls = 'stimcoding';
try
% use the stimcoding difference
results.z_prevresp = ...
results.(['z_1__' whichmdls 'dczprevresp']) - results.(['z_2__' whichmdls 'dczprevresp']);
results.v_prevresp = ...
results.(['dc_1__' whichmdls 'dczprevresp']) - results.(['dc_2__' whichmdls 'dczprevresp']);
catch
results.z_prevresp = ...
results.(['z_1_0__' whichmdls 'dczprevresp']) - results.(['z_2_0__' whichmdls 'dczprevresp']);
results.v_prevresp = ...
results.(['dc_1_0__' whichmdls 'dczprevresp']) - results.(['dc_2_0__' whichmdls 'dczprevresp']);
end
close all;
subplot(441); hold on;
% COMPUTE THE CORRELATION COEFFICIENT
[rho, pval] = corr( results.v_prevresp, results.z_prevresp, ...
'type', 'spearman', 'rows', 'complete');
if pval < 0.05,
% 18 SEPTEMBER 2018 - SWITCH TO PCA CORRELATION https://elifesciences.org/articles/00638
b = deming(results.v_prevresp, results.z_prevresp);
xrangeextra = 0.15*range(results.v_prevresp);
xrange = linspace(min(results.v_prevresp)- xrangeextra, ...
max(results.v_prevresp)+xrangeextra, 100);
yrange = polyval(fliplr(b'), xrange);
% NOW PLOT
l = plot(xrange, yrange);
l.Color = 'k';
l.LineWidth = 0.5;
l.LineStyle = '-';
end
allresults.rho(d) = rho;
allresults.pval(d) = pval;
allresults.bf(d) = corrbf(rho, numel(results.z_prevresp));
% PLOT ALL DATAPOINTS IN SPECIFIC COLOR
s = scatter(results.v_prevresp, results.z_prevresp, 7, [0.5 0.5 0.5], 'o');
ylabel('History shift in z', 'color', colors(1, :));
xlabel('History shift in v_{bias}', 'color', colors(2, :));
axis tight; offsetAxes;
fprintf('%s, rho = %.3f, pval = %.3f \n', datasets{d}, rho, pval);
title(datasetnames{d});
tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/zbias_vs_vbias_d%d.pdf', d));
end
allresults
bf = prod([allresults(:).bf])
end