API Reference

Experiment

Main interface

Experiment([arglist])

Main object for controlling experiment execution.

Methods that must be defined for each study

Experiment.create_stimuli()

Initialize study-specific stimulus objects.

Experiment.generate_trials()

Generator that yields data for each trial.

Experiment.run_trial(trial_info)

Execute an individual trial of the experiment.

Methods that can be overridden to control execution

Experiment.define_cmdline_params(parser)

Augment the command line parser to set params at runtime.

Experiment.serialize_trial_info(trial_info)

Serialize the trial results so they can be be sent to the remote.

Experiment.save_data()

Write out data files at the end of the run.

Experiment.compute_performance()

Extract performance metrics from trial data log.

Experiment.show_performance(mean_acc, mean_rt)

Show end-of-run feedback to the subject about performance.

Execution methods

Experiment.trial_count([max])

Generator of trial index.

Experiment.trial_info(**kwargs)

Generate a Series with trial information.

Experiment.check_abort()

Check whether the quit key has been pressed and exit if so.

Experiment.wait_until([end, timeout, sleep, …])

Wait limited by callback and timeout, possibly drawing stimuli.

Experiment.iti_end(iti_duration[, check_abort])

Return True if current time is within a flip of the ITI end.

Experiment.draw(stims[, flip])

Draw each named stimulus in the order provided.

Experiment.frame_range([seconds, frames, …])

Generator function for timing events based on screen flips.

Experiment.check_fixation([allow_blinks, …])

Enforce fixation but possibly allow blinks.

Experiment.show_feedback(stim, result[, idx])

Change the color of a stimulus to show feedback.

Experiment.flicker(stim[, duration, rate, …])

Repeatedly turn a stimulus off and on.

Initialization methods

Experiment.initialize_params()

Determine parameters for this run of the experiment.

Experiment.initialize_data_output()

Define stem for output filenames and ensure directory exists.

Experiment.initialize_sounds()

Create PsychoPy Sound objects for auditory feedback.

Experiment.initialize_server()

Start a server in an independent thread for experiment control.

Experiment.initialize_eyetracker()

Connect to and calibrate eyetracker.

Experiment.initialize_display([…])

Open the PsychoPy window to begin the experiment.

Experiment.initialize_stimuli()

Setup stimulus objects.

Shutdown methods

Experiment.shutdown_server()

Cleanly close down the experiment server process.

Experiment.shutdown_eyetracker()

End Eyetracker recording and save eyetracker log files.

Experiment.shutdown_display()

Cleanly exit out of the psychopy window.

Networking methods

Experiment.sync_remote_screen(stims)

Send information about what’s on the screen to the client.

Experiment.sync_remote_trials(trial_info)

Send trial information to the remote client for plotting.

Experiment.sync_remote_params()

Update eyetracking params using values from the remote client.

Internal execution methods

Experiment.run()

Outer loop for executing the experiment.

Experiment.wait_for_trigger()

Wait for a trigger key (or an abort).

Experiment.wait_for_exit()

Wait until the experimenter quits.

Tools

AcquireFixation(exp)

Handler for waiting until subject fixates to begin trial.

AcquireTarget(exp[, correct_target, allow_retry])

Handler for waiting until subject makes a eye or key response.

check_gaze(gaze, point, window)

Check whether gaze coordinates are on the point.

flexible_values(val[, size, random_state, …])

Flexibly determine a number of values.

truncated_sample(rv[, size, min, max])

Iteratively sample from a random variate rejecting values outside limits.

limited_repeat_sequence(values, max_repeats)

Infinite generator with a constraint on number of repeats of each item.

Stimuli

Fixation points, saccade targets, and spatial cues

stimuli.Point(win, pos[, radius, color])

Wrapper for a single psychopy.visual.Circle.

stimuli.Points(win, pos[, radius, color])

Wrapper for multiple psychopy.visual.Circle objects.

stimuli.LineCue(win[, extent, width, color])

Line extending from fixation towards a stimulus location.

stimuli.PointCue(win, norm, radius[, color])

Point extending from fixation towards at a stimulus location.

stimuli.FixationTask(win, clock, colors, …)

Random dot motion

stimuli.RandomDotMotion(win[, shape, size, …])

Random dot motion stimulus (from Newsome, Movshon, and others).

stimuli.RandomDotColorMotion(win[, shape, …])

Bivalent random dot stimulus with color and motion dimensions.

Gratings, hyperplaids, and noise fields

stimuli.Grating(win[, tex, mask, units, …])

Psychopy grating stimulus with variable luminance pedestal.

stimuli.ElementArray(win[, units, fieldPos, …])

Field of elements that are independently controlled and rapidly drawn.

stimuli.Pattern(win, n[, pos, contrast])

Contrast pattern created by averaging oriented gratings.

stimuli.GaussianNoise(win[, contrast, …])

Noise field with Gaussian statistics parameterized by contrast.

stimuli.UniformNoise(win[, contrast, …])

Noise field with uniform statistics parameterized by contrast.

Apertures

stimuli.BoreAperture(win, radius, pos)

stimuli.StimAperture(win, radius)

Simulated gaze position

stimuli.GazeStim(win, tracker)

Stimulus linked to eyetracker that shows gaze location.

Eye Tracking

eyetracker.EyeTracker(exp[, edf_stem])

Interface to EyeLink eyetracker.