Opticka 2.16.1
Opticka is an experiment manager for behavioral research.
Loading...
Searching...
No Matches
checkerboardStimulus Class Reference

checkerBoardStimulus – using a GLSL shader to make the checkerboard More...

Detailed Description

checkerBoardStimulus – using a GLSL shader to make the checkerboard

See docs for more property details

Copyright ©2014-2022 Ian Max Andolina — released: LGPL3, see LICENCE.md

Inheritance diagram for checkerboardStimulus:

Public Types

enum  Events { changeScale , changePhaseIncrement }
 
- Public Types inherited from baseStimulus
enum  Events { readPanelUpdate }
 

Public Member Functions

function checkerboardStimulus (in varargin)
 Class constructor.
 
function setup (in me, in sM)
 Setup this object in preparation for use When displaying a stimulus object, the main properties that are to be modified are copied into cache copies of the property, both to convert from visual description (c/d, Hz, degrees) to computer metrics, and to be animated and modified as independant variables. So xPosition is copied to xPositionOut and converted from degrees to pixels. The animation and drawing functions use these modified properties, and when they are updated, for example to change to a new xPosition, internal methods ensure reconversion and update any dependent properties. This method initialises the object with all the cache properties for display.
 
function set_sfOut (in me, in value)
 
function set_tfOut (in me, in value)
 
function set_reverseDirectionOut (in me, in value)
 
function set_sizeOut (in me, in value)
 
function set_xPositionOut (in me, in value)
 
function set_yPositionOut (in me, in value)
 
function update (in me)
 Update this stimulus object for display.
 
function draw (in me, in win, in sf)
 Draw this stimulus object for display.
 
function animate (in me)
 Animate this object for runExperiment.
 
function reset (in me)
 Reset an structure for runExperiment.
 
function set sf (in me, in value)
 sf Set method
 
function set colour2 (in me, in value)
 SET Colour2 method Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value colour.
 
function set baseColour (in me, in value)
 SET baseColour method Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value colour.
 
function calculatePhase (in me)
 calculate phase offset
 
- Public Member Functions inherited from baseStimulus
virtual setup (in runObject)
 ALL Children must implement these 5 methods!
 
virtual draw (in runObject)
 draw to the screen buffer, ready for flip()
 
function baseStimulus (in varargin)
 Class constructor.
 
function set colour (in me, in value)
 colour set method Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value colour
 
function set alpha (in me, in value)
 alpha set method
 
function get delta (in me)
 delta Get method delta is the normalised number of pixels per frame to move a stimulus
 
function get dX (in me)
 dX Get method X position increment for a given delta and angle
 
function get dY (in me)
 dY Get method Y position increment for a given delta and angle
 
function show (in me)
 Method to set isVisible=true.
 
function hide (in me)
 Method to set isVisible=false.
 
function setOffTime (in me, in time)
 set offTime
 
function setDelayTime (in me, in time)
 set delayTime
 
function resetTicks (in me)
 reset the various tick counters for our stimulus
 
function getMousePosition (in me)
 get mouse position we make sure this is only called once per animation tick to improve performance and ensure all stimuli that are following mouse position have consistent X and Y per frame update This sets mouseX and mouseY and mouseValid if mouse is within PTB screen (useful for mouse override positioning for stimuli)
 
function run (in me, in benchmark, in runtime, in s, in forceScreen, in showVBL)
 Run stimulus in a window to preview it.
 
function makePanel (in me, in parent)
 make a GUI properties panel for this object
 
function selectFilePanel (in me, in varargin)
 read values from a GUI properties panel for this object
 
function readPanel (in me, in varargin)
 read values from a GUI properties panel for this object
 
function showPanel (in me)
 show GUI properties panel for this object
 
function hidePanel (in me)
 hide GUI properties panel for this object
 
function closePanel (in me, in varargin)
 close GUI panel for this object
 
function cleanHandles (in me, in ignoredArg)
 clean any handles
 
function getP (in me, in name, in range)
 gets a property copy or original property
 
function setP (in me, in name, in value)
 sets a property copy or original property
 
function updateXY (in me, in x, in y, in useDegrees)
 Update only position info, faster and doesn't reset image etc.
 
- Public Member Functions inherited from optickaCore
function optickaCore (in varargin)
 Class constructor.
 
function get fullName (in me)
 
function getALF (in me, in subject, in sessionPrefix, in lab, in create)
 
function findAttributes (in me, in attrName, in attrValue)
 
function findAttributesandType (in me, in attrName, in attrValue, in type)
 find properties of object with specific attributes, for example all properties whose GetAcccess attribute is public and type is logical.
 
function findPropertyDefault (in me, in propName)
 
function clone (in me)
 Use this syntax to make a deep copy of the object, i.e. OBJ_OUT has the same field values, but will not behave as a handle-copy of me anymore.
 
function checkSuperclasses (in List)
 
function editProperties (in me, in properties)
 method to modify a set of properties
 
function setProp (in me, in property, in value)
 method to fast change a particular value. This is useful for use in anonymous functions, like in the state machine.
 
function initialiseGlobals (in me, in doReset, in doOpen)
 
function initialiseSaveFile (in me)
 Initialise Save prefix.
 
function checkPaths (in me)
 checks the paths are valid
 

Public Attributes

Property type
 family type
 
Property sf
 spatial frequency of the checkerboard
 
Property tf
 temporal frequency of the checkerboard
 
Property colour2
 second colour of the checkerboard
 
Property baseColour
 
Property rotateTexture
 rotate the grating patch (false) or the grating texture within the patch (default = true)?
 
Property phase
 phase of grating
 
Property contrast
 contrast of grating (technically the contrast from the baseColour)
 
Property mask
 use a circular mask for the grating (default = true).
 
Property reverseDirection
 direction of the drift; default = false means drift left>right when angle is 0deg.
 
Property direction
 the direction of the grating object if moving.
 
Property correctPhase
 
Property phaseReverseTime
 Reverse phase of grating X times per second? Useful with a static grating for linearity testing.
 
Property phaseOfReverse
 What phase to use for reverse?
 
Property aspectRatio
 aspect ratio of the grating
 
Property specialFlags
 special flags passed to drawing functions
 
Property family
 
Property scale
 scale is used when changing size as an independent variable to keep sf accurate
 
Property phaseIncrement
 the phase amount we need to add for each frame of animation
 
- Public Attributes inherited from baseStimulus
Property type
 stimulus type
 
Property xPosition
 
Property yPosition
 
Property size
 
Property colour
 
Property alpha
 Alpha (opacity) [0-1], this gets combined with the RGB colour.
 
Property startPosition
 
Property speed
 
Property angle
 angle in degrees (0 - 360)
 
Property delayTime
 
Property offTime
 time to turn stimulus off, relative to stimulus onset
 
Property isVisible
 true or false, whether to draw() this object
 
Property mouseOverride
 override X and Y position with mouse input? Useful for RF mapping
 
Property showOnTracker
 show the position on the Eyetracker display?
 
Property verbose
 Do we log extra details to the command-line?
 
Property xFinal
 
Property yFinal
 
Property mvRect
 
Property szIsPx
 
Property szPx
 computed size in pixels
 
Property szD
 computed size in °
 
Property xFinalD
 X and Y position in °
 
Property yFinalD
 
Property isRect
 
Property tick
 tick updates +1 on each call of draw (even if delay or off is true and no stimulus is drawn, resets on each update
 
Property drawTick
 draw tick only updates when a draw is actually performed, resets on each update
 
Property ppd
 pixels per degree (normally inhereted from screenManager)
 
Property delta
 What our per-frame motion delta is.
 
Property dX
 X update which is computed from our speed and angle.
 
Property dY
 X update which is computed from our speed and angle.
 
- Public Attributes inherited from optickaCore
Property name
 object name
 
Property comment
 comment
 
Property verbose
 verbose logging, subclasses must assign this. This is normally logical true/false
 
Property dateStamp
 clock() dateStamp set on construction
 
Property uuid
 universal ID
 
Property paths
 storage of various paths
 
Property fullName
 The fullName is the object name combined with its uuid and class name.
 

Protected Member Functions

function setRect (in me)
 setRect setRect makes the PsychRect based on the texture and screen values this is modified over parent method as gratings have slightly different requirements.
 
function calculateScale (in me, in ignoredArg, in ignoredArg)
 calculateScale Use an event to recalculate scale as get method is slower (called many more times), than an event which is only called on update
 
function calculatePhaseIncrement (in me, in ignoredArg, in ignoredArg)
 calculatePhaseIncrement Use an event to recalculate as get method is slower (called many more times), than an event which is only called on update
 
- Protected Member Functions inherited from baseStimulus
function addRuntimeProperties (in me)
 These are transient properties that specify actions during runtime.
 
function updateRuntimeProperties (in me)
 Update transient properties that specify actions during runtime.
 
function computePosition (in me)
 compute xFinal and yFinal (in pixels) taking startPosition, xPosition, yPosition and direction/angle into account
 
function setAnimationDelta (in me)
 
function setRect (in me)
 
function toStructure (in me, in tmp)
 Converts properties to a structure.
 
function removeTmpProperties (in me)
 Finds and removes dynamic properties.
 
function delete (in me)
 
- Protected Member Functions inherited from optickaCore
function parseArgs (in me, in args, in allowedProperties)
 Sets properties from a structure or normal arguments pairs, ignores invalid or non-allowed properties.
 
function addArgs (in me, in args)
 
function setPaths (in me)
 Sets properties from a structure or normal arguments pairs, ignores invalid or non-allowed properties.
 
function getFonts (in me)
 set paths for object
 
function toStructure (in me)
 Converts properties to a structure.
 
function getType (in me, in in)
 
function logOutput (in me, in in, in message, in override)
 Give a metaproperty return the likely property class.
 
function salutation (in me, in varargin)
 Prints messages dependent on verbosity.
 

Protected Attributes

Property sfCache
 
Property sfRecurse
 to stop a loop between set method and an event
 
Property allowedProperties
 allowed properties passed to object upon construction
 
Property ignoreProperties
 properties to not create transient copies of during setup phase
 
Property phaseCounter
 how many frames between phase reverses
 
Property maskValue
 mask value (radius for the procedural shader)
 
Property shader
 the raw shader, we can try to change colours.
 
- Protected Attributes inherited from baseStimulus
Property family
 the stimulus family (grating, dots etc.)
 
Property texture
 Our texture pointer for texture-based stimuli.
 
Property handles
 handles for the GUI
 
Property sM
 our screen manager
 
Property animator
 animation manager
 
Property screenVals
 screen settings generated by sM on setup
 
Property isSetup
 
Property isGUI
 is panel constructed?
 
Property dstRect
 initial screen rectangle position [LEFT TOP RIGHT BOTTOM]
 
Property mouseValid
 is mouse position within screen co-ordinates?
 
Property mouseX
 mouse X position
 
Property mouseY
 mouse Y position
 
Property delayTicks
 delay ticks to wait until display
 
Property offTicks
 ticks before stimulus turns off
 
Property inSetup
 are we setting up?
 
Property delta_
 delta cache
 
Property dX_
 dX cache
 
Property dY_
 dY cache
 
Property isInSetColour
 deal with interaction of colour and alpha
 
Property setLoop
 
Property ignorePropertiesBase
 Which properties to ignore cloning when making transient copies in setup.
 
Property ignorePropertiesUIBase
 Which properties to not draw in the UI panel.
 
- Protected Attributes inherited from optickaCore
Property cloning
 are we cloning this from another object
 
Property mversion
 Matlab version number, this is transient so it is not saved.
 
Property sansFont
 sans font
 
Property monoFont
 monoFont
 
Property className
 class name
 
Property savePrefix
 save prefix generated from clock time
 
Property fullName_
 cached full name
 

Additional Inherited Members

- Static Public Member Functions inherited from baseStimulus
static function d2r (in degrees)
 degrees2radians
 
static function r2d (in r)
 radians2degrees
 
static function findDistance (in x1, in y1, in x2, in y2)
 findDistance in X and Y coordinates
 
static function updatePosition (in delta, in angle)
 updatePosition returns dX and dY given an angle and delta
 
- Static Public Member Functions inherited from optickaCore
static function makeArgs (in args)
 Converts cell args to structure array.
 
static function addDefaults (in args, in defs)
 add default options to arg input
 
static function hasKey (in in, in key)
 check if a struct / object has a propery / field
 
static function getKeys (in device)
 PTB Get key presses, stops key bouncing.
 

Member Enumeration Documentation

◆ Events

Enumerator
changeScale 

triggered when changing size, so we can change sf etc to compensate

changePhaseIncrement 

triggered when changing tf or drift direction

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
154 if strcmp(fn{j},'reverseDirection');p.SetMethod = @set_reverseDirectionOut;end
155 if strcmp(fn{j},'size');p.SetMethod = @set_sizeOut;end
156 if strcmp(fn{j},'xPosition');p.SetMethod = @set_xPositionOut;end
157 if strcmp(fn{j},'yPosition');p.SetMethod = @set_yPositionOut;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'))
176 p=me.addprop('phaseIncrement');
177 end
178
179 if isempty(me.findprop('driftPhase'));p=me.addprop('driftPhase');p.Transient=true;end
180 if me.correctPhase
181 ps=me.calculatePhase;
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
189 switch length(me.aspectRatio)
190 case 1
191 me.res = round([me.gratingSize*me.aspectRatio me.gratingSize]);
192 case 2
193 me.res = round([me.gratingSize*me.aspectRatio(1) me.gratingSize*me.aspectRatio(2)]);
194 end
195 if max(me.res) > me.sM.screenVals.width %scale to be no larger than screen width
196 me.res = floor( me.res / (max(me.res) / me.sM.screenVals.width));
197 end
198
199 if me.mask == true
200 me.maskValue = floor((me.ppd*me.size))/2;
201 else
202 me.maskValue = [];
203 end
204
205 if me.phaseReverseTime > 0
206 me.phaseCounter = round(me.phaseReverseTime / me.sM.screenVals.ifi);
207 end
208
209 if isempty(me.baseColour)
210 me.baseColourOut = me.sM.backgroundColour;
211 me.baseColourOut(4) = me.alpha;
212 end
213
214 % this is a checkerboard shader
215 [me.texture, ~, me.shader] = CreateProceduralCheckerboard(me.sM.win, ...
216 me.res(1), me.res(2), me.maskValue);
217
218 me.inSetup = false; me.isSetup = true;
219 calculateScale(me);
220 computePosition(me);
221 setRect(me);
222
223 function set_sfOut(me,value)
224 if value <= 0; value = 0.01; end
225 me.sfCache = value;
226 me.sfOut = me.sfCache;
227 %fprintf('SET SFOut: %.2f | in: %.2f | scale: %.2f\n', me.sfOut, me.sfCache, me.scale);
228 end
229 function set_tfOut(me,value)
230 me.tfOut = value;
231 notify(me,'changePhaseIncrement');
232 end
233 function set_reverseDirectionOut(me,value)
234 me.reverseDirectionOut = value;
235 notify(me,'changePhaseIncrement');
236 end
237 function set_sizeOut(me,value)
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
242 function set_xPositionOut(me, value)
243 me.xPositionOut = value * me.ppd;
244 end
245 function set_yPositionOut(me,value)
246 me.yPositionOut = value*me.ppd;
247 end
248
249 end
250
251 % ===================================================================
252 %> @brief Update this stimulus object for display
253 %>
254 % ===================================================================
255 function update(me)
256 resetTicks(me);
257 if me.correctPhase
258 ps=me.calculatePhase;
259 me.driftPhase=me.phaseOut-ps;
260 else
261 me.driftPhase=me.phaseOut;
262 end
263 glUseProgram(me.shader);
264 if me.mask == true
265 me.maskValue = me.sizeOut/2;
266 else
267 me.maskValue = 0;
268 end
269 glUniform1f(glGetUniformLocation(me.shader, 'radius'), me.maskValue);
270 glUseProgram(0);
271 calculateScale(me);
272 computePosition(me);
273 setRect(me);
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
284 if ~exist('sf','var'); sf = me.specialFlags; end
285 if me.isVisible && me.tick >= me.delayTicks && me.tick < me.offTicks
286 Screen('DrawTexture', win, me.texture, [],me.mvRect,...
287 me.angleOut, [], [], me.baseColourOut, [], sf,...
288 [me.ppd, me.sfOut, me.contrastOut, me.driftPhase, ...
289 me.colourOut, me.colour2Out]);
290 me.drawTick = me.drawTick + 1;
291 end
292 if me.isVisible; me.tick = me.tick + 1; end
293 end
294
295 % ===================================================================
296 %> @brief Animate this object for runExperiment
297 %>
298 % ===================================================================
299 function animate(me)
300 if me.isVisible && me.tick >= me.delayTicks
301 if me.mouseOverride
303 if me.mouseValid
304 me.mvRect = CenterRectOnPointd(me.mvRect, me.mouseX, me.mouseY);
305 end
306 end
307 if me.doMotion
308 me.mvRect=OffsetRect(me.mvRect,me.dX_,me.dY_);
309 end
310 if me.doDrift
311 me.driftPhase = me.driftPhase + me.phaseIncrement;
312 %fprintf('Drift Phase: %.2f\n',me.driftPhase);
313 end
314 if mod(me.tick, me.phaseCounter) == 0
315 %tmp = me.colourOut;me.colourOut = me.colour2Out;me.colour2Out = tmp;
316 me.driftPhase = me.driftPhase + me.phaseOfReverse;
317 end
318 end
319 end
320
321 % ===================================================================
322 %> @brief Reset an structure for runExperiment
323 %>
324 %> @param rE runExperiment object for reference
325 %> @return stimulus structure.
326 % ===================================================================
327 function reset(me)
328 resetTicks(me);
329 if ~isempty(me.texture) && Screen(me.texture,'WindowKind') == -1
330 try Screen('Close',me.texture); end
331 end
332 me.texture=[];
333 me.shader=[];
334 if me.mask > 0
335 me.mask = true;
336 end
337 me.sfCache = me.sf;
338 me.maskValue = [];
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
348 me.sfCache = value;
349 me.sf = value;
350 me.salutation(['set sf: ' num2str(me.sf)],'Custom set method')
351 end
352
353 % ===================================================================
354 %> @brief SET Colour2 method
355 %> Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value colour
356 % ===================================================================
357 function set.colour2(me,value)
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 % ===================================================================
371 %> @brief SET baseColour method
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 % ===================================================================
395 function phase = calculatePhase(me)
396 phase = 0;
397 if me.correctPhase > 0
398 ppd = me.ppd;
399 size = (me.sizeOut/2); %divide by 2 to get the 0 point
400 sfTmp = (me.sfOut/me.scale)*me.ppd;
401 md = size / (ppd/sfTmp);
402 md=md-floor(md);
403 phase = (360*md);
404 end
405 end
406
407 end %---END PUBLIC METHODS---%
408
409
410 %=======================================================================
411 methods ( Access = protected ) %-------PROTECTED METHODS-----%
412 %=======================================================================
413
414 % ===================================================================
415 %> @brief setRect
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 % ===================================================================
420 function setRect(me)
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'))
433 me.dstRect=OffsetRect(me.dstRect,(me.xPosition)*me.ppd,(me.yPosition)*me.ppd);
434 else
435 me.dstRect=OffsetRect(me.dstRect,me.xPositionOut+(sx*me.ppd),me.yPositionOut+(sy*me.ppd));
436 end
437 end
438 me.mvRect=me.dstRect;
439 me.szPx = RectWidth(me.mvRect);
441 end
442
443
444 % ===================================================================
445 %> @brief calculateScale
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 % ===================================================================
449 function calculateScale(me,~,~)
450 me.scale = me.sizeOut/(me.size*me.ppd);
451 me.maskValue = me.sizeOut / 2;
452 if me.verbose;fprintf('Calculate SFOut: %.2f | in: %.2f | scale: %.2f | size: %.2f\n', me.sfOut, me.sfCache, me.scale, me.sizeOut);end
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 % ===================================================================
460 function calculatePhaseIncrement(me,~,~)
461 if ~isempty(me.findprop('tfOut'))
462 me.phaseIncrement = (me.tfOut * 360) * me.sM.screenVals.ifi;
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

Constructor & Destructor Documentation

◆ checkerboardStimulus()

function checkerboardStimulus::checkerboardStimulus ( in  varargin)

Class constructor.

More detailed description of what the constructor does.

Parameters
argsare passed as a structure of properties which is parsed.
Returns
instance of class.

Member Function Documentation

◆ animate()

function checkerboardStimulus::animate ( in  me)
virtual

Animate this object for runExperiment.

Reimplemented from baseStimulus.

◆ baseColour()

function set checkerboardStimulus::baseColour ( in  me,
in  value 
)

SET baseColour method Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value colour.

◆ calculatePhase()

function checkerboardStimulus::calculatePhase ( in  me)

calculate phase offset

◆ calculatePhaseIncrement()

function checkerboardStimulus::calculatePhaseIncrement ( in  me,
in  ignoredArg,
in  ignoredArg 
)
protected

calculatePhaseIncrement Use an event to recalculate as get method is slower (called many more times), than an event which is only called on update

◆ calculateScale()

function checkerboardStimulus::calculateScale ( in  me,
in  ignoredArg,
in  ignoredArg 
)
protected

calculateScale Use an event to recalculate scale as get method is slower (called many more times), than an event which is only called on update

◆ colour2()

function set checkerboardStimulus::colour2 ( in  me,
in  value 
)

SET Colour2 method Allow 1 (R=G=B) 3 (RGB) or 4 (RGBA) value colour.

◆ draw()

function checkerboardStimulus::draw ( in  me,
in  win,
in  sf 
)

Draw this stimulus object for display.

Parameters
win– optional [i.e. offscreen] window pointer
sf- optional special Flags override

◆ reset()

function checkerboardStimulus::reset ( in  me)
virtual

Reset an structure for runExperiment.

Parameters
rErunExperiment object for reference
Returns
stimulus structure.

Reimplemented from baseStimulus.

◆ set_reverseDirectionOut()

function checkerboardStimulus::set_reverseDirectionOut ( in  me,
in  value 
)

◆ set_sfOut()

function checkerboardStimulus::set_sfOut ( in  me,
in  value 
)

◆ set_sizeOut()

function checkerboardStimulus::set_sizeOut ( in  me,
in  value 
)

◆ set_tfOut()

function checkerboardStimulus::set_tfOut ( in  me,
in  value 
)

◆ set_xPositionOut()

function checkerboardStimulus::set_xPositionOut ( in  me,
in  value 
)

◆ set_yPositionOut()

function checkerboardStimulus::set_yPositionOut ( in  me,
in  value 
)

◆ setRect()

function checkerboardStimulus::setRect ( in  me)
protected

setRect setRect makes the PsychRect based on the texture and screen values this is modified over parent method as gratings have slightly different requirements.

◆ setup()

function checkerboardStimulus::setup ( in  me,
in  sM 
)

Setup this object in preparation for use When displaying a stimulus object, the main properties that are to be modified are copied into cache copies of the property, both to convert from visual description (c/d, Hz, degrees) to computer metrics, and to be animated and modified as independant variables. So xPosition is copied to xPositionOut and converted from degrees to pixels. The animation and drawing functions use these modified properties, and when they are updated, for example to change to a new xPosition, internal methods ensure reconversion and update any dependent properties. This method initialises the object with all the cache properties for display.

Parameters
sMscreenManager object to use

◆ sf()

function set checkerboardStimulus::sf ( in  me,
in  value 
)

sf Set method

◆ update()

function checkerboardStimulus::update ( in  me)
virtual

Update this stimulus object for display.

Reimplemented from baseStimulus.

Member Data Documentation

◆ allowedProperties

Property checkerboardStimulus::allowedProperties
protected

allowed properties passed to object upon construction

◆ aspectRatio

Property checkerboardStimulus::aspectRatio

aspect ratio of the grating

◆ baseColour

Property checkerboardStimulus::baseColour

base colour from which colour and colour2 are blended via contrast value if empty [default], uses the background colour from screenManager

◆ colour2

Property checkerboardStimulus::colour2

second colour of the checkerboard

◆ contrast

Property checkerboardStimulus::contrast

contrast of grating (technically the contrast from the baseColour)

◆ correctPhase

Property checkerboardStimulus::correctPhase

Do we need to correct the phase to be relative to center not edge? This enables centre surround stimuli are phase matched, and if we enlarge a grating object its phase stays identical at the centre of the object (where we would imagine our RF)

◆ direction

Property checkerboardStimulus::direction

the direction of the grating object if moving.

◆ family

Property checkerboardStimulus::family

◆ ignoreProperties

Property checkerboardStimulus::ignoreProperties
protected

properties to not create transient copies of during setup phase

◆ mask

Property checkerboardStimulus::mask

use a circular mask for the grating (default = true).

◆ maskValue

Property checkerboardStimulus::maskValue
protected

mask value (radius for the procedural shader)

◆ phase

Property checkerboardStimulus::phase

phase of grating

◆ phaseCounter

Property checkerboardStimulus::phaseCounter
protected

how many frames between phase reverses

◆ phaseIncrement

Property checkerboardStimulus::phaseIncrement

the phase amount we need to add for each frame of animation

◆ phaseOfReverse

Property checkerboardStimulus::phaseOfReverse

What phase to use for reverse?

◆ phaseReverseTime

Property checkerboardStimulus::phaseReverseTime

Reverse phase of grating X times per second? Useful with a static grating for linearity testing.

◆ reverseDirection

Property checkerboardStimulus::reverseDirection

direction of the drift; default = false means drift left>right when angle is 0deg.

◆ rotateTexture

Property checkerboardStimulus::rotateTexture

rotate the grating patch (false) or the grating texture within the patch (default = true)?

◆ scale

Property checkerboardStimulus::scale

scale is used when changing size as an independent variable to keep sf accurate

◆ sf

Property checkerboardStimulus::sf

spatial frequency of the checkerboard

◆ sfCache

Property checkerboardStimulus::sfCache
protected

as get methods are slow, we cache sf, then recalculate sf whenever changeScale event is called

◆ sfRecurse

Property checkerboardStimulus::sfRecurse
protected

to stop a loop between set method and an event

◆ shader

Property checkerboardStimulus::shader
protected

the raw shader, we can try to change colours.

◆ specialFlags

Property checkerboardStimulus::specialFlags

special flags passed to drawing functions

◆ tf

Property checkerboardStimulus::tf

temporal frequency of the checkerboard

◆ type

Property checkerboardStimulus::type

family type


The documentation for this class was generated from the following file: