forked from bobvo23/flicker_stimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flickermovie.m
63 lines (58 loc) · 2.26 KB
/
flickermovie.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 [flickerTexure]=flickermovie(winWidth,winHeight,targetWidth,targetHeight)
yScreen = max(Screen('Screens'));
Priority(0);
%myScreen = 2;
SquareRect = 900;
[win,winRect] = Screen(myScreen,'OpenWindow',[],[0 0 SquareRect SquareRect]);
width =900;
height = 900;
[width, height] = RectSize(winRect);
winWidth = 900;
winHeight =900;
%% Generate matrix for 4 target (Top, Right, Down, Left)
for i=1:5
targetMatrix{i} = zeros(winWidth,winHeight,'uint8');
end
targetWidth = 200;
targetHeight = 200;
%conver maxtrix from zero to target
% 00100 Top
% 10001 Left/Right
% 00100 Down
for i =1:winHeight
for j=1:winWidth
%Target1 : Top
if (j>= (winWidth/2-targetWidth/2))&&( j <= winWidth/2+targetWidth/2)&&( i <=targetHeight)
targetMatrix{1}(i,j)=1; %match target coordinate
%disp('got it');
end
%Target3 : Down
if (j>= (winWidth/2-targetWidth/2))&&( j <= winWidth/2+targetWidth/2)&&( i >= (winHeight-targetHeight))
targetMatrix{3}(i,j)=1; %match target coordinate
%disp('got it');
end
%Target2 : Right
if (j>= (winWidth-targetWidth))&&( i >= (winHeight/2-targetHeight/2))&&( i <= (winHeight/2+targetHeight/2))
targetMatrix{2}(i,j)=1; %match target coordinate
%disp('got it');
end
%Target4 : Left
if (j<= (targetWidth))&&( i >= (winHeight/2-targetHeight/2))&&( i <= (winHeight/2+targetHeight/2))
targetMatrix{4}(i,j)=1; %match target coordinate
%disp('got it');
end
end
end
%%Draw texture to screen: Draw 16 states depens on the value of
for targetState1=1:2
for targetState2=1:2
for targetState3=1:2
for targetState4=1:2
textureNumber = (targetState4-1)*8 +(targetState3-1)*4 +(targetState2-1)*2 +(targetState1-1)*1 +1;
screenMatrix{textureNumber}=targetMatrix{5} | targetMatrix{1}*uint8(targetState1-1) |...
uint8(targetState2-1)*targetMatrix{2} |...
uint8(targetState3-1)*targetMatrix{3} | uint8(targetState4-1)*targetMatrix{4};
end
end
end
end