RadialStim(win[, tex, mask, units, pos, ...]) | Stimulus object for drawing radial stimuli, like an annulus, a rotating wedge, a checkerboard etc... |
RadialStim.win | The Window object in which the stimulus will be rendered by default. |
RadialStim.tex | Texture to used on the stimulus as a grating (aka carrier) |
RadialStim.mask | The alpha mask that forms the shape of the resulting image |
RadialStim.units | None, ‘norm’, ‘cm’, ‘deg’, ‘degFlat’, ‘degFlatPos’, or ‘pix’ |
RadialStim.pos | The position of the center of the stimulus in the stimulus units |
RadialStim.ori | The orientation of the stimulus (in degrees). |
RadialStim.size | The size (width, height) of the stimulus in the stimulus units |
RadialStim.contrast | A value that is simply multiplied by the color |
RadialStim.color | Color of the stimulus |
RadialStim.colorSpace | The name of the color space currently being used (for numeric colors) |
RadialStim.opacity | Determines how visible the stimulus is relative to background |
RadialStim.interpolate | |
RadialStim.setAngularCycles(value[, ...]) | Usually you can use ‘stim.attribute = value’ syntax instead, |
RadialStim.setAngularPhase(value[, ...]) | Usually you can use ‘stim.attribute = value’ syntax instead, |
RadialStim.setRadialCycles(value[, ...]) | Usually you can use ‘stim.attribute = value’ syntax instead, |
RadialStim.setRadialPhase(value[, ...]) | Usually you can use ‘stim.attribute = value’ syntax instead, |
RadialStim.name | String or None. |
RadialStim.autoLog | Whether every change in this stimulus should be logged automatically |
RadialStim.draw([win]) | Draw the stimulus in its relevant window. |
RadialStim.autoDraw | Determines whether the stimulus should be automatically drawn on every frame flip. |
RadialStim.clearTextures() | Clear all textures associated with the stimulus. |
Stimulus object for drawing radial stimuli, like an annulus, a rotating wedge, a checkerboard etc...
Ideal for fMRI retinotopy stimuli!
Many of the capabilities are built on top of the GratingStim.
This stimulus is still relatively new and I’m finding occasional gliches. it also takes longer to draw than a typical GratingStim, so not recommended for tasks where high frame rates are needed.
Float (but Int is prettiest). Set the number of cycles going around the stimulus. i.e. it controls the number of ‘spokes’.
Operations supported.
Float. Set the angular phase (like orientation) of the texture (wraps 0-1).
This is akin to setting the orientation of the texture around the stimulus in radians. If possible, it is more efficient to rotate the stimulus using its ori setting instead.
Operations supported.
The number of triangles used to make the sti.
Operations supported.
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 logged automatically
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.
Clear all textures associated with the 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.
Color of the stimulus
string: to specify a Colors by name. Any of the standard html/X11 color names <http://www.w3schools.com/html/html_colornames.asp> can be used.
these, operations are supported.
When color is specified using numbers, it is interpreted with respect to the stimulus’ current colorSpace. If color is given as a single value (scalar) then this will be applied to all 3 channels.
Operations work as normal for all numeric colorSpaces (e.g. ‘rgb’, ‘hsv’ and ‘rgb255’) but not for strings, like named and hex. For example, assuming that colorSpace=’rgb’:
stim.color += [1, 1, 1] # increment all guns by 1 value
stim.color *= -1 # multiply the color by -1 (which in this space inverts the contrast)
stim.color *= [0.5, 0, 1] # decrease red, remove green, keep blue
You can use setColor if you want to set color and colorSpace in one line. These two are equivalent:
stim.setColor((0, 128, 255), 'rgb255')
# ... is equivalent to
stim.colorSpace = 'rgb255'
stim.color = (0, 128, 255)
The name of the color space currently being used (for numeric colors)
Value should be: a string or None
For strings and hex values this is not needed. If None the default colorSpace for the stimulus is used (defined during initialisation).
Please note that changing colorSpace does not change stimulus parameters. Thus you usually want to specify colorSpace before setting the color. Example:
# A light green text
stim = visual.TextStim(win, 'Color me!', color=(0, 1, 0), colorSpace='rgb')
# An almost-black text
stim.colorSpace = 'rgb255'
# Make it light green again
stim.color = (128, 255, 128)
Returns True if a point x,y is inside the extent of the stimulus.
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 by vertices. 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 demo, shapeContains.py
A value that is simply multiplied by the color
Set the contrast of the stimulus, i.e. scales how far the stimulus deviates from the middle grey. You can also use the stimulus opacity to control contrast, but that cannot be negative.
Examples:
stim.contrast = 1.0 # unchanged contrast
stim.contrast = 0.5 # decrease contrast
stim.contrast = 0.0 # uniform, no contrast
stim.contrast = -0.5 # slightly inverted
stim.contrast = -1.0 # totally inverted
Setting contrast outside range -1 to 1 is permitted, but may produce strange results if color values exceeds the monitor limits.:
stim.contrast = 1.2 # increases contrast
stim.contrast = -1.2 # inverts with increased contrast
DEPRECATED. Depth is now controlled simply by drawing order.
Draw the stimulus in its relevant window. You must call this method after every win.flip() if you want the stimulus to appear on that frame and then update the screen again.
If win is specified then override the normal window of this stimulus.
The alpha mask that forms the shape of the resulting image
Value should one of:
- ‘circle’, ‘gauss’, ‘raisedCos’, None (resets to default)
- or the name of an image file (most formats supported)
- or a numpy array (1xN) ranging -1:1
Note that the mask for RadialStim is somewhat different to the mask for ImageStim. For RadialStim it is a 1D array specifying the luminance profile extending outwards from the center of the stimulus, rather than a 2D array
Various types of input. Default to None. This is used to pass additional parameters to the mask if those are needed.
For ‘gauss’ mask, pass dict {‘sd’: 5} to control standard deviation.
- For the ‘raisedCos’ mask, pass a dict: {‘fringeWidth’:0.2},
where ‘fringeWidth’ is a parameter (float, 0-1), determining the proportion of the patch that will be blurred by the raised cosine edge.
String or None. The name 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.
Determines how visible the stimulus is relative to background
The value should be a single float ranging 1.0 (opaque) to 0.0 (transparent). Operations are supported. Precisely how this is used depends on the Blend Mode.
The orientation of the stimulus (in degrees).
Should be a single value (scalar). Operations are supported.
Orientation convention is like a clock: 0 is vertical, and positive values rotate clockwise. Beyond 360 and below zero values wrap appropriately.
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
Phase of the stimulus in each dimension of the texture.
Should be an x,y-pair or scalar
NB phase has modulus 1 (rather than 360 or 2*pi) This is a little unconventional but has the nice effect that setting phase=t*n drifts a stimulus at n Hz
The position of the center of the stimulus in the stimulus units
value should be an x,y-pair. Operations are also supported.
Example:
stim.pos = (0.5, 0) # Set slightly to the right of center
stim.pos += (0.5, -1) # Increment pos rightwards and upwards. Is now (1.0, -1.0)
stim.pos *= 0.2 # Move stim towards the center. Is now (0.2, -0.2)
Tip: If you need the position of stim in pixels, you can obtain it like this:
from psychopy.tools.monitorunittools import posToPix posPix = posToPix(stim)
Float (but Int is prettiest). Set the number of texture cycles from centre to periphery, i.e. it controls the number of ‘rings’.
Operations supported.
Float. Set the radial phase of the texture (wraps 0-1). This is the phase of the texture from the centre to the perimeter of the stimulus (in radians). Can be used to drift concentric rings out/inwards.
Operations supported.
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
Sets autoDraw. 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 and/or set colorSpace simultaneously.
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
DEPRECATED since v1.60.05: Please use the color attribute
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
DEPRECATED since v1.60.05: Please use the color attribute
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
DEPRECATED. Use ‘stim.parameter = value’ syntax instead
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
DEPRECATED since v1.60.05: Please use the color attribute
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
DEPRECATED. Use ‘stim.parameter = value’ syntax instead
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
DEPRECATED. Use ‘stim.parameter = value’ syntax instead
Usually you can use ‘stim.attribute = value’ syntax instead, but use this method if you need to suppress the log message
Spatial frequency of the grating texture
Should be a x,y-pair or scalar or None. If units == ‘deg’ or ‘cm’ units are in cycles per deg or cm as appropriate. If units == ‘norm’ then sf units are in cycles per stimulus (and so SF scales with stimulus size). If texture is an image loaded from a file then sf=None defaults to 1/stimSize to give one cycle of the image.
The size (width, height) of the stimulus in the stimulus units
Value should be x,y-pair, scalar (applies to both dimensions) or None (resets to default). Operations are supported.
Sizes can be negative (causing a mirror-image reversal) and can extend beyond the window.
Example:
stim.size = 0.8 # Set size to (xsize, ysize) = (0.8, 0.8), quadratic.
print stim.size # Outputs array([0.8, 0.8])
stim.size += (0.5, -0.5) # make wider and flatter. Is now (1.3, 0.3)
Tip: if you can see the actual pixel range this corresponds to by looking at stim._sizeRendered
Texture to used on the stimulus as a grating (aka carrier)
If specifying your own texture using an image or numpy array you should ensure that the image has square power-of-two dimesnions (e.g. 256x256). If not then PsychoPy will upsample your stimulus to the next larger power of two.
Power-of-two int. Sets the resolution of the mask and texture. texRes is overridden if an array or image is provided as mask.
Operations supported.
None, ‘norm’, ‘cm’, ‘deg’, ‘degFlat’, ‘degFlatPos’, or ‘pix’
If None then the current units of the Window will be used. See Units for the window and stimuli for explanation of other options.
Note that when you change units, you don’t change the stimulus parameters and it is likely to change appearance. Example:
# This stimulus is 20% wide and 50% tall with respect to window
stim = visual.PatchStim(win, units='norm', size=(0.2, 0.5)
# This stimulus is 0.2 degrees wide and 0.5 degrees tall.
stim.units = 'deg'
Should shaders be used to render the stimulus (typically leave as True)
If the system support the use of OpenGL shader language then leaving this set to True is highly recommended. If shaders cannot be used then various operations will be slower (notably, changes to stimulus color or contrast)
This determines the coordinates of the vertices for the current stimulus in pixels, accounting for size, ori, pos and units
tuple (start, end) in degrees. Determines visible range. (0, 360) is full visibility.
Operations supported.
Example, drawing same stimulus in two different windows and display simultaneously. Assuming that you have two windows and a stimulus (win1, win2 and stim):
stim.win = win1 # stimulus will be drawn in win1
stim.draw() # stimulus is now drawn to win1
stim.win = win2 # stimulus will be drawn in win2
stim.draw() # it is now drawn in win2
win1.flip(waitBlanking=False) # do not wait for next monitor update
win2.flip() # wait for vertical blanking.
Note that this just changes **default** window for stimulus.
You could also specify window-to-draw-to when drawing::
stim.draw(win1)
stim.draw(win2)