expyfun.EyelinkController#

class expyfun.EyelinkController(ec, link='default', fs=1000, verbose=None)[source]#

Eyelink communication and control methods.

Parameters:
ecinstance of ExperimentController | None

ExperimentController instance to interface with. Necessary for doing calibrations.

linkstr | None

If ‘default’, the default value will be read from EXPYFUN_EYELINK. If None, dummy (simulation) mode will be used. If str, should be the network location of eyelink (e.g., “100.1.1.1”).

fsint

Sample rate to use. Must be one of [250, 500, 1000, 2000].

verbosebool, str, int, or None

If not None, override default verbose level (see expyfun.verbose).

Attributes:
dummy_mode
eye_used

Return the eye used ‘left’ or ‘right’

file_list

The list of files started on the EyeLink

fs
recording

Returns boolean for whether or not the Eyelink is recording

Methods

calibrate([beep, prompt])

Calibrate the eyetracker

custom_calibration([ctype, horiz, vert, ...])

Set Eyetracker to use a custom calibration sequence

get_eye_position()

The current eye position in pixels

maintain_fix(fix_pos, check_duration[, tol, ...])

Check to see if subject is fixating in a region.

stop()

Stop Eyelink recording and close current file

transfer_remote_file(remote_name)

Pull remote file (from Eyelink) to local machine

wait_for_fix(fix_pos[, fix_time, tol, ...])

Wait for gaze to settle within a defined region

Notes

The data will be saved to the ExperimentController output_dir. If this was None, data will be saved to the current working dir.

calibrate(beep=False, prompt=True)[source]#

Calibrate the eyetracker

Parameters:
beepbool

If True, beep for each calibration target.

promptbool

If True, a standard screen prompt will be shown.

Returns:
fnamestr | None

Filename on the Eyelink of the started data file.

Notes

At the start of this function, the previous Eyelink file will be closed (if one is open), a new file will be opened, and recording will be started.

custom_calibration(ctype='HV5', horiz=0.6666666666666666, vert=0.6666666666666666, coordinates=None, units='norm')[source]#

Set Eyetracker to use a custom calibration sequence

Parameters:
ctypestr

Type of calibration. Currently ‘H3’, ‘HV5’, ‘HV9’, and ‘HV13’ are supported. If ‘custom’ coordinates can be directly input.

horizfloat

Horizontal distance (left and right, each) to use.

vertfloat

Vertical distance (up and down, each) to use.

coordinateslist of list of float or int

List of coordinates to use for calibration. Each entry in the list must be a list with 2 elements corresponding to x and y position.

unitsstr

Units to use. See check_units for options.

property eye_used#

Return the eye used ‘left’ or ‘right’

Returns:
eyestr

‘left’ or ‘right’.

property file_list#

The list of files started on the EyeLink

get_eye_position()[source]#

The current eye position in pixels

Returns:
eye_posarray

The current eye position. Will be [np.inf, np.inf] if the eye is lost.

maintain_fix(fix_pos, check_duration, tol=100.0, period=0.25, check_interval=0.001, units='norm', stop_early=False)[source]#

Check to see if subject is fixating in a region.

This checks to make sure that the subjects gaze falls within a region at least once in any given period. In other words it checks to make sure that the gaze falls in the target region at least every period seconds.

Parameters:
fix_postuple (length 2)

The screen position (in specified units) required.

check_durationfloat

Total amount of time to check.

tolfloat

The tolerance (in pixels) to consider the target hit.

periodfloat

Maximum time between gazes in region

check_intervalfloat

Time to use between position checks (seconds).

unitsstr

Units for fix_pos. See check_units for options.

stop_earlybool

Whether to exit the function when fix_success is False or not.

Returns:
fix_successbool

Whether or not the subject successfully fixated throughout the check_duration.

property recording#

Returns boolean for whether or not the Eyelink is recording

stop()[source]#

Stop Eyelink recording and close current file

transfer_remote_file(remote_name)[source]#

Pull remote file (from Eyelink) to local machine

Parameters:
remote_namestr

The filename on the Eyelink.

Returns:
fnamestr

The filename on the local machine following the transfer.

wait_for_fix(fix_pos, fix_time=0.0, tol=100.0, max_wait=inf, check_interval=0.001, units='norm')[source]#

Wait for gaze to settle within a defined region

Parameters:
fix_postuple (length 2)

The screen position (in specified units) required.

fix_timefloat

Amount of time required to call a fixation.

tolfloat

The tolerance (in pixels) to consider the target hit.

max_waitfloat

Maximum time to wait (seconds) before returning.

check_intervalfloat

Time to use between position checks (seconds).

unitsstr

Units for fix_pos. See check_units for options.

Returns:
fix_successbool

Whether or not the subject successfully fixated.

Examples using expyfun.EyelinkController#

Experiment using eye-tracking pupillometry

Experiment using eye-tracking pupillometry

Experiment with eye-tracking

Experiment with eye-tracking