-
Notifications
You must be signed in to change notification settings - Fork 0
/
DrawMunkerStimulus.m
71 lines (60 loc) · 2.43 KB
/
DrawMunkerStimulus.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
function DrawMunkerStimulus( stimulus, screen )
%Draws a Munker stimulus to the screen
%
% stimulus is struct containing fields:
% stripeColourA
% stripeColourB
% figureColour
% stripeIndex (1 for drawing foreground on A, 2 for B, 3 For Full)
% destinationRect (location to draw)
% imageMatrix (matrix of indexes 1 to 4)
%
% screen is a struct containing
% centreX
% centreY
% ptr
% rect
% number
% Step 1: Get seperate matrices for red / green / blue for all four colour
% indexes, set them to stripe colours a and b.
red = [stimulus.stripeColourA(1),...
stimulus.stripeColourA(1),...
stimulus.stripeColourB(1),...
stimulus.stripeColourB(1)];
green = [stimulus.stripeColourA(2),...
stimulus.stripeColourA(2),...
stimulus.stripeColourB(2),...
stimulus.stripeColourB(2)];
blue = [stimulus.stripeColourA(3),...
stimulus.stripeColourA(3),...
stimulus.stripeColourB(3),...
stimulus.stripeColourB(3)];
% Step 2: depending on value (1 or 2) set the foreground index of either a
% stripes or b stripes to the correct colour
if stimulus.stripeIndex == 1
red(1) = stimulus.figureColour(1);
green(1) = stimulus.figureColour(2);
blue(1) = stimulus.figureColour(3);
elseif stimulus.stripeIndex == 2
red(3) = stimulus.figureColour(1);
green(3) = stimulus.figureColour(2);
blue(3) = stimulus.figureColour(3);
else
red(1) = stimulus.figureColour(1);
green(1) = stimulus.figureColour(2);
blue(1) = stimulus.figureColour(3);
red(3) = stimulus.figureColour(1);
green(3) = stimulus.figureColour(2);
blue(3) = stimulus.figureColour(3);
end
% Step 3: construct the images, by using the imageMatrix as indexes to
% the individual colour arrays
image(:,:,1) = red(stimulus.imageMatrix);
image(:,:,2) = green(stimulus.imageMatrix);
image(:,:,3) = blue(stimulus.imageMatrix);
% Step 4: copy the texture to the graphics display
texture = Screen('MakeTexture', screen.ptr, image);
% Step 5: Draw the texture (and release texture from memory)
Screen('DrawTexture', screen.ptr, texture, [], stimulus.destinationRect);
Screen('Close', texture);
end