Visual Stimulus Classes¶
Display Basic Items of an Experiment¶
- class +o_ptb.+stimuli.+visual.FixationCross(color)¶
Draw a fixation cross.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
color (int or array of three ints) – The color of the fixation cross.
Display Images¶
- class +o_ptb.+stimuli.+visual.Image(image)¶
Draw an image read from a file.
This class provides all methods of
+o_ptb.+stimuli.+visual.TextureBase
and+o_ptb.+stimuli.+visual.Base
.- Parameters
image (string) – The filename of the image.
Display Text¶
- class +o_ptb.+stimuli.+visual.Text(text)¶
Draw formatted text.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
text (string) – The text to display
- Variables
size (
float
) – The font size of the text. Defaults to 46.style (
int
) – The style of the text. You can use the constants defined in+o_ptb.+constants.PTB_TextStyles
. Defaults to+o_ptb.+constants.PTB_TextStyles.Normal
.font (
string
) – The font used for drawing the text. Defaults to Arial.sx (
float
) – The x coordinates of the text. Defaults to the center of the destination_rect (normally the whole window).sy (
float
) – The y coordinates of the text. Defaults to the center of the destination_rect (normally the whole window).color (
int or array of three ints
) – The color of the text. You can use the constants defined in+o_ptb.+constants.PTB_Colors
Defaults to+o_ptb.+constants.PTB_Colors.black
.wrapat (
int
) – If set, text will automatically be continued on the next line if one line exceeds that amount of characters.vspacing (
int
) – The spacing between vertical lines. If your lines overlap, increase this property. Defaults to 1.
- class +o_ptb.+stimuli.+visual.TextFile(f_name)¶
Read formatted text from a file and draw it.
This class provides all methods of
+o_ptb.+stimuli.+visual.Text
.- Parameters
f_name (string) – The filename to read the text from.
Display geometric shapes¶
- class +o_ptb.+stimuli.+visual.Line(height, width, color, pen_width)¶
Draw a line.
The line is initially centered on the screen. Use the
move()
method to move it to the desired location.This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
height (float) – The distance from the bottom to the top of the line.
width (float) – The distance from left to right of the line.
color (int or array of three ints) – The color of the circle.
pen_size (float) – The width of the circle outline.
- class +o_ptb.+stimuli.+visual.FrameCircle(radius, color, pen_size)¶
Draw the outline of a circle.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
radius (float) – The radius of the circle.
color (int or array of three ints) – The color of the circle.
pen_size (float, optional) – The width of the circle outline.
- class +o_ptb.+stimuli.+visual.FrameOval(width, height, color, pen_size)¶
Draw the outline of an oval.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
width (float) – The width of the oval.
height (float) – The height of the oval.
color (int or array of three ints) – The color of the oval.
pen_size (float, optional) – The width of the ovals outline.
- class +o_ptb.+stimuli.+visual.FilledCircle(radius, color)¶
Draw a filled circle.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
radius (float) – The radius of the circle.
color (int or array of three ints) – The color of the circle.
- class +o_ptb.+stimuli.+visual.FilledOval(width, height, color)¶
Draw a filled oval.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
width (float) – The width of the oval.
height (float) – The height of the oval.
color (int or array of three ints) – The color of the oval.
- class +o_ptb.+stimuli.+visual.FrameCircleArc(radius, color, start_angle, total_angle, pen_size)¶
Draw the outline of a circle arc.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
radius (float) – The radius of the circle.
color (int or array of three ints) – The color of the circle.
start_angle (float) – The angle in degrees at which to start drawing.
total_angle (float) – The angle of the arc in degrees.
pen_size (float, optional) – The width of the circle outline.
- class +o_ptb.+stimuli.+visual.FrameOvalArc(width, height, color, start_angle, total_angle, pen_size)¶
Draw the outline of a oval arc.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
width (float) – The width of the oval.
height (float) – The height of the oval.
color (int or array of three ints) – The color of the circle.
start_angle (float) – The angle in degrees at which to start drawing.
total_angle (float) – The angle of the arc in degrees.
pen_size (float, optional) – The width of the circle outline.
- class +o_ptb.+stimuli.+visual.FilledCircleArc(radius, color, start_angle, total_angle)¶
Draw a filled circle arc.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
radius (float) – The radius of the circle.
color (int or array of three ints) – The color of the circle.
start_angle (float) – The angle in degrees at which to start drawing.
total_angle (float) – The angle of the arc in degrees.
- class +o_ptb.+stimuli.+visual.FilledOvalArc(width, height, color, start_angle, total_angle)¶
Draw a filled oval arc.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- Parameters
width (float) – The width of the oval.
height (float) – The height of the oval.
color (int or array of three ints) – The color of the circle.
start_angle (float) – The angle in degrees at which to start drawing.
total_angle (float) – The angle of the arc in degrees.
pen_size (float, optional) – The width of the circle outline.
Display advanced stimuli¶
- class +o_ptb.+stimuli.+visual.Gabor(width, height)¶
Draw a Gabor patch.
Note
It is mandatory to set the following properties after the class is instantiated:
frequency
sc
contrast
This class provides all methods of
+o_ptb.+stimuli.+visual.TextureBase
and+o_ptb.+stimuli.+visual.Base
.- Parameters
width (float) – The width of the gabor patch.
height (float) – The height of the gabor patch.
- Variables
rotate (
float
) – The rotation of the gabor in degrees. Default = 0.phase (
float
) – The phase of the gabor in degrees. Default = 180.aspectration (
float
) – Leave at 1 (the default) if you want the gabor to be as wide as it is high.frequency (
float
) – The spatial frequency in cycles per pixel. No default.sc (
float
) – The sigma value of the gauss function. No default.contrast (
float
) – The contrast of the gabor. No default.
- class +o_ptb.+stimuli.+visual.Movie(f_name)¶
Read a movie file and provide the frames.
Please refer to the tutorial for detailed instructions.
This class provides all methods of
+o_ptb.+stimuli.+visual.TextureBase
and+o_ptb.+stimuli.+visual.Base
.- Parameters
f_name (string) – The filename of the movie to load.
- Variables
duration (
float
) – Duration of the movie in seconds.fps (
float
) – Framrate of the movie.next_flip_time (
float
) – Timestamp of the flip for the currently loaded frame.
- fetch_frame()¶
Fetch the next frame of the movie.
- Returns
bool –
true
if another frame was available.
- resync()¶
Skip frames of the movie to catch up with current time.
- start()¶
Start movie playback.
- stop()¶
Stop movie playback.
Base classes¶
- class +o_ptb.+stimuli.+visual.Base¶
This is the base class for all visual stimuli.
This means that:
All visual stimulus classes provide all the parameters and methods of this base class. Please refer to How to draw stuff on the screen for details.
In order to create your own visual stimulus class, you need to inherite from this base class. Please refer to How to create your own stimuli for details.
- Variables
height (
float
) – The height of the stimulus in pixelswidth (
float
) – The width of the stimulus in pixels
- center_on_screen()¶
Center the stimulus on the screen.
- move(movex, movey)¶
Move the stimulus.
Move the stimulus by the amount of pixels.
- Parameters
movex (float) – Amount of pixels to move horizontally.
movey (float) – Amount of pixels to move vertically.
- move_to(x, y)¶
Move stimulus to x and y coordinates.
- Parameters
x (float) – The x coordinate of the destination.
y (float) – The y coordinate of the destination.
- scale(scalex, scaley)¶
Scale the stimulus.
Scale the stimulus by the ratios provided via the parameters.
- Parameters
scalex (float) – Ratio to scale the stimulus horizontally.
scaley (float, optional) – Ration to scale the stimulus vertically. If ommitted, scalex is used.
- class +o_ptb.+stimuli.+visual.TextureBase¶
Base class for all texture based stimuli.
- Variables
rotate (
float
) – Rotation of the stimulus in degrees.
This class provides all methods of
+o_ptb.+stimuli.+visual.Base
.- add_gauss_blur(stdev, kernel_size)¶
Add gaussian blur to the stimulus.
Blur the image with a guassian kernel.
- Parameters
stdev (float) – Standard deviation of the gaussian kernel.
kernel_size (int) – Size of the kernel.