149 :length(fn)
150 if ~matches(fn{j}, me.ignoreProperties) %create a temporary dynamic property
151 p=me.addprop([fn{j} 'Out']);
152 if strcmp(fn{j},
'sf');p.SetMethod = @
set_sfOut;end
153 if strcmp(fn{j},
'tf');p.SetMethod = @
set_tfOut;end
155 if strcmp(fn{j},
'size');p.SetMethod = @
set_sizeOut;end
158 me.([fn{j} 'Out']) = me.(fn{j}); %copy our property value to our tempory copy
159 end
160 end
161
163
164 if isempty(me.findprop('rotateMode'));p=me.addprop('rotateMode');p.Transient=true;p.Hidden=true;end
165 if me.rotateTexture
166 me.rotateMode = kPsychUseTextureMatrixForRotation;
167 else
168 me.rotateMode = [];
169 end
170 me.specialFlags = mor(me.specialFlags, me.rotateMode);
171
172 if isempty(me.findprop('gratingSize'));p=me.addprop('gratingSize');p.Transient=true;end
173 me.gratingSize = round(me.ppd*me.size); %
virtual support larger than initial
size
174
175 if isempty(me.findprop('phaseIncrement'))
177 end
178
179 if isempty(me.findprop('driftPhase'));p=me.addprop('driftPhase');p.Transient=true;end
182 me.driftPhase=me.phaseOut-ps;
183 else
184 me.driftPhase=me.phaseOut;
185 end
186
187 if isempty(me.findprop('res'));p=me.addprop('res');p.Transient=true;end
188
190 case 1
191 me.res = round([me.gratingSize*me.
aspectRatio me.gratingSize]);
192 case 2
194 end
196 me.res = floor( me.res / (max(me.res) / me.
sM.
screenVals.width));
197 end
198
201 else
203 end
204
207 end
208
210 me.baseColourOut = me.
sM.backgroundColour;
211 me.baseColourOut(4) = me.
alpha;
212 end
213
214 % this is a checkerboard
shader
217
222
224 if value <= 0; value = 0.01; end
227 %fprintf('SET SFOut: %.2f | in: %.2f |
scale: %.2f\n', me.sfOut, me.
sfCache, me.
scale);
228 end
230 me.tfOut = value;
232 end
234 me.reverseDirectionOut = value;
236 end
238 me.sizeOut = ceil(value*me.
ppd);
239 me.
szPx = me.sizeOut;
240 %fprintf('SET sizeOut: %.2f | in: %.2f \n', me.sizeOut, value);
241 end
243 me.xPositionOut = value * me.
ppd;
244 end
246 me.yPositionOut = value*me.
ppd;
247 end
248
249 end
250
251 % ===================================================================
252 %> @brief Update this stimulus object for display
253 %>
254 % ===================================================================
259 me.driftPhase=me.phaseOut-ps;
260 else
261 me.driftPhase=me.phaseOut;
262 end
266 else
268 end
270 glUseProgram(0);
274 end
275
276 % ===================================================================
277 %> @brief Draw this stimulus object for display
278 %>
279 %> @param win -- optional [i.e. offscreen] window pointer
280 %> @param
sf - optional special Flags override
281 % ===================================================================
282 function
draw(me, win,
sf)
283 if ~exist('win','var'); win = me.
sM.win; end
287 me.angleOut, [], [], me.baseColourOut, [],
sf,...
288 [me.
ppd, me.sfOut, me.contrastOut, me.driftPhase, ...
289 me.colourOut, me.colour2Out]);
291 end
293 end
294
295 % ===================================================================
297 %>
298 % ===================================================================
305 end
306 end
307 if me.doMotion
309 end
310 if me.doDrift
312 %fprintf('Drift Phase: %.2f\n',me.driftPhase);
313 end
315 %tmp = me.colourOut;me.colourOut = me.colour2Out;me.colour2Out = tmp;
317 end
318 end
319 end
320
321 % ===================================================================
323 %>
325 %> @return stimulus structure.
326 % ===================================================================
330 try Screen('Close',me.
texture); end
331 end
336 end
340 end
341
342 % ===================================================================
343 %> @brief
sf Set method
344 %>
345 % ===================================================================
346 function set.
sf(me,value)
347 if value <= 0; value = 0.05; end
351 end
352
353 % ===================================================================
354 %> @brief SET Colour2 method
355 %> Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value
colour
356 % ===================================================================
358 len=length(value);
359 switch len
360 case {4,3}
361 me.colour2 = [value(1:3) me.
alpha]; %force our
alpha to
override
362 case 1
363 me.colour2 = [value value value me.alpha]; %construct RGBA
364 otherwise
365 me.colour2 = [1 1 1 me.alpha]; %return white for everything else
366 end
367 me.colour2(me.colour2<0)=0; me.colour2(me.colour2>1)=1;
368 end
369
370 % ===================================================================
372 %> Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value
colour
373 % ===================================================================
374 function set.baseColour(me,value)
375 len=length(value);
376 switch len
377 case 4
378 me.baseColour = value;
379 case 3
380 me.baseColour = [value(1:3) me.
alpha]; %force our
alpha to
override
381 case 1
382 me.baseColour = [value value value me.alpha]; %construct RGBA
383 case 0
384 me.baseColour = [];
385 otherwise
386 me.baseColour = [1 1 1 me.alpha]; %return white for everything else
387 end
388 me.baseColour(me.baseColour<0)=0; me.baseColour(me.baseColour>1)=1;
389 end
390
391 % ===================================================================
392 %> @brief calculate
phase offset
393 %>
394 % ===================================================================
397 if me.correctPhase > 0
399 size = (me.sizeOut/2); %divide by 2 to get the 0 point
400 sfTmp = (me.sfOut/me.scale)*me.ppd;
402 md=md-floor(md);
404 end
405 end
406
407 end %---END PUBLIC METHODS---%
408
409
410 %=======================================================================
411 methods ( Access = protected ) %-------PROTECTED METHODS-----%
412 %=======================================================================
413
414 % ===================================================================
416 %>
setRect makes the PsychRect based on the
texture and screen values
417 %> this is modified over parent method as gratings have slightly different
418 %> requirements.
419 % ===================================================================
421 %me.dstRect=Screen('Rect',me.texture);
422 me.dstRect=ScaleRect([0 0 me.res(1) me.res(2)],me.scale,me.scale);
423 if me.mouseOverride && me.mouseValid
424 me.dstRect = CenterRectOnPointd(me.dstRect, me.mouseX, me.mouseY);
425 else
426 if isempty(me.findprop('directionOut'))
427 [sx, sy]=pol2cart(me.d2r(me.direction),me.startPosition);
428 else
429 [sx, sy]=pol2cart(me.d2r(me.directionOut),me.startPosition);
430 end
431 me.dstRect=CenterRectOnPointd(me.dstRect,me.sM.xCenter,me.sM.yCenter);
432 if isempty(me.findprop('xPositionOut'))
434 else
436 end
437 end
441 end
442
443
444 % ===================================================================
446 %> Use an event to recalculate
scale as get method is slower (called
447 %> many more times), than an event which is only called on
update
448 % ===================================================================
453 end
454
455 % ===================================================================
457 %> Use an event to recalculate as get method is slower (called
458 %> many more times), than an event which is only called on
update
459 % ===================================================================
461 if ~isempty(me.findprop('tfOut'))
463 if ~isempty(me.findprop('reverseDirectionOut'))
464 if me.reverseDirectionOut == false
466 end
467 end
468 end
469 end
470
471 end
472end
function CreateProceduralCheckerboard(in windowPtr, in width, in height, in radius)
function computePosition(in me)
compute xFinal and yFinal (in pixels) taking startPosition, xPosition, yPosition and direction/angle ...
Property mouseValid
is mouse position within screen co-ordinates?
Definition baseStimulus.m:187
Property size
Definition baseStimulus.m:46
function getMousePosition(in me)
get mouse position we make sure this is only called once per animation tick to improve performance an...
Property sM
our screen manager
Definition baseStimulus.m:165
Property szPx
computed size in pixels
Definition baseStimulus.m:113
function setAnimationDelta(in me)
Property ppd
pixels per degree (normally inhereted from screenManager)
Definition baseStimulus.m:139
Property delayTicks
delay ticks to wait until display
Definition baseStimulus.m:196
function resetTicks(in me)
reset the various tick counters for our stimulus
Property colour
Definition baseStimulus.m:50
Property inSetup
are we setting up?
Definition baseStimulus.m:202
Property alpha
Alpha (opacity) [0-1], this gets combined with the RGB colour.
Definition baseStimulus.m:53
Property texture
Our texture pointer for texture-based stimuli.
Definition baseStimulus.m:159
Property verbose
Do we log extra details to the command-line?
Definition baseStimulus.m:86
Property isVisible
true or false, whether to draw() this object
Definition baseStimulus.m:77
Property yPosition
Definition baseStimulus.m:42
Property screenVals
screen settings generated by sM on setup
Definition baseStimulus.m:171
Property isSetup
Definition baseStimulus.m:174
Property mvRect
Definition baseStimulus.m:102
Property drawTick
draw tick only updates when a draw is actually performed, resets on each update
Definition baseStimulus.m:136
function removeTmpProperties(in me)
Finds and removes dynamic properties.
Property dX_
dX cache
Definition baseStimulus.m:208
Property mouseX
mouse X position
Definition baseStimulus.m:190
Property dstRect
initial screen rectangle position [LEFT TOP RIGHT BOTTOM]
Definition baseStimulus.m:184
function addRuntimeProperties(in me)
These are transient properties that specify actions during runtime.
Property mouseY
mouse Y position
Definition baseStimulus.m:193
Property tick
tick updates +1 on each call of draw (even if delay or off is true and no stimulus is drawn,...
Definition baseStimulus.m:133
Property mouseOverride
override X and Y position with mouse input? Useful for RF mapping
Definition baseStimulus.m:80
Property xPosition
Definition baseStimulus.m:38
Property dY_
dY cache
Definition baseStimulus.m:211
Property offTicks
ticks before stimulus turns off
Definition baseStimulus.m:199
function set_sfOut(in me, in value)
Property maskValue
mask value (radius for the procedural shader)
Definition checkerboardStimulus.m:107
Property baseColour
Definition checkerboardStimulus.m:29
function update(in me)
Update this stimulus object for display.
Property aspectRatio
aspect ratio of the grating
Definition checkerboardStimulus.m:63
Property phase
phase of grating
Definition checkerboardStimulus.m:35
function set_yPositionOut(in me, in value)
function calculatePhase(in me)
calculate phase offset
function set_tfOut(in me, in value)
function animate(in me)
Animate this object for runExperiment.
Property mask
use a circular mask for the grating (default = true).
Definition checkerboardStimulus.m:41
Property colour2
second colour of the checkerboard
Definition checkerboardStimulus.m:25
Property phaseCounter
how many frames between phase reverses
Definition checkerboardStimulus.m:104
Property shader
the raw shader, we can try to change colours.
Definition checkerboardStimulus.m:110
Property correctPhase
Definition checkerboardStimulus.m:54
function set_reverseDirectionOut(in me, in value)
function setRect(in me)
setRect setRect makes the PsychRect based on the texture and screen values this is modified over pare...
function calculateScale(in me, in ignoredArg, in ignoredArg)
calculateScale Use an event to recalculate scale as get method is slower (called many more times),...
function set_xPositionOut(in me, in value)
function set_sizeOut(in me, in value)
Property specialFlags
special flags passed to drawing functions
Definition checkerboardStimulus.m:66
Property scale
scale is used when changing size as an independent variable to keep sf accurate
Definition checkerboardStimulus.m:75
function calculatePhaseIncrement(in me, in ignoredArg, in ignoredArg)
calculatePhaseIncrement Use an event to recalculate as get method is slower (called many more times),...
Property sfCache
Definition checkerboardStimulus.m:90
function draw(in me, in win, in sf)
Draw this stimulus object for display.
Property phaseReverseTime
Reverse phase of grating X times per second? Useful with a static grating for linearity testing.
Definition checkerboardStimulus.m:57
function reset(in me)
Reset an structure for runExperiment.
Property phaseOfReverse
What phase to use for reverse?
Definition checkerboardStimulus.m:60
Property sf
spatial frequency of the checkerboard
Definition checkerboardStimulus.m:19
@ changePhaseIncrement
triggered when changing tf or drift direction
Definition checkerboardStimulus.m:118
Property phaseIncrement
the phase amount we need to add for each frame of animation
Definition checkerboardStimulus.m:78
function salutation(in me, in varargin)
Prints messages dependent on verbosity.
The main experiment manager.
Definition runExperiment.m:3