-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPresentation.m
64 lines (46 loc) · 1.85 KB
/
Presentation.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
PsychPortAudio('DeleteBuffer');
stim_count = 1;
playTime = tic;
stim_size = pixel_size(cfg.DOT_PITCH, cfg.STIM_SIZE, cfg.VISUAL_DISTANCE);
stim_locs = pixel_size(cfg.DOT_PITCH, cfg.STIM_LOCS, cfg.VISUAL_DISTANCE);
while toc(playTime) < cfg.playTime
out = stim_sound{cfg.condition_frame(stim_count),1}; % load stim sound
isi = (length(out) / cfg.AUDIO_SAMPLING_RATE) + cfg.TIME_ISI; % set stim isi
if visionMode
if cfg.condition_frame(stim_count) == 1 % when sound A presented
Screen('CopyWindow',empty,win);
Screen('DrawTexture', win, imagetex, [], ...
[centerX - stim_size - stim_locs, centerY - (stim_size*ratio), centerX + stim_size - stim_locs, centerY + (stim_size*ratio)]);
elseif cfg.condition_frame(stim_count) == 2 % when sound B presented
Screen('CopyWindow',empty,win);
Screen('DrawTexture', win, imagetex, [], ...
[centerX - stim_size + stim_locs, centerY - (stim_size*ratio), centerX + stim_size + stim_locs, centerY + (stim_size*ratio)]);
end
Screen('Flip', win,0,1);
end
% imageArray=Screen('GetImage',win);
% imwrite(imageArray,['test_' num2str(stim_count) '.png']);
% auditory stimulus onset
PsychPortAudio('DeleteBuffer');
PsychPortAudio('FillBuffer', pahandle, out);
sTime = PsychPortAudio('Start', pahandle);
% silence
timer.silence = tic;
while toc(timer.silence) < isi
end
if visionMode
Screen('CopyWindow',empty,win);
Screen('Flip', win,0,1);
end
stim_count = stim_count+1;
clear keyCode;
[keyIsDown,secs,keyCode]=KbCheck;
% interrupt by ESC
if (keyCode(cfg.key.KEY_ESCAPE))
Screen('CloseAll');
Screen('ClearAll');
ListenChar(0);
sca;
return
end
end