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
Windowobject (required)- unitsNone, ‘height’, ‘norm’, ‘cm’, ‘deg’ or ‘pix’
If None then the current units of the
Windowwill 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
colorfor more info on the color parameter andcolorSpacefor 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
autoDrawDetermines whether the stimulus should be automatically drawn on every frame flip.
autoLogWhether every change in this stimulus should be auto logged.
backColorAlternative way of setting fillColor
borderColorcolorAlternative way of setting foreColor.
colorSpaceThe name of the color space currently being used
colorsSpecifying the color(s) of the elements.
contrastA value that is simply multiplied by the color.
contrsThe contrasts of the elements, ranging -1 to +1.
depth(Nx1) list/array of ints.
elementMaskThe mask, to be used by all elements (e.g.
elementTexThe texture, to be used by all elements (e.g.
fieldDepthInt.
fieldPosx,y-pair.
fieldShapeThe shape of the array (‘circle’ or ‘sqr’).
fieldSizeScalar or x,y-pair.
fillColorSet the fill color for the shape.
foreColorForeground color of the stimulus
interpolateWhether to interpolate (linearly) the texture in the stimulus.
lineColorAlternative way of setting borderColor.
maskThe alpha mask (forming the shape of the image).
maskParamsVarious types of input.
nameThe name (str) of the object to be using during logged messages about this stim.
opacitiesSet the opacity for each element.
opacityoris(Nx1 or a single value) The orientations of the elements.
pedestal_contrsStimulus contrast, accounting for pedestal
phasesThe spatial phase of the texture on each element.
sfsThe spatial frequency for each element.
sizesSet the size for each element.
texResPower-of-two int.
xysThe xy positions of the elements centres, relative to the field centre.