forked from BrainAndNumber/SimSeq_CerebralCortex2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunExp.m
More file actions
101 lines (87 loc) · 2.71 KB
/
RunExp.m
File metadata and controls
101 lines (87 loc) · 2.71 KB
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
function RunExp()
%author: Seda Cavdaroglu, 17/07/13
AssertOpenGL;
%get subject number before starting the task
prompt = {'Subject Number:','Block No'};
dlg_title = 'Input';
num_lines = 1;
def = {'',''};
answer = inputdlg(prompt,dlg_title,num_lines,def);
subNo =str2num(char(answer(1)));
block_no = str2num(char(answer(2)));
%define colors
black = [0 0 0];
white = [255 255 255];
screens=Screen('Screens');
screenNumber=1;%max(screens);
[w, rect] = Screen('OpenWindow', screenNumber, black);
%use the 5 key to start the task
kc_s = KbName('5%');
kc_esc = KbName('esc');
% Do initial flip...
Screen('Flip',w);
[center(1), center(2)] = RectCenter(rect);
%
% Screen('Flip',w);
% [center(1), center(2)] = RectCenter(rect);
% keyFile = strcat('log_files\',num2str(subNo),'_keys.txt');
% if block_no == 1
% [keyIsDown secs keycodes] = KbCheck();
% while isempty(keycodes) || ~keycodes(kc_esc)
% Screen('DrawText', w, 'Press the left key', center(1)-200, center(2),white);
% Screen('Flip', w);
% str_left = KbName();
% while ~keycodes(kc_esc)
% Screen('DrawText', w, str_left, center(1)-100, center(2),white);
% Screen('Flip', w);
% [keyIsDown secs keycodes] = KbCheck();
% end;
% end;
%
% vbl = Screen('Flip', w);
%
% keycodes(kc_esc) = 0;
% [keyIsDown secs keycodes] = KbCheck();
% keycodes(kc_esc) = 0;
%
% while ~keycodes(kc_esc)
%
% Screen('DrawText', w, 'Press the right key', center(1)-200, center(2),white);
% Screen('Flip', w);
% str_right = KbName();
% while ~keycodes(kc_s)
% Screen('DrawText', w, str_right, center(1)-100, center(2),white);
% Screen('Flip', w);
% [keyIsDown secs keycodes] = KbCheck();
% end;
% end;
% %clean the screen
% Screen('Flip', w);..............................................
%
%
% fid = fopen(keyFile,'wt');
% fprintf(fid,'%s\t',str_left);
% fprintf(fid,'%s\t',str_right);
% end;
%
%
% keycodes(kc_s) = 0;
[keyIsDown secs keycodes] = KbCheck();
keycodes(kc_s) = 0;
while ~keycodes(kc_s)
Screen('DrawText', w, 'Waiting for the trigger...', center(1)-200, center(2),white);
vbl = Screen('Flip', w);
[keyIsDown secs keycodes] = KbCheck();
end;
vbl = Screen('Flip', w);
PlayNums(w,rect,subNo,vbl,block_no);
[keyIsDown secs keycodes] = KbCheck();
keyIsDown = 0;
while ~keyIsDown
[keyIsDown secs keycodes] = KbCheck();
Screen('DrawText', w, 'End of the block... You can relax...', center(1)-300, center(2));
Screen('Flip', w);
end;
%clean the screen
Screen('Flip', w);
Screen('CloseAll');