Restrict a stimulus visibility area to a basic shape or list of vertices.
When enabled, any drawing commands will only operate on pixels within the Aperture. Once disabled, subsequent draw operations affect the whole screen as usual.
If shape is ‘square’ or ‘triangle’ then that is what will be used (obviously) If shape is ‘circle’ or None then a polygon with nVerts will be used (120 for a rough circle) If shape is a list or numpy array (Nx2) then it will be used directly as the vertices to a ShapeStim
See demos/stimuli/aperture.py for example usage
Author: | 2011, Yuri Spitsyn 2011, Jon Peirce added units options, Jeremy Gray added shape & orientation 2014, Jeremy Gray added .contains() option |
---|
Determines whether the stimulus should be automatically drawn on every frame flip.
Value should be: True or False. You do NOT need to set this on every frame flip!
Whether every change in this stimulus should be logged automatically
Value should be: True or False. Set to False if your stimulus is updating frequently (e.g. updating its position every frame) and you want to avoid swamping the log file with messages that aren’t likely to be useful.
Returns True if a point x,y is inside the extent of the stimulus.
two separate args, x and y
one arg (list, tuple or array) containing two vals (x,y)
as a Mouse.
Returns True if the point is within the area defined by vertices. This method handles complex shapes, including concavities and self-crossings.
Note that, if your stimulus uses a mask (such as a Gaussian) then this is not accounted for by the contains method; the extent of the stimulus is determined purely by the size, position (pos), and orientation (ori) settings (and by the vertices for shape stimuli).
See coder demo, shapeContains.py
Use Aperture.enabled = False instead.
Use Aperture.enabled = True instead.
True / False. Enable or disable the aperture. Determines whether it is used in future drawing operations.
NB. The Aperture is enabled by default, when created.
String or None. The name of the object to be using during logged messages about this stim. If you have multiple stimuli in your experiment this really helps to make sense of log files!
If name = None your stimulus will be called “unnamed <type>”, e.g. visual.TextStim(win) will be called “unnamed TextStim” in the logs.
Set the orientation of the Aperture.
This essentially controls a ShapeStim so see documentation for ShapeStim.ori.
Operations supported here as well as ShapeStim.
Use setOri() if you want to control logging and resetting.
Returns True if this stimulus intersects another one.
If polygon is another stimulus instance, then the vertices and location of that stimulus will be used as the polygon. Overlap detection is typically very good, but it can fail with very pointy shapes in a crossed-swords configuration.
Note that, if your stimulus uses a mask (such as a Gaussian blob) then this is not accounted for by the overlaps method; the extent of the stimulus is determined purely by the size, pos, and orientation settings (and by the vertices for shape stimuli).
See coder demo, shapeContains.py
Set the pos (centre) of the Aperture. Operations supported.
This essentially controls a ShapeStim so see documentation for ShapeStim.pos.
Operations supported here as well as ShapeStim.
Use setPos() if you want to control logging and resetting.
The position of the aperture in pixels
Sets autoDraw. Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Set the size (diameter) of the Aperture.
This essentially controls a ShapeStim so see documentation for ShapeStim.size.
Operations supported here as well as ShapeStim.
Use setSize() if you want to control 0logging and resetting.
The size of the aperture in pixels
This determines the coordinates of the vertices for the current stimulus in pixels, accounting for size, ori, pos and units