|
35 | 35 | % ------------------------------------------------------------------------- |
36 | 36 |
|
37 | 37 | % Define black and white |
38 | | -white = WhiteIndex(cfg.screenNumber); |
39 | | -black = BlackIndex(cfg.screenNumber); |
| 38 | +white = WhiteIndex(cfg.screen); |
| 39 | +black = BlackIndex(cfg.screen); |
40 | 40 | grey = white / 2; |
41 | 41 | inc = white - grey; |
42 | 42 |
|
|
91 | 91 | mask(:, :, 2)= grating .* contrast; |
92 | 92 |
|
93 | 93 | % Make our grating mask texture |
94 | | -gratingMaskTex = Screen('MakeTexture', cfg.window, mask); |
| 94 | +gratingMaskTex = Screen('MakeTexture', cfg.win, mask); |
95 | 95 |
|
96 | 96 | % Make a black and white noise mask half the size of our grating. This will |
97 | 97 | % be scaled upon drawing to make a "chunky" noise texture which our grating |
|
100 | 100 | noise = rand(round(visibleSize / 2)) .* white; |
101 | 101 |
|
102 | 102 | % Make our noise texture |
103 | | -noiseTex = Screen('MakeTexture', cfg.window, noise); |
| 103 | +noiseTex = Screen('MakeTexture', cfg.win, noise); |
104 | 104 |
|
105 | 105 | % Make a destination rectangle for our textures and center this on the |
106 | 106 | % screen |
107 | 107 | dstRect = [0 0 visibleSize visibleSize]; |
108 | | -dstRect = CenterRect(dstRect, cfg.windowRect); |
| 108 | +dstRect = CenterRect(dstRect, cfg.winRect); |
109 | 109 |
|
110 | 110 | % Calculate the wait duration |
111 | 111 | waitDuration = waitframes * cfg.ifi; |
|
119 | 119 | shiftPerFrame = cyclesPerSecond * pixPerCycle * waitDuration; |
120 | 120 |
|
121 | 121 | % Sync us to the vertical retrace |
122 | | -vbl = Screen('Flip', cfg.window); |
| 122 | +vbl = Screen('Flip', cfg.win); |
123 | 123 |
|
124 | 124 | % Set the frame counter to zero, we need this to 'drift' our grating |
125 | 125 | frameCounter = 0; |
|
138 | 138 | srcRect = [xoffset 0 xoffset + visibleSize visibleSize]; |
139 | 139 |
|
140 | 140 | % Draw noise texture to the screen |
141 | | - Screen('DrawTexture', cfg.window, noiseTex, [], dstRect, []); |
| 141 | + Screen('DrawTexture', cfg.win, noiseTex, [], dstRect, []); |
142 | 142 |
|
143 | 143 | % Draw grating mask |
144 | | - Screen('DrawTexture', cfg.window, gratingMaskTex, srcRect, dstRect, []); |
| 144 | + Screen('DrawTexture', cfg.win, gratingMaskTex, srcRect, dstRect, []); |
145 | 145 |
|
146 | 146 | % Flip to the screen on the next vertical retrace |
147 | | - vbl = Screen('Flip', cfg.window, vbl + (waitframes - 0.5) * cfg.ifi); |
| 147 | + vbl = Screen('Flip', cfg.win, vbl + (waitframes - 0.5) * cfg.ifi); |
148 | 148 |
|
149 | 149 | end |
150 | 150 |
|
|
180 | 180 | % Here we call some default settings for setting up Psychtoolbox |
181 | 181 | PsychDefaultSetup(2); |
182 | 182 |
|
183 | | -% Get the screen numbers |
184 | | -cfg.screens = Screen('Screens'); |
185 | | - |
186 | | -% Draw to the external screen if avaliable |
187 | | -cfg.screenNumber = max(cfg.screens); |
| 183 | +% Get the screen numbers and draw to the external screen if avaliable |
| 184 | +cfg.screen = max(Screen('Screens')); |
188 | 185 |
|
189 | 186 | % Open an on screen window |
190 | | -[cfg.window, cfg.windowRect] = Screen('OpenWindow', cfg.screenNumber, cfg.backgroundColor); |
| 187 | +[cfg.win, cfg.winRect] = Screen('OpenWindow', cfg.screen, cfg.backgroundColor); |
191 | 188 |
|
192 | 189 | % Get the size of the on screen window |
193 | | -[cfg.screenXpixels, cfg.screenYpixels] = Screen('WindowSize', cfg.window); |
| 190 | +[cfg.winWidth, cfg.winHeight] = WindowSize(cfg.win); |
194 | 191 |
|
195 | 192 | % Query the frame duration |
196 | | -cfg.ifi = Screen('GetFlipInterval', cfg.window); |
| 193 | +cfg.ifi = Screen('GetFlipInterval', cfg.win); |
197 | 194 |
|
198 | | -% Get the centre coordinate of the window |
199 | | -[cfg.xCenter, cfg.yCenter] = RectCenter(cfg.windowRect); |
| 195 | +% Get the Center of the Screen |
| 196 | +cfg.center = [cfg.winRect(3), cfg.winRect(4)]/2; |
200 | 197 |
|
201 | 198 | % Set up alpha-blending for smooth (anti-aliased) lines |
202 | | -Screen('BlendFunction', cfg.window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); |
| 199 | +Screen('BlendFunction', cfg.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); |
203 | 200 |
|
204 | 201 | end |
205 | 202 |
|
|
0 commit comments