Experiment

class haptic.Experiment(w, **kwargs)

Experiment objects control the flow of an experiment and serve as an abstraction layer above the hardware and graphics managment layers. It is set up to primarily use callback methods allowing external definition of processes without requiring (but still allowing) management of the execution chain.

The best way to use this is by extending the class, creating a child experiment and overwriting methods where needed.

window

The psychopy window in use for this experiment.

Type

psychopy.visual.window

joystick

The joystick in use.

Type

HapticDevice

stims

Will be set to the output of the makeStims callback. See makeStims.

invert_y_axis

Whether the stick position’s y-axis should be inverted by default.

Type

bool

calibrate(*args, **kwargs)

Runs the joystick calibration methods.

Warning

This should be considered highly unstable.

Its operation will be changed to accomodate changes in the haptic.HapticDevice calibration scheme providing a relatively seamless integration of calibration into main experiment files.

Keyword Arguments
  • sMag (int) – Strong motor magnitude.

  • wMag (int) – Weak motor magnitude.

  • step (int) – How much to step up the magnitude.

makeStims()

Overwrite with own function.

run(n=1, func=None, funcargs=[], funckwargs={})

Run the provided function in a loop.

This method abstracts running visual.window.flip loops and

the experiment. T

drawing objects to the screen. Th provided function is run on each loop and is provided the window object and the frame number (starting from 0). These can be used to do more fine-grained editing within the callback.

The callback function should return a list of objects to

draw in the order they should be drawn.

Warning

The callback function should not flip the window.

Doing so will introduce errors into your experiment timing.

Keyword Arguments
  • n (int) – The number of frames to run. On a monitor with a 60Hz refresh rate, each frame corresponds to roughly 17ms. Defaults to 1.

  • func (function) – A callback function to run on each loop pass. The first argument to this callback will be the the frame number. This function should return a list of objects to draw.

  • funcargs (list) – Positional arguments for func.

  • funckwargs (dictionary) – Keyword arguments for func.

setJoystick(joy)

Overwrite with own function.

stickPos(start=- 3, stop=- 1, tolerance=0.1, scale=0.25)

Provide the stick position, inverting y-axis if needed.