-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestscreen.m
More file actions
150 lines (120 loc) · 5.13 KB
/
testscreen.m
File metadata and controls
150 lines (120 loc) · 5.13 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
function testscreen(debug, modulateColor)
if nargin == 0
debug =0;
modulateColor =[255 255 255];
elseif nargin == 1
modulateColor =[255 255 255];
end
color_sequence = { modulateColor,
[255, 0, 0],
[0, 255, 0],
[0, 0, 255] };
n_colors = length(color_sequence);
commandwindow
addpath('HelperFunctions/')
screen = InitScreen(debug);
waitframes = 1;
boxL_um = 120; %unit: um
boxL = Pixel_for_Micron(boxL_um); %um to pixels %not good to round here.
disp(['Pixel N for ', num2str(boxL_um), 'um = ', num2str(boxL), ' px']);
disp(['Pixel N for ', num2str(100), 'um = ', num2str(PIXELS_PER_100_MICRONS), ' px']);
% MEA Box (150um = MEA length = 30 * 5)
boxL_mea = 5*boxL;
N = 20; % determines the stim size
stimsize = N*boxL;
disp(['Stim size = ', num2str(N*boxL_um), ' um (', num2str(stimsize), ' px)']);
% Define the obj Destination Rectangle
objRect = RectForScreen(screen,stimsize,stimsize,0,0);
for i=1:2
% 1. random texture pointer
%Screen('FillRect', screen.w, 0.5*modulateColor);
%texMatrix = ( rand(N, N)>.5)*2*screen.gray;
%objTex = Screen('MakeTexture', screen.w, texMatrix);
% display last texture
%Screen('DrawTexture', screen.w, objTex, [], objRect, 0, 0, 1, modulateColor); % globalalpha default = 1, but ignored when modulateColor is specified.
% 2. checker on gray
%
[x, y] = meshgrid(1:N, 1:N);
texMatrix = mod(x+y,2)*2*screen.gray;
% texture pointer
objTex = Screen('MakeTexture', screen.w, texMatrix);
for j=1:n_colors
Screen('FillRect', screen.w, 0.5*modulateColor);
Screen('DrawTexture', screen.w, objTex, [], objRect, 0, 0, 1, color_sequence{j});
Screen('FillOval', screen.w, screen.white, DefinePD);
%Screen('DrawTexture', windowPointer, texturePointer [,sourceRect]
%[,destinationRect] [,rotationAngle] [, filterMode] [, globalAlpha] [,
%modulateColor] [, textureShader] [, specialFlags] [, auxParameters]);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end;
end
% 3-0. Stim area (0 intensity outside of the stim area)
box = RectForScreen(screen,stimsize,stimsize,0, 0);
% dark Stim area on gray
Screen('FillRect', screen.w, modulateColor);
Screen('FillRect', screen.w, 0, box);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end
% bright stim area on dark
Screen('FillRect', screen.w, 0);
Screen('FillRect', screen.w, modulateColor, box);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end
% 3-1. MEA Box (0 intensity)
% dark MEA on gray
box = RectForScreen(screen, boxL_mea, boxL_mea, 0, 0);
Screen('FillRect', screen.w, 0.5*modulateColor); % background
Screen('FillRect', screen.w, 0, box);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end;
% white MEA on dark
% for power calibration
Screen('FillRect', screen.w, 0); % background
Screen('FillRect', screen.w, modulateColor, box);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end;
% 3-2. 1 Box
box = RectForScreen(screen,boxL,boxL,0, 0);
% dark box on gray
Screen('FillRect', screen.w, 0.5*modulateColor);
Screen('FillRect', screen.w, 0, box);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end;
% bright box on dark
Screen('FillRect', screen.w, 0);
Screen('FillRect', screen.w, modulateColor, box);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end
% black screen
Screen('FillRect', screen.w, 0);
Screen('Flip', screen.w, 0);
KbWait(-1, 2); [~, ~, c]=KbCheck; YorN=find(c);
if YorN==27, break; end
% moving bar?
% 2*N+1 texture with a bar at the center. Draw a subpart
texMatrix = ones(N,2*N+1);
texMatrix(:, N+1) = 0;
objTex = Screen('MakeTexture', screen.w, texMatrix);
shiftperframe = 1;% in pixels
n_frames = round(stimsize/shiftperframe);
for i = 1:n_frames
% Shift the grating by "shiftperframe" pixels per frame:
xoffset = mod(i*shiftperframe, N);
% Define shifted srcRect that cuts out the properly shifted rectangular
% area from the texture:
%srcRect=[xoffset 0 xoffset + visiblesize visiblesize];
Screen('FillRect', screen.w, 0.5*modulateColor);
Screen('DrawTexture', screen.w, objTex, [], objRect, 0, 0, 1, modulateColor);
% Flip 'waitframes' monitor refresh intervals after last redraw.
%vbl = Screen('Flip', w, vbl + (waitframes - 0.5) * screen.ifi);
end
end
Screen('CloseAll');
end