-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplayPictureViewing.m
39 lines (31 loc) · 1.35 KB
/
playPictureViewing.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
function [settings, logs] = playPictureViewing(settings, logs, currTrial, frames)
% play picture-viewing task
% MN, September 2021
total_n_Trial = currTrial+logs{1}.passedTrials;
logs{total_n_Trial}.pic = settings.pics.paths{currTrial};
for cFrame = frames
% quit if user aborted experiment
[~, firstPress] = KbQueueCheck();
if firstPress(logs{1}.keys.escapeKey) || logs{1}.userQuit == 1
logs{1}.userQuit = 1;
return;
end
% draw image
total_n_Trial = currTrial+logs{1}.passedTrials;
picSz = round(settings.scr.height/3);
[center(1), center(2)] = RectCenter(logs{1}.winRect);
picCoords = [center(1)-picSz center(2)-picSz, center(1)+picSz center(2)+picSz];
Screen('DrawTexture', logs{1}.w, settings.pics.id(currTrial), [],picCoords);
% finish drawing and flip to screen
Screen('DrawingFinished', logs{1}.w);
logs{total_n_Trial}.flips(cFrame,1) = Screen('Flip', logs{1}.w);
% log scanner trigger
if firstPress(logs{1}.keys.scannerTriggerKey)
logs{1}.tTriggers = [logs{1}.tTriggers, logs{total_n_Trial}.flips(cFrame,1)];
end
% log NaN's for xy's
logs{total_n_Trial}.xy(cFrame, :) = [nan, nan];
end
% add trial info to log file
logs{total_n_Trial}.trialType = 'free_viewing';
end