-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.m
79 lines (61 loc) · 2.12 KB
/
main.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
%counterfactual stimuli experiment.
clear all
version = '2019-02-20';
global log
global params
global global_clock
global w %psychtoolbox window
%% 1. ask for name and block number
prompt = {'Name: ','Block number:'};
dlg_title = 'Filename'; % title of the input dialog box
num_lines = 1; % number of input lines
default = {'42KaFr','0'}; % default filename
savestr = inputdlg(prompt,dlg_title,num_lines,default);
name = savestr{1};
block_number = str2double(savestr{2});
%% 2. set preferences and open screen
%set different random seed for each participant(subject #19 onwards)
if ~isnan(str2double(name(1:3)))
rng(str2double(name(1:3)))
end
%open psychtoolbox
[w,rect] = setWindow(0);%setWindow(1) for debugging mode.
params = loadPars(rect, name, block_number);
%% 3. initialize log
% Initialize log with NaNs where possible.
log.resp = nan(params.Ntrials,2);
log.visibility = nan(params.Ntrials,1);
log.correct = nan(params.Ntrials,1);
log.events = [];
log.confidence = nan(params.Ntrials,1);
log.visibilityByFrame = nan(params.Ntrials,...
round(params.display_duration/params.ifi));
vis_house_log = -1.5;
vis_face_log = -1.5;
correct_house = [];
correct_face = [];
%% 4. run calibration
global_clock = tic();
for num_trial = 1:params.Ntrials
response = trialGradual(num_trial);
confidence = rateConf();
log.resp(num_trial,:) = response;
log.correct(num_trial) = log.resp(num_trial,2)==params.present(num_trial);
log.confidence(num_trial) = confidence;
end
% close
Priority(0);
ShowCursor
Screen('CloseAll');
% Make a gong sound so that I can hear from outside the testing room that
% the behavioural session is over :-)
load gong.mat;
soundsc(y);
log.bonus = ((log.correct(~isnan(log.confidence))-0.5)'...
*log.confidence(~isnan(log.confidence)))/330;
numbers = {'first','second','third','fourth'};
sprintf('the bonus for the %s block is %0.02f',numbers{params.block_number},...
(log.bonus))
%% save
save(fullfile('data',strcat(params.name, '_block',num2str(params.block_number),'.mat')),...
'log','params');