Package psychopy :: Module visual :: Class ElementArrayStim
[frames] | no frames]

Class ElementArrayStim

source code

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.
Instance Methods
 
__init__(self, win, units=None, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='circle', nElements=100, sizes=2.0, xys=None, rgbs=(1.0, 1.0, 1.0), opacities=1.0, depths=0, fieldDepth=0, oris=0, sfs=1.0, contrs=1, phases=0, elementTex='sin', elementMask='gauss', texRes=48)
:Parameters:
source code
 
setXYs(self, value=None, operation='')
Set the xy values of the element centres (relative to the centre of the field).
source code
 
setOris(self, value, operation='')
Set the orientation for each element.
source code
 
setSfs(self, value, operation='')
Set the spatial frequency for each element.
source code
 
setOpacities(self, value, operation='')
Set the opacity for each element.
source code
 
setSizes(self, value, operation='')
Set the size for each element.
source code
 
setPhases(self, value, operation='')
Set the phase for each element.
source code
 
setRgbs(self, value, operation='')
Set the rgb for each element.
source code
 
setContrs(self, value, operation='')
Set the contrast for each element.
source code
 
setFieldPos(self, value, operation='')
Set the centre of the array (X,Y)
source code
 
setPos(self, newPos=None, operation='', units=None)
Obselete - users should use setFieldPos or instead of setPos
source code
 
setFieldSize(self, value, operation='')
Set the size of the array on the screen (will override current XY positions of the elements)
source code
 
draw(self)
Draw the stimulus in its relevant window.
source code
 
updateElementVertices(self) source code
 
updataElementColors(self)
Create a new array of self._RGBAs
source code
 
updataTextureCoords(self)
Create a new array of self._maskCoords
source code
 
setTex(self, value)
Change the texture (all elements have the same base texture).
source code
 
setMask(self, value)
Change the mask (all elements have the same mask).
source code
 
__del__(self) source code
 
clearTextures(self)
Clear the textures associated with the given stimulus.
source code
Method Details

__init__(self, win, units=None, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='circle', nElements=100, sizes=2.0, xys=None, rgbs=(1.0, 1.0, 1.0), opacities=1.0, depths=0, fieldDepth=0, oris=0, sfs=1.0, contrs=1, phases=0, elementTex='sin', elementMask='gauss', texRes=48)
(Constructor)

source code 

:Parameters:

    win :
        a :class:`~psychopy.visual.Window` object (required)
                         
    units : **None**, 'norm', 'cm', 'deg' or 'pix'  
        If None then the current units of the :class:`~psychopy.visual.Window` will be used. 
        See :ref:`units` for explanation of other options.
    
    fieldPos : 
        The centre of the array of elements
                        
    fieldSize : 
        The size of the array of elements (this will be overridden by setting explicit xy positions for the elements)
    
    fieldShape : 
        The shape of the array ('circle' or 'sqr')        
    
    nElements : 
        number of elements in the array     
       
    sizes : 
        an array of sizes Nx1, Nx2 or a single value      
      
    xys : 
        the xy positions of the elements, relative to the field centre (fieldPos)   
         
    rgbs : 
        specifying the color(s) of the elements. 
        Should be Nx1 (different greys), Nx3 (different colors) or 1x3 (for a single color)
    
    opacities : 
        the opacity of each element (Nx1 or a single value)
    
    depths : 
        the depths of the elements (Nx1), relative the overall depth of the field (fieldDepth)
    
    fieldDepth : 
        the depth of the field (will be added to the depths of the elements)
    
    oris : 
        the orientations of the elements (Nx1 or a single value)
    
    sfs : 
        the spatial frequencies of the elements (Nx1, Nx2 or a single value)
    
    contrs : 
        the contrasts of the elements, ranging -1 to +1 (Nx1 or a single value)
    
    phases : 
        the spatial phase of the texture on the stimulus (Nx1 or a single value)
    
    elementTex : 
        the texture, to be used by all elements (e.g. 'sin', 'sqr',.. , 'myTexture.tif', numpy.ones([48,48]))
    
    elementMask : 
        the mask, to be used by all elements (e.g. 'circle', 'gauss',.. , 'myTexture.tif', numpy.ones([48,48]))
    
    texRes : 
        the number of pixels in the textures (overridden if an array or image is provided)                       

setXYs(self, value=None, operation='')

source code 

Set the xy values of the element centres (relative to the centre of the field). Values should be:

  • None
  • an array/list of Nx2 coordinates.

If value is None then the xy positions will be generated automatically, based on the fieldSize and fieldPos. In this case opacity will also be overridden by this function (it is used to make elements outside the field invisible.

setOris(self, value, operation='')

source code 
Set the orientation for each element. Should either be a single value or an Nx1 array/list

setSfs(self, value, operation='')

source code 

Set the spatial frequency for each element. Should either be:

  • a single value
  • an Nx1 array/list
  • an Nx2 array/list (spatial frequency of the element in X and Y).

If the units for the stimulus are 'pix' or 'norm' then the units of sf are cycles per stimulus width. For units of 'deg' or 'cm' the units are c/cm or c/deg respectively.

setOpacities(self, value, operation='')

source code 
Set the opacity for each element. Should either be a single value or an Nx1 array/list

setSizes(self, value, operation='')

source code 

Set the size for each element. Should either be:

  • a single value
  • an Nx1 array/list
  • an Nx2 array/list

setPhases(self, value, operation='')

source code 

Set the phase for each element. Should either be:

  • a single value
  • an Nx1 array/list
  • an Nx2 array/list (for separate X and Y phase)

setRgbs(self, value, operation='')

source code 

Set the rgb for each element. Should either be:

  • a single value
  • an Nx1 array/list
  • an Nx3 array/list

setContrs(self, value, operation='')

source code 

Set the contrast for each element. Should either be:

  • a single value
  • an Nx1 array/list

draw(self)

source code 
Draw the stimulus in its relevant window. You must call this method after every MyWin.update() if you want the stimulus to appear on that frame and then update the screen again.

setTex(self, value)

source code 
Change the texture (all elements have the same base texture). Avoid this during time-critical points in your script. Uploading new textures to the graphics card can be time-consuming.

setMask(self, value)

source code 
Change the mask (all elements have the same mask). Avoid doing this during time-critical points in your script. Uploading new textures to the graphics card can be time-consuming.

clearTextures(self)

source code 
Clear the textures associated with the given stimulus. As of v1.61.00 this is called automatically during garbage collection of your stimulus, so doesn't need calling explicitly by the user.