-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelicitCueName.m
73 lines (61 loc) · 2.08 KB
/
elicitCueName.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
function [ response, rt, tStart, tEnd, exitFlag ] =...
elicitCueName( window, responseHandler, tex, keys, constants, answer )
%collectResponses Show arrow until participant makes response, and collect
%that response
response = {''};
rt = NaN;
exitFlag = {'OK'};
slack = .5;
% advance = 0;
KbQueueCreate(constants.device, keys);
drawFixation(window);
vbl= Screen('Flip', window.pointer);
firstFlip = 1;
while 1
drawStimulus(window, response{1}, tex);
vbl = Screen('Flip', window.pointer, vbl + (slack * window.ifi));
if firstFlip
tStart = vbl;
KbQueueStart(constants.device);
firstFlip = 0;
end
% KbQueueWait;
[keys_pressed, press_times] = responseHandler(constants.device, answer);
if ~isempty(keys_pressed)
[keyName, rt] = ...
wrapper_keyProcess(keys_pressed, press_times, tStart, 'name');
switch keyName{1}
case {'Return', 'ESCAPE'}
break;
case 'BackSpace'
if ~isempty(response{1})
response = {response{1}(1:end-1)};
end
case 'space'
response = {[response{1}, ' ']};
otherwise
response = {[response{1}, keyName{1}]};
end
end
end
tEnd = Screen('Flip', window.pointer, vbl + (0.5 * window.ifi));
if isempty(response{:})
response = {'NO RESPONSE'};
end
KbQueueStop(constants.device);
KbQueueFlush(constants.device);
KbQueueRelease(constants.device);
end
function drawStimulus(window, response, tex)
for eye = 1:2
Screen('SelectStereoDrawBuffer',window.pointer,eye-1);
Screen('DrawTexture', window.pointer, tex, [], window.imagePlace);
% prompt participant to respond
DrawFormattedText(window.pointer, 'What is this a part of?', ...
window.xCenter-300, window.winRect(4)*.8);
DrawFormattedText(window.pointer, response, window.xCenter+100, window.winRect(4)*.8);
DrawFormattedText(window.pointer, '[Press Enter to Continue]', ...
'center', window.winRect(4)*.9);
end
Screen('DrawingFinished',window.pointer);
end