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

Class DotStim

source code


This stimulus class defines a field of dots with an update rule that determines how they change on every call to the .draw() method.

This standard class can be used to generate a wide variety of dot motion types. For a review of possible types and their pros and cons see Scase, Braddick & Raymond (1996). All six possible motions they describe can be generated with appropriate choices of the signalDots (which determines whether signal dots are the 'same' or 'different' from frame to frame), noiseDots (which determines the locations of the noise dots on each frame) and the dotLife (which determines for how many frames the dot will continue before being regenerated).

'Movshon'-type noise uses a random position, rather than random direction, for the noise dots and the signal dots are distinct (noiseDots='different'). This has the disadvantage that the noise dots not only have a random direction but also a random speed (so differ in two ways from the signal dots). The default option for DotStim is that the dots follow a random walk, with the dot and noise elements being randomised each frame. This provides greater certainty that individual dots cannot be used to determine the motion direction.

When dots go out of bounds or reach the end of their life they are given a new random position. As a result, to prevent inhomogeneities arising in the dots distribution across the field, a limitted lifetime dot is strongly recommended.

If further customisation is required, then the DotStim should be subclassed and its _update_dotsXY and _newDotsXY methods overridden.

Instance Methods
 
__init__(self, win, units='', nDots=1, coherence=0.5, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='sqr', dotSize=2.0, dotLife=3, dir=0.0, speed=0.5, rgb=None, color=(1.0, 1.0, 1.0), colorSpace='rgb', opacity=1.0, depth=0, element=None, signalDots='different', noiseDots='position')
:Parameters:
source code
 
set(self, attrib, val, op='')
DotStim.set() is obselete and may not be supported in future versions of PsychoPy.
source code
 
setPos(self, newPos=None, operation='', units=None)
Obselete - users should use setFieldPos or instead of setPos
source code
 
setFieldPos(self, val, op='') source code
 
setFieldCoherence(self, val, op='')
Change the coherence (%) of the DotStim.
source code
 
setDir(self, val, op='')
Change the direction of the signal dots (units in degrees)
source code
 
setSpeed(self, val, op='')
Change the speed of the dots (in stimulus units per second)
source code
 
draw(self, win=None)
Draw the stimulus in its relevant window.
source code

Inherited from _BaseVisualStim: setColor, setContr, setDKL, setDepth, setLMS, setOpacity, setOri, setRGB, setSize, setUseShaders

Instance Variables
  depth
initialise the dots themselves - give them all random dir and then fix the first n in the array to have the direction specified
Method Details

__init__(self, win, units='', nDots=1, coherence=0.5, fieldPos=(0.0, 0.0), fieldSize=(1.0, 1.0), fieldShape='sqr', dotSize=2.0, dotLife=3, dir=0.0, speed=0.5, rgb=None, color=(1.0, 1.0, 1.0), colorSpace='rgb', opacity=1.0, depth=0, element=None, signalDots='different', noiseDots='position')
(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.
    nDots : int
        number of dots to be generated
    fieldPos : (x,y) or [x,y]
        specifying the location of the centre of the stimulus.
    fieldSize : a single value, specifying the diameter of the field
        Sizes can be negative and can extend beyond the window.
    fieldShape : *'sqr'* or 'circle' 
        Defines the envelope used to present the dots
    dotSize
        specified in pixels (overridden if `element` is specified)
    dotLife : int
        Number of frames each dot lives for (default=3, -1=infinite)
    dir : float (degrees)
        direction of the coherent dots
    speed : float
        speed of the dots (in *units*/frame)            
    signalDots : 'same' or 'different'
        If 'same' then the chosen signal dots remain the same on each frame.
        If 'different' they are randomly chosen each frame. This paramater
        corresponds to Scase et al's (1996) categories of RDK.            
    noiseDots : 'position','direction' or 'walk'
        Determines the behaviour of the noise dots, taken directly from 
        Scase et al's (1996) categories. For 'position', noise dots take a
        random position every frame. For 'direction' noise dots follow a 
        random, but constant direction. For 'walk' noise dots vary their
        direction every frame, but keep a constant speed.                            
    rgb : (r,g,b) or [r,g,b] or a single intensity value 
        or a single value (which will be applied to all guns).
        RGB vals are applied to simple textures and to greyscale
        image files but not to RGB images.
        **NB** units range -1:1 (so 0.0 is GREY). See :ref:`rgb` for further info.
    opacity : float
        1.0 is opaque, 0.0 is transparent
    depth : 0,
        This can be used to choose which
        stimulus overlays which. (more negative values are nearer).
        At present the window does not do perspective rendering
        but could do if that's really useful(?!)
    element : *None* or a visual stimulus object
        This can be any object that has a ``.draw()`` method and a
        ``.setPos([x,y])`` method (e.g. a PatchStim, TextStim...)!!
        See `ElementArrayStim` for a faster implementation of this idea.
    

Overrides: _BaseVisualStim.__init__

set(self, attrib, val, op='')

source code 
DotStim.set() is obselete and may not be supported in future versions of PsychoPy. Use the specific method for each parameter instead (e.g. setFieldPos(), setCoherence()...)

setPos(self, newPos=None, operation='', units=None)

source code 
Obselete - users should use setFieldPos or instead of setPos
Overrides: _BaseVisualStim.setPos

setFieldCoherence(self, val, op='')

source code 
Change the coherence (%) of the DotStim. This will be rounded according to the number of dots in the stimulus.

draw(self, win=None)

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