Skip to content

Commit 740e254

Browse files
author
Caspar Addyman
committed
Version 1.1
Added load and save for model parameters and outputs. Updated documentation.
1 parent 883f7c2 commit 740e254

File tree

5 files changed

+74
-35
lines changed

5 files changed

+74
-35
lines changed

GAMIT Matlab Code.docx

35.2 KB
Binary file not shown.

GAMIT_Lifetime.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function ReferenceCurve = GAMIT_Lifetime(params, N, showGraphics)
1+
function ReferenceCurve = GAMIT_Lifetime(params, N, showGraphics, exportRawData)
22
%
33
% generates an average lifetime activation curve. Has default values but
44
% accepts overrides
@@ -12,6 +12,9 @@
1212
if nargin < 3
1313
showGraphics = false;
1414
end
15+
if nargin < 4
16+
exportRawData = true;
17+
end
1518
%initialise storage
1619
gamitScore =zeros(N,params.nIterations);
1720
scoreDelta =zeros(N,params.nIterations);
@@ -74,6 +77,14 @@
7477
ReferenceCurve.GamitScoreUncertainty = std(gamitScore, 1);
7578
ReferenceCurve.Delta = mean(scoreDelta,1);
7679

80+
if exportRawData
81+
Score = ReferenceCurve.GamitScore';
82+
ScoreUncertainty = ReferenceCurve.GamitScoreUncertainty';
83+
Delta = ReferenceCurve.Delta';
84+
t = table(Score,ScoreUncertainty,Delta);
85+
writetable(t,'GAMIT_Lifetime.csv','Delimiter',',');
86+
save('GAMIT_Lifetime_Params.mat','params');
87+
end
7788

7889

7990
if showGraphics

GAMIT_Params.m

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
1-
function params = GAMIT_Params()
1+
function params = GAMIT_Params(matfile)
22
%
33
% helper function to return standard GAMIT spreading activation parameters
4+
% if matfile parameter is passed we load params from corresponding .mat
5+
% file
46

5-
%curve evolution parameters
6-
params.initialActivation = 1;
7-
params.nColumns = 200;
8-
params.nIterations = 2000; % number of timesteps we evolve curve for
7+
if nargin == 1
8+
temp = load(matfile);
9+
params = temp.params;
10+
else
11+
%curve evolution parameters
12+
params.initialActivation = 1;
13+
params.nColumns = 200;
14+
params.nIterations = 2000; % number of timesteps we evolve curve for
915

10-
params.alpha = 0.7; % self activation
11-
params.beta = 0.14952; % spreading activation
12-
params.noiseFactor = 0.000025; % noise
16+
params.alpha = 0.7; % self activation
17+
params.beta = 0.14952; % spreading activation
18+
params.noiseFactor = 0.00025; % noise
1319

14-
params.GaussianFit = false; %is gamit score the stddev of the best fit gaussian
15-
%or is it SummedActivation + MaxActivation?
20+
params.GaussianFit = 0; %is gamit score the stddev of the best fit gaussian
21+
%or is it SummedActivation + MaxActivation?
1622

17-
%curve sampling params
18-
params.bias = 0.87; %single parameter to account for fact that humans always underestimate/overproduce intervals.
19-
params.sampleErrorSize = .02; % margin of error on an sample from curve
20-
params.MemoryUncertainty = false; %is there any additional uncertainty when we read off from the lifetime Curve?
23+
%curve sampling params
24+
params.bias = 0.87; %single parameter to account for fact that humans always underestimate/overproduce intervals.
25+
params.sampleErrorSize = .05; % margin of error on an sample from curve
26+
params.MemoryUncertainty = 0; %is there any additional uncertainty when we read off from the lifetime Curve?
2127

22-
%prospective model parameters
23-
params.WorkingMemoryDelta = false; %Do we just a subset of sampling deltas or all of them?
24-
params.RandomAccessMemory = false; %If WMD=true, is the subset random or just the most recent deltas
25-
params.nSampleDeltas = 6; % how many samples can we keep in memory?
28+
%prospective model parameters
29+
params.WorkingMemoryDelta = 0; %Do we just a subset of sampling deltas or all of them?
30+
params.RandomAccessMemory = 0; %If WMD=true, is the subset random or just the most recent deltas
31+
params.nSampleDeltas = 6; % how many samples can we keep in memory?
2632

27-
params.sampleFrequency = 50; % base rate of one sample every fifty ticks
28-
params.PoissonSampling = true; % are time points samples according to a Poisson process or uniform random variable
33+
params.sampleFrequency = 50; % base rate of one sample every fifty ticks
34+
params.PoissonSampling = 1; % are time points samples according to a Poisson process or uniform random variable
35+
36+
end

GAMIT_Retro_Pro_Interaction.m

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function GAMIT_Retro_Pro_Interaction(targetTime,nSamples,lowCognitiveLoad,highCognitiveLoad,showGraphics)
1+
function GAMIT_Retro_Pro_Interaction(targetTime,nSamples,lowCognitiveLoad,highCognitiveLoad,showGraphics,exportRawData)
22
%
33
% Demonstrate how the retrospective and prospective time estimates are
44
% calculated in the GAMIT model.
@@ -7,22 +7,24 @@ function GAMIT_Retro_Pro_Interaction(targetTime,nSamples,lowCognitiveLoad,highCo
77
targetTime = 600;
88
end
99
if nargin<2
10-
nSamples = 50;
10+
nSamples = 20;
1111
end
1212
if nargin<3
1313
lowCognitiveLoad = 0.95;
14-
highCognitiveLoad = 1.1;
14+
highCognitiveLoad = 1.05;
1515
end
16-
if nargin<4
16+
if nargin<5
1717
showGraphics = true;
1818
end
19-
relativeEstimates = true;
19+
if nargin<6
20+
exportRawData = true;
21+
end
22+
relativeEstimates = true; % divide through by targetTime
2023

2124
%step 1: Get default params & generate a reference curve
2225
params = GAMIT_Params();
2326
lifetimeCurve = GAMIT_Lifetime(params);
2427

25-
2628
testTimes = targetTime * ones(1,nSamples);
2729

2830
%%% RETROSPECTIVE %%%
@@ -33,6 +35,11 @@ function GAMIT_Retro_Pro_Interaction(targetTime,nSamples,lowCognitiveLoad,highCo
3335
prospectiveLow = GAMIT(testTimes,lowCognitiveLoad,true,false,params,lifetimeCurve);
3436
prospectiveHigh = GAMIT(testTimes,highCognitiveLoad,true,false,params,lifetimeCurve);
3537

38+
if exportRawData
39+
t = table(retrospectiveLow,retrospectiveHigh,prospectiveLow,prospectiveHigh);
40+
writetable(t,'GAMIT_Retro_Pro_Interaction.csv','Delimiter',',');
41+
save('GAMIT_Retro_Pro_Params.mat','params');
42+
end
3643

3744
if showGraphics
3845
%Graphics code shows interaction plot like Block, Hancock & Zakay 2010
@@ -43,10 +50,11 @@ function GAMIT_Retro_Pro_Interaction(targetTime,nSamples,lowCognitiveLoad,highCo
4350
%get retrospective 'coordinates'
4451
yR = [mean(retrospectiveLow),mean(retrospectiveHigh)];
4552
yeR = [std(retrospectiveLow),std(retrospectiveHigh)];
53+
yeR = yeR /sqrt(length(retrospectiveLow));
4654
%get retrospective 'coordinates'
4755
yP = [mean(prospectiveLow),mean(prospectiveHigh)];
4856
yeP = [std(prospectiveLow),std(prospectiveHigh)];
49-
57+
yeP = yeP /sqrt(length(prospectiveLow));
5058
if relativeEstimates
5159
yR = yR/targetTime;
5260
yeR = yeR/targetTime;
@@ -56,14 +64,15 @@ function GAMIT_Retro_Pro_Interaction(targetTime,nSamples,lowCognitiveLoad,highCo
5664

5765
hold on;
5866
%plot lines
59-
line(xC, yR,'Color','b');
60-
%offset this xcoord slightly for ease of view
67+
%offset second set of xcoords slightly for ease of view
6168
xCprime = xC+diff(xC)*.02;
62-
line(xCprime, yP, 'Color','r');
63-
legend('Retrospective','Prospective');
69+
% line(xC, yR,'Color','k','LineStyle','--','Marker','o');
70+
% line(xCprime, yP, 'Color','k','Marker','o');
6471
%plot error bars
65-
errorbar(xC,yR,yeR,'Color','b');
66-
errorbar(xCprime,yP,yeP,'Color','r');
72+
errorbar(xC,yR,yeR,'Color','k','LineStyle','--','Marker','o');
73+
errorbar(xCprime,yP,yeP,'Color','k','Marker','o');
74+
legend('Retrospective','Prospective');
75+
6776
hold off;
6877
xlabel('Relative Cognitve Load (Normal load = 1.0)');
6978
if relativeEstimates

GAMIT_Weber_Demo.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function GAMIT_Weber_Demo(targetTime, nSamples, prospectiveFlag,method)
1+
function GAMIT_Weber_Demo(targetTime, nSamples, prospectiveFlag,method,exportRawData)
22
%
33
% Demonstrate that time estimates in the GAMIT model have the scalar
44
% property.
@@ -8,6 +8,7 @@ function GAMIT_Weber_Demo(targetTime, nSamples, prospectiveFlag,method)
88
% prospectiveFlag = 0,false [Retrospective], 1,true [Prospective]
99
% method = 0,'hist' compare targetTime and 1.5*targetTime as histograms
1010
% 1,'bars' compare targetTime & 0.2:0.2:2 * targetTime as estimates & errorbars
11+
% exportRawData = 0,1,true,false, save
1112

1213
if nargin<1
1314
targetTime = 800;
@@ -21,6 +22,9 @@ function GAMIT_Weber_Demo(targetTime, nSamples, prospectiveFlag,method)
2122
if nargin<4
2223
method = 0;
2324
end
25+
if nargin<5
26+
exportRawData = false;
27+
end
2428

2529
if prospectiveFlag
2630
pro_or_ret = 'Prospective';
@@ -65,6 +69,13 @@ function GAMIT_Weber_Demo(targetTime, nSamples, prospectiveFlag,method)
6569
subplot(1,2,2);
6670
bar(x,[n' n2']);
6771
title(['Scaled histograms of estimates - ' pro_or_ret]);
72+
73+
if exportRawData
74+
t = table(retrospectiveLow,retrospectiveHigh,prospectiveLow,prospectiveHigh);
75+
writetable(t,'GAMIT_Weber_Demo.csv','Delimiter',',');
76+
save('GAMIT_Weber_Params.mat','params');
77+
end
78+
6879
else %webers law as error bars.
6980
multipliers = [0.2:0.2:2];
7081
nSteps = length(multipliers);

0 commit comments

Comments
 (0)