forked from jCalderTravis/distractor-stats-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makePlotsForPaper.m
163 lines (112 loc) · 4.94 KB
/
makePlotsForPaper.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function makePlotsForPaper(Dirs, numPtpnts)
% Makes many of the plots in the paper
% INPUT
% Dirs: (structure) contains fields 'Plots', 'Data', 'MainFit', and 'SecondFit'
% describing the directory to save plots in, the full filename of the data, and
% the directories results from the two fitting runs were saved in.
% numPtpnts: Number of participants expected. This value is used as a check.
addpath('./modellingTools')
addpath('./plotFuns')
addpath('./analysisFuns')
Loaded = load(Dirs.Data);
DSet = Loaded.DSet;
if length(DSet.P)~=numPtpnts; error('Unexpected number of participants'); end
%% Patterns in local log-likelihood
plotLocalLogLikeliWithMeas()
mT_exportNicePdf(14/3, 15.9/3, Dirs.Plots, 'patternsInLocalLL')
%% Plot stimulus distributions
plotStimuliDists;
mT_exportNicePdf(15.9/6, 15.9/2, Dirs.Plots, 'stimulusDensities')
plotDencity(DSet)
mT_exportNicePdf(14*(4/3), 15.9, Dirs.Plots, 'statisticDencities')
%% Data only, effect of distractor statistics
plotFig = plotAllSumStatsAllData(DSet);
plotAllSumStatsAllData(DSet, plotFig, 'line');
mT_exportNicePdf(14, 15.9, Dirs.Plots, 'allDataAllStats')
[~, plotFig] = plotEffectOfMeanVarInt(DSet);
plotEffectOfMeanVarInt(DSet, plotFig, 'line');
mT_exportNicePdf(14, (15.9/2.5), Dirs.Plots, 'meanVarInt')
%% Tables of parameter values
% Load and check data
AllDSets = mT_analyseClusterResults(Dirs.MainFit, 1, true, false, true);
close all
assert(length(AllDSets)==1)
DSet = AllDSets{1};
if length(DSet.P)~=numPtpnts; error('Unexpected number of participants'); end
% Check all models in the the same order accross participants
mT_findAppliedModels(DSet)
produceParamTables(DSet, Dirs.Plots)
%% Model fit plots
for modelNum = [1, 3]
Figures = compareDataAndModel(DSet, modelNum);
fileNameLeaf = ['_', ...
DSet.P(1).Models(modelNum).Settings.ModelName.Inference, 'Inference_', ...
DSet.P(1).Models(modelNum).Settings.ModelName.BlockTypes, 'Blocks'];
figure(Figures.AllSumStatsAllData)
mT_exportNicePdf(14, 15.9, Dirs.Plots, ...
['allDataAllStats_withModelFits', fileNameLeaf])
figure(Figures.EffectOfMeanVarInt)
mT_exportNicePdf(14, (15.9/2.5), Dirs.Plots, ...
['meanVarInt_withModelFit', fileNameLeaf])
figure(Figures.DistractorStatsDifferentFormat.Uniform)
mT_exportNicePdf(14*(4/3), 15.9, Dirs.Plots, ...
['setSizesSeperately_uniform', fileNameLeaf])
figure(Figures.DistractorStatsDifferentFormat.Conc)
mT_exportNicePdf(14*(4/3), 15.9, Dirs.Plots, ...
['setSizesSeperately_conc', fileNameLeaf])
figure(Figures.EffectOfSetSize)
mT_exportNicePdf(14, (15.9/2.5), Dirs.Plots, ...
['effectOfSetSize', fileNameLeaf])
end
% Also make a plot of the effect, according to model 2, of distractor variance
% on FA rate at set size 3, in the two different distractor environements
modelNum = 2;
Figures = compareDataAndModel(DSet, modelNum);
figure(Figures.DistractorVarSet3Only)
fileNameLeaf = ['_', ...
DSet.P(1).Models(modelNum).Settings.ModelName.Inference, 'Inference_', ...
DSet.P(1).Models(modelNum).Settings.ModelName.BlockTypes, 'Blocks'];
mT_exportNicePdf(14*(1/3), 15.9*(1/3), Dirs.Plots, ...
['environmentEffect', fileNameLeaf])
%% Model comparison
[aicData, bicData] = mT_collectBicAndAicInfo(DSet);
mT_plotAicAndBic(aicData, bicData, [], 'Real data', false)
mT_exportNicePdf(14, 15.9, Dirs.Plots, 'modelComparison')
% Fit end points
[~, ~, numSuccessFig] = mT_plotFitEndPoints(DSet, false, 1);
figure(numSuccessFig)
mT_exportNicePdf(15.9/2, 15.9/2, Dirs.Plots, 'runFitSucesses_firstFit')
%% Second model fitting round
% Load and check data
AllDSets = mT_analyseClusterResults(Dirs.SecondFit, 1, true, false, true);
close all;
assert(length(AllDSets)==1)
DSet = AllDSets{1};
if length(DSet.P)~=numPtpnts; error('Unexpected number of participants'); end
% Check all models in the the same order accross participants
mT_findAppliedModels(DSet)
% Check the start point setup worked as expected, running from the end point of
% previous runs
nChecks = 20;
numModels = length(DSet.P(1).Models)/2;
ptpnts = randi(length(DSet.P), nChecks, 1);
models = randi(length(numModels), nChecks, 1);
fits = randi(length(DSet.P(1).Models(1).Fits), nChecks, 1);
for iC = 1 : nChecks
if ~isequal(DSet.P(ptpnts(iC)).Models(models(iC)).Fits(fits(iC)).Params, ...
DSet.P(ptpnts(iC)).Models(models(iC)+numModels ...
).Fits(fits(iC)).InitialVals)
error('Bug');
end
end
% Need to remove the models from the first round of fitting
for iP = 1 : length(DSet.P)
DSet.P(iP).Models(1:numModels) = [];
end
[aicData, bicData] = mT_collectBicAndAicInfo(DSet);
mT_plotAicAndBic(aicData, bicData, [], 'Real data', false)
mT_exportNicePdf(14, 15.9, Dirs.Plots, 'modelComparison_secondFittingRun')
% Fit end points
[~, ~, numSuccessFig] = mT_plotFitEndPoints(DSet, false, 1);
figure(numSuccessFig)
mT_exportNicePdf(15.9/2, 15.9/2, Dirs.Plots, 'runFitSucesses_secondFit')