-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExperiment.m
106 lines (73 loc) · 2.66 KB
/
Experiment.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
function Experiment(ppnr, trial, initials)
% Eperiment part 2 UG receivers for MRI
%
% Inge Huijsmans
% 2017/11/07
if IsWin
wd = '';
else
wd = '/home_local/meduser/Desktop/experiment_MRI/';
end
%Setup wd
SCANNER = {'Skyra','Dummy','Debugging','Keyboard','buttonbox'}; SCANNER = SCANNER{1};
%setup_bits;
try
%% Screen stuff %%
%Set parameters to build screen (on Peter's advice)
%Skips the 'Welcome to psychtoolbox message'
Screen('Preference', 'VisualDebuglevel', 0);
%At the beginning of each script matlab does synctests. Level 1 and 2
%prevent those tests. What does 0 do?
Screen('Preference', 'SkipSyncTests', 1);
% Get the screen numbers
screens = Screen('Screens');
% Draw to the external screen if avaliable
screenNumber = max(screens);
% Open an on screen window
white = 255;
black = 0;
[window, ~] = Screen('OpenWindow',screenNumber,white);
% Hide mouse
HideCursor;
% Text settings
Screen('TextFont', window, 'Ariel');
Screen('TextSize', window, 32);
Screen('TextStyle', window, 0);
KbName('UnifyKeyNames');
%% Set ppnr
if nargin == 0
%% New PPNR
ppnr_str = openended(window, 'Participant Nr:', black);
initials = openended(window, 'Initials:', black);
ppnr = str2double(ppnr_str);
initials = sprintf('%s',upper(initials));
% Get counterbalancing variables
c = counterbalance(ppnr);
listing = dir([wd, '/results/']);
for i = 1:length(listing)
if strcmp(listing(i).name, sprintf('%i.txt', ppnr))
fprintf('Ppnr exists, abort file');
break
end
end
save([wd, '/results/', sprintf('c_%i.mat', ppnr)], 'c')
trial = 0;
else
%% PPNR already exists
% Load counterbalancing variables
load([wd, '/results/', sprintf('c_%i', ppnr)]);
initials = upper(initials);
end
%% Start task
practice = '';
UGR_NEW(window, ppnr, c, trial, initials, SCANNER, practice);
% if escape ~= 0
% fprintf(escape);
% end
Screen('CloseAll');
catch me
me.message
me.stack.line
Screen('CloseAll');
end
end