-
Notifications
You must be signed in to change notification settings - Fork 3
/
rd_plotTemporalAttentionAdjustCompareFits.m
100 lines (81 loc) · 2.7 KB
/
rd_plotTemporalAttentionAdjustCompareFits.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
% rd_plotTemporalAttentionAdjustCompareFits.m
%% group i/o
subjectIDs = {'bl','rd','id','ec','ld','en','sj','ml','ca','jl','ew','jx'};
% subjectIDs = {'bl'};
run = 9;
nSubjects = numel(subjectIDs);
saveFigs = 0;
groupFigTitle = [sprintf('%s ',subjectIDs{:}) sprintf('(N=%d), run %d', nSubjects, run)];
modelNames = {'fixedNoBias','mixtureNoBias'}; % 'fixedNoBias','mixtureWithBias','mixtureNoBias','swapNoBias', 'swapWithBias', 'variablePrecision', 'variablePrecisionGammaSD'
%% get data
for iSubject = 1:nSubjects
%% indiv i/o
subjectID = subjectIDs{iSubject};
subject = sprintf('%s_a1_tc100_soa1000-1250', subjectID);
expName = 'E3_adjust';
% dataDir = 'data';
% figDir = 'figures';
dataDir = pathToExpt('data');
figDir = pathToExpt('figures');
dataDir = sprintf('%s/%s/%s', dataDir, expName, subject(1:2));
figDir = sprintf('%s/%s/%s', figDir, expName, subject(1:2));
%% load data
dataFile = dir(sprintf('%s/%s_run%02d_%s_vs_%s.mat', dataDir, subject, run, modelNames{1}, modelNames{2}));
load(sprintf('%s/%s', dataDir, dataFile.name))
%% organize data
measures = fields(fit);
nMeasures = numel(measures);
for iM = 1:nMeasures
measure = measures{iM};
groupData.(measure)(iSubject,:) = fit.(measure);
% groupData.(measure) = real(groupData.(measure));
end
end
%% summary stats
for iM = 1:nMeasures
measure = measures{iM};
groupMean(iM,:) = mean(groupData.(measure),1);
groupSte(iM,:) = std(groupData.(measure),0,1)./sqrt(nSubjects);
groupDiff(iM,:) = diff(groupData.(measure),1,2);
end
groupDiffMean = mean(groupDiff,2);
groupDiffStd = std(groupDiff,0,2);
groupDiffSte = std(groupDiff,0,2)./sqrt(nSubjects);
disp([groupDiffMean groupDiffStd])
[h p ci stat] = ttest(groupDiff')
%% non-parametric
fprintf('\nWilcoxon sign-rank test\n')
for iM = 1:nMeasures
measure = measures{iM};
p = signrank(groupDiff(iM,:));
[pp, h, stats] = signrank(groupDiff(iM,:),0,'method','approximate');
fprintf('%s: Z = %1.3f, p = %1.5f\n', measure, stats.zval, p)
end
%% plot
% individuals
for iM = 1:nMeasures
measure = measures{iM};
figure
bar(groupData.(measure))
title(measure)
set(gca,'XTick',1:nSubjects)
set(gca,'XTickLabel',subjectIDs)
legend(modelNames)
end
% group
figure
hold on
barweb(groupMean, groupSte, [], measures)
legend(modelNames)
% individuals - differences between models
figure
for iM = 1:nMeasures
measure = measures{iM};
subplot(nMeasures,1,iM)
bar(groupDiff(iM,:))
title(measure)
set(gca,'XTick',1:nSubjects)
set(gca,'XTickLabel',subjectIDs)
end
rd_supertitle(sprintf('%s vs. %s (+ favors model 1)', modelNames{1}, modelNames{2}))
rd_raiseAxis(gca);