-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_and_play_stim.m
63 lines (48 loc) · 2.21 KB
/
compute_and_play_stim.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
function compute_and_play_stim()
global BpodSystem;
% % for dots
% display = BpodSystem.Data.Custom.display;
% dots = BpodSystem.Data.Custom.dots;
% curr_trial = BpodSystem.Data.Custom.iTrial;
% % draw dots, note: this does not flip the screen
% draw_dots(display,dots)
%
% %update the dot position
% [dots.x,dots.y] = move_dots(dots.x,dots.y,dots.dx(curr_trial,:),dots.dy(curr_trial,:));
%
% % Deal with dots that move offscreen
% [dots.x,dots.y] = compute_aperture(dots.x,dots.y,dots.center,dots.apertureSize);
%
% % Deal with dots that have died
% [dots.x, dots.y, dots.life] = compute_life(dots);
%
% % flip the screen
% display.vbl = Screen('Flip', display.windowPtr, display.vbl + (display.waitframes + 1.0) * display.ifi);
%
% BpodSystem.Data.Custom.display = display;
% BpodSystem.Data.Custom.dots = dots;
% for dots
%BpodSystem.Data.Custom.display;
%dots = BpodSystem.Data.Custom.dots;
curr_trial = BpodSystem.Data.Custom.iTrial;
% draw dots, note: this does not flip the screen
dots = BpodSystem.Data.Custom.dots{curr_trial};
draw_dots(BpodSystem.Data.Custom.display, dots);
%update the dot position
[dots.x, dots.y] = move_dots(dots.x, dots.y, dots.dx, dots.dy);
% Deal with dots that move offscreen
[dots.x, dots.y] = compute_aperture(dots.x, dots.y, dots.center, dots.apertureSize);
% Deal with dots that have died
[dots.x, dots.y, dots.life] = compute_life(dots);
BpodSystem.Data.Custom.dots{curr_trial} = dots;
% flip the screen
% for dots
%display fps is 60 but we are presenting stimuli at 30. waitframes
%should be .5*ifi but now it's 1*ifi because the ifi is already half
%waht we want
BpodSystem.Data.Custom.display.vbl = Screen('Flip', ...
BpodSystem.Data.Custom.display.windowPtr, ...
BpodSystem.Data.Custom.display.vbl + (BpodSystem.Data.Custom.display.waitframes) * BpodSystem.Data.Custom.display.ifi);
%BpodSystem.Data.Custom.display = display;
%BpodSystem.Data.Custom.dots = dots;
end