Aperture
¶Stimulus class to restrict a stimulus visibility area to a basic shape or list of vertices. This is a lazy-imported class, therefore import using full path from psychopy.visual.aperture import Aperture when inheriting from it.
|
Restrict a stimulus visibility area to a basic shape or list of vertices. |
Set the size (diameter) of the Aperture. |
|
Set the pos (centre) of the Aperture. |
|
Set the orientation of the Aperture. |
|
True / False. |
|
The name (str) of the object to be using during logged messages about this stim. |
|
Whether every change in this stimulus should be auto logged. |
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.
Supported shapes:
‘square’, ‘triangle’, ‘circle’ or None: a polygon with appropriate nVerts will be used (120 for ‘circle’)
integer: a polygon with that many vertices will be used
list or numpy array (Nx2): it will be used directly as the vertices to a
ShapeStim
a filename then it will be used to load and image as a
ImageStim
. Note that transparent parts
in the image (e.g. in a PNG file) will not be included in the mask
shape. The color of the image will be ignored.
See demos/stimuli/aperture.py for example usage
2011, Yuri Spitsyn 2011, Jon Peirce added units options, Jeremy Gray added shape & orientation 2014, Jeremy Gray added .contains() option 2015, Thomas Emmerling added ImageStim option
Internal method to rebuild the shape - shouldn’t be called by the user. You have to explicitly turn resetting off by setting self._needReset = False
Sets Stim.verticesPix and ._borderPix from pos, size, ori, flipVert, flipHoriz
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 auto logged.
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 stimulus’ border.
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 either by its border attribute (if one defined), or its vertices attribute if there is no .border. 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 demos: shapeContains.py See Coder demos: shapeContains.py
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.
True / False. Set to true to invert the aperture. A non-inverted aperture masks everything BUT the selected shape. An inverted aperture masks the selected shape.
NB. The Aperture is not inverted by default, when created.
The name (str) 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 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 logging 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