visigoth.stimuli.ElementArray¶
- class visigoth.stimuli.ElementArray(win, units=None, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='circle', nElements=100, sizes=2.0, xys=None, rgbs=None, colors=(1.0, 1.0, 1.0), colorSpace='rgb', opacities=None, depths=0, fieldDepth=0, oris=0, sfs=1.0, contrs=1, phases=0, elementTex='sin', elementMask='gauss', texRes=48, interpolate=True, name=None, autoLog=False, maskParams=None, pedestal=None)[source]¶
Field of elements that are independently controlled and rapidly drawn.
This stimulus class defines a field of elements whose behaviour can be independently controlled. Suitable for creating ‘global form’ stimuli or more detailed random dot stimuli.
This stimulus can draw thousands of elements without dropping a frame, but in order to achieve this performance, uses several OpenGL extensions only available on modern graphics cards (supporting OpenGL2.0). See the ElementArray demo.
- __init__(win, units=None, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='circle', nElements=100, sizes=2.0, xys=None, rgbs=None, colors=(1.0, 1.0, 1.0), colorSpace='rgb', opacities=None, depths=0, fieldDepth=0, oris=0, sfs=1.0, contrs=1, phases=0, elementTex='sin', elementMask='gauss', texRes=48, interpolate=True, name=None, autoLog=False, maskParams=None, pedestal=None)[source]¶
- Parameters
- win :
a
Window
object (required)- unitsNone, ‘height’, ‘norm’, ‘cm’, ‘deg’ or ‘pix’
If None then the current units of the
Window
will be used. See units for explanation of other options.- nElements :
number of elements in the array.
Methods
__init__
(win[, units, fieldPos, fieldSize, …])- Parameters
clearTextures
()Clear all textures associated with the stimulus.
draw
([win])Draw the stimulus in its relevant window.
setAutoDraw
(value[, log])Sets autoDraw.
setAutoLog
([value, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setBackColor
(color[, colorSpace, operation, log])setBorderColor
(color[, colorSpace, …])Hard setter for fillColor, allows suppression of the log message, simultaneous colorSpace setting and calls update methods.
setColor
(color[, colorSpace, operation, log])setColors
(colors[, colorSpace, operation, log])See
color
for more info on the color parameter andcolorSpace
for more info in the colorSpace parameter.setContrast
(newContrast[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
setContrs
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setFieldPos
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setFieldSize
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setFillColor
(color[, colorSpace, operation, log])Hard setter for fillColor, allows suppression of the log message, simultaneous colorSpace setting and calls update methods.
setForeColor
(color[, colorSpace, operation, log])Hard setter for foreColor, allows suppression of the log message, simultaneous colorSpace setting and calls update methods.
setLineColor
(color[, colorSpace, operation, log])setMask
(value[, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setOpacities
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setOris
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setPhases
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setPos
([newPos, operation, units, log])Obsolete - users should use setFieldPos or instead of setPos.
setRgbs
(value[, operation])DEPRECATED (as of v1.74.00).
setSfs
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setSizes
(value[, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setTex
(value[, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
setXYs
([value, operation, log])Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message.
updateColors
()Placeholder method to update colours when set externally, for example updating the pallette attribute of a textbox
updateElementColors
()Create a new array of self._RGBAs based on self.rgbs.
updateTextureCoords
()Create a new array of self._maskCoords
Attributes
autoDraw
Determines whether the stimulus should be automatically drawn on every frame flip.
autoLog
Whether every change in this stimulus should be auto logged.
backColor
Alternative way of setting fillColor
borderColor
color
Alternative way of setting foreColor.
colorSpace
The name of the color space currently being used
colors
Specifying the color(s) of the elements.
contrast
A value that is simply multiplied by the color.
contrs
The contrasts of the elements, ranging -1 to +1.
depth
(Nx1) list/array of ints.
elementMask
The mask, to be used by all elements (e.g.
elementTex
The texture, to be used by all elements (e.g.
fieldDepth
Int.
fieldPos
x,y-pair.
fieldShape
The shape of the array (‘circle’ or ‘sqr’).
fieldSize
Scalar or x,y-pair.
fillColor
Set the fill color for the shape.
foreColor
Foreground color of the stimulus
interpolate
Whether to interpolate (linearly) the texture in the stimulus.
lineColor
Alternative way of setting borderColor.
mask
The alpha mask (forming the shape of the image).
maskParams
Various types of input.
name
The name (str) of the object to be using during logged messages about this stim.
opacities
Set the opacity for each element.
opacity
oris
(Nx1 or a single value) The orientations of the elements.
pedestal_contrs
Stimulus contrast, accounting for pedestal
phases
The spatial phase of the texture on each element.
sfs
The spatial frequency for each element.
sizes
Set the size for each element.
texRes
Power-of-two int.
xys
The xy positions of the elements centres, relative to the field centre.