Eyetracker |

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
pygaze._eyetracker.libtobii.TobiiProTracker Class Reference
Inheritance diagram for pygaze._eyetracker.libtobii.TobiiProTracker:

## Public Member Functions
| __init__ (self, display, logfile=settings.LOGFILE, eventdetection=settings.EVENTDETECTION, saccade_velocity_threshold=35, saccade_acceleration_threshold=9500, blink_threshold=settings.BLINKTHRESH, **args)
| log_var (self, var, val)
| set_eye_used (self)
| is_valid_sample (self, sample)
| start_recording (self)
| stop_recording (self)
| sample (self)
| pupil_size (self)
| calibrate (self, calibrate=True, validate=True)
| fix_triggered_drift_correction (self, pos=None, min_samples=10, max_dev=60, reset_threshold=30)
| drift_correction (self, pos=None, fix_triggered=False)
| wait_for_fixation_start (self)
| wait_for_fixation_end (self)
| wait_for_saccade_start (self)
| wait_for_saccade_end (self)
| wait_for_blink_start (self)
| wait_for_blink_end (self)
| log (self, msg)
| close (self)
Public Member Functions inherited from pygaze._eyetracker.baseeyetracker.BaseEyeTracker
| __init__ (self)
| connected (self)
| get_eyetracker_clock_async (self)
| send_command (self, cmd)
| draw_drift_correction_target (self, x, y)
| draw_calibration_target (self, x, y)
| set_draw_calibration_target_func (self, func)
| set_draw_drift_correction_target_func (self, func)
| status_msg (self, msg)
| set_detection_type (self, eventdetection)
| wait_for_event (self, event)

## Public Attributes
list | gaze = []
| disp = display
| screen = Screen()
| kb = Keyboard(keylist=['space', 'escape', 'q'], timeout=1)
bool | recording = False
| screendist = settings.SCREENDIST
list | eyetrackers = [t for t in tr.find_all_eyetrackers() if t.serial_number == settings.TRACKERSERIALNUMBER]
list | eyetracker = self.eyetrackers[0]
int | LEFT_EYE = 0
int | RIGHT_EYE = 1
int | BINOCULAR = 2
int | eye_used = 0
list | points_to_calibrate = [self._norm_2_px(p) for p in [(lb, ub), (rb, ub), (xc, yc), (lb, bb), (rb, bb)]]
float | fixtresh = 1.5
int | fixtimetresh = 100
| spdtresh = saccade_velocity_threshold
| accthresh = saccade_acceleration_threshold
| blinkthresh = blink_threshold
int | weightdist = 10
str | eventdetection = eventdetection
| screensize = settings.SCREENSIZE
tuple | pixpercm
int | errdist = 2
| pxerrdist = self._deg2pix(self.screendist, self.errdist, self.pixpercm)
list | event_data = []
| t0 = None
| datafile = open("{0}_TOBII_output.tsv".format(logfile), 'w')
list | pxaccuracy = [(self._mean(lxacc), self._mean(lyacc)), (self._mean(rxacc), self._mean(ryacc))]
| sampletime = self._mean(timestamps)
| samplerate = int(1000.0 / self.sampletime)
tuple | pxdsttresh = (XRMS, YRMS)
| pxfixtresh = self._deg2pix(self.screendist, self.fixtresh, self.pixpercm)
| pxspdtresh = self._deg2pix(self.screendist, self.spdtresh / 1000.0, self.pixpercm)
| pxacctresh = self._deg2pix(self.screendist, self.accthresh / 1000.0, self.pixpercm)
Public Attributes inherited from pygaze._eyetracker.baseeyetracker.BaseEyeTracker
| draw_calibration_target = func
| draw_drift_correction_target = func

## Protected Member Functions
| _norm_2_px (self, normalized_point)
| _px_2_norm (self, pixelized_point)
| _mean (self, array)
| _deg2pix (self, cmdist, angle, pixpercm)
| _on_gaze_data (self, gaze_data)
| _flush_to_file (self)
| _write_header (self)
| _write_sample (self, sample)

## Protected Attributes
bool | _write_enabled = True
| _on_gaze_data = []

## Detailed Description

    A class for Tobii Pro EyeTracker objects

## Constructor & Destructor Documentation

## ◆ __init__()

pygaze._eyetracker.libtobii.TobiiProTracker.__init__ | ( |  | self,
|  |  | display,
|  |  | logfile = settings.LOGFILE,
|  |  | eventdetection = settings.EVENTDETECTION,
|  |  | saccade_velocity_threshold = 35,
|  |  | saccade_acceleration_threshold = 9500,
|  |  | blink_threshold = settings.BLINKTHRESH,
|  | ** | args )

    Initializes a TobiiProTracker instance

    arguments
    display --  a pygaze.display.Display instance

    keyword arguments
    None

## Member Function Documentation

## ◆ _deg2pix()

pygaze._eyetracker.libtobii.TobiiProTracker._deg2pix | ( |  | self,
|  |  | cmdist,
|  |  | angle,
|  |  | pixpercm )
| protected

## ◆ _flush_to_file()

pygaze._eyetracker.libtobii.TobiiProTracker._flush_to_file | ( |  | self | ) |
| protected

## ◆ _mean()

pygaze._eyetracker.libtobii.TobiiProTracker._mean | ( |  | self,
|  |  | array )
| protected

## ◆ _norm_2_px()

pygaze._eyetracker.libtobii.TobiiProTracker._norm_2_px | ( |  | self,
|  |  | normalized_point )
| protected

## ◆ _on_gaze_data()

pygaze._eyetracker.libtobii.TobiiProTracker._on_gaze_data | ( |  | self,
|  |  | gaze_data )
| protected

## ◆ _px_2_norm()

pygaze._eyetracker.libtobii.TobiiProTracker._px_2_norm | ( |  | self,
|  |  | pixelized_point )
| protected

## ◆ _write_header()

pygaze._eyetracker.libtobii.TobiiProTracker._write_header | ( |  | self | ) |
| protected

## ◆ _write_sample()

pygaze._eyetracker.libtobii.TobiiProTracker._write_sample | ( |  | self,
|  |  | sample )
| protected

## ◆ calibrate()

pygaze._eyetracker.libtobii.TobiiProTracker.calibrate | ( |  | self,
|  |  | calibrate = True,
|  |  | validate = True )

    Calibrates the eye tracker.

    arguments
    None

    keyword arguments
    calibrate   --  Boolean indicating if calibration should be
                performed (default = True).
    validate    --  Boolean indicating if validation should be performed
                (default = True).

    returns
    success --  returns True if calibration succeeded, or False if
                not; in addition a calibration log is added to the
                log file and some properties are updated (i.e. the
                thresholds for detection algorithms)

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ close()

pygaze._eyetracker.libtobii.TobiiProTracker.close | ( |  | self | ) |

    Closes the currently used log file.

    arguments
    None

    returns
    None        --  closes the log file.

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ drift_correction()

pygaze._eyetracker.libtobii.TobiiProTracker.drift_correction | ( |  | self,
|  |  | pos = None,
|  |  | fix_triggered = False )

    Performs a drift check

    arguments
    None

    keyword arguments
    pos         -- (x, y) position of the fixation dot or None for
                   a central fixation (default = None)
    fix_triggered   -- Boolean indicating if drift check should be
                   performed based on gaze position (fix_triggered
                   = True) or on spacepress (fix_triggered =
                   False) (default = False)

    returns
    checked     -- Boolean indicating if drift check is ok (True)
                   or not (False); or calls self.calibrate if 'q'
                   or 'escape' is pressed

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ fix_triggered_drift_correction()

pygaze._eyetracker.libtobii.TobiiProTracker.fix_triggered_drift_correction | ( |  | self,
|  |  | pos = None,
|  |  | min_samples = 10,
|  |  | max_dev = 60,
|  |  | reset_threshold = 30 )

    Performs a fixation triggered drift correction by collecting
    a number of samples and calculating the average distance from the
    fixation position

    arguments
    None

    keyword arguments
    pos         -- (x, y) position of the fixation dot or None for
                   a central fixation (default = None)
    min_samples     -- minimal amount of samples after which an
                   average deviation is calculated (default = 10)
    max_dev     -- maximal deviation from fixation in pixels
                   (default = 60)
    reset_threshold -- if the horizontal or vertical distance in
                   pixels between two consecutive samples is
                   larger than this threshold, the sample
                   collection is reset (default = 30)

    returns
    checked     -- Boolean indicating if drift check is ok (True)
                   or not (False); or calls self.calibrate if 'q'
                   or 'escape' is pressed

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ is_valid_sample()

pygaze._eyetracker.libtobii.TobiiProTracker.is_valid_sample | ( |  | self,
|  |  | sample )

    Checks if the sample provided is valid, based on Tobii specific
    criteria (for internal use)

    arguments
    sample      --  a (x,y) gaze position tuple, as returned by
                    self.sample()

    returns
    valid           --  a Boolean: True on a valid sample, False on
                    an invalid sample

## ◆ log()

pygaze._eyetracker.libtobii.TobiiProTracker.log | ( |  | self,
|  |  | msg )

    Writes a message to the log file

    arguments
    msg     -- a string to include in the log file

    returns
    Nothing -- uses native log function to include a line
               in the log file

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ log_var()

pygaze._eyetracker.libtobii.TobiiProTracker.log_var | ( |  | self,
|  |  | var,
|  |  | val )

    Writes a variable to the log file

    arguments
    var     -- variable name
    val     -- variable value

    returns
    Nothing -- uses native log function to include a line
                in the log file in a "var NAME VALUE" layout

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ pupil_size()

pygaze._eyetracker.libtobii.TobiiProTracker.pupil_size | ( |  | self | ) |

    Returns newest available pupil size

    arguments
    None

    returns
    pupilsize   -- a float if only eye is selected or only one eye has valid data.
                -- a tuple with two floats if both eyes are selected.
                -- -1 if there is no valid pupil data available.

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ sample()

pygaze._eyetracker.libtobii.TobiiProTracker.sample | ( |  | self | ) |

    Returns newest available gaze position

    The gaze position is relative to the self.eye_used currently selected.
    If both eyes are selected, the gaze position is averaged from the data of both eyes.

    arguments
    None

    returns
    sample  -- an (x,y) tuple or a (-1,-1) on an error

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ set_eye_used()

pygaze._eyetracker.libtobii.TobiiProTracker.set_eye_used | ( |  | self | ) |

    Logs the eye_used variable, based on which eye was specified.

    arguments
    None

    returns
    Nothing -- logs which eye is used by calling self.log_var, e.g.
               self.log_var("eye_used", "right")

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ start_recording()

pygaze._eyetracker.libtobii.TobiiProTracker.start_recording | ( |  | self | ) |

    Starts recording eye position

    arguments
    None

    returns
    None        -- sets self.recording to True when recording is
               successfully started

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ stop_recording()

pygaze._eyetracker.libtobii.TobiiProTracker.stop_recording | ( |  | self | ) |

    Stop recording eye position

    arguments
    None

    returns
    Nothing -- sets self.recording to False when recording is
               successfully started

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_blink_end()

pygaze._eyetracker.libtobii.TobiiProTracker.wait_for_blink_end | ( |  | self | ) |

    Waits for a blink end and returns the blink ending time

    arguments
    None

    returns
    timestamp       --  blink ending time in milliseconds, as
                    measured from experiment begin time

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_blink_start()

pygaze._eyetracker.libtobii.TobiiProTracker.wait_for_blink_start | ( |  | self | ) |

    Waits for a blink start and returns the blink starting time

    arguments
    None

    returns
    timestamp       --  blink starting time in milliseconds, as
                    measured from experiment begin time

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_fixation_end()

pygaze._eyetracker.libtobii.TobiiProTracker.wait_for_fixation_end | ( |  | self | ) |

    Returns time and gaze position when a fixation has ended;
    function assumes that a 'fixation' has ended when a deviation of
    more than self.pxfixtresh from the initial fixation position has
    been detected (self.pxfixtresh is created in self.calibration,
    based on self.fixtresh, a property defined in self.__init__)

    arguments
    None

    returns
    time, gazepos   -- time is the starting time in milliseconds (from
                   expstart), gazepos is a (x,y) gaze position
                   tuple of the position from which the fixation
                   was initiated

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_fixation_start()

pygaze._eyetracker.libtobii.TobiiProTracker.wait_for_fixation_start | ( |  | self | ) |

    Returns starting time and position when a fixation is started;
    function assumes a 'fixation' has started when gaze position
    remains reasonably stable (i.e. when most deviant samples are
    within self.pxfixtresh) for five samples in a row (self.pxfixtresh
    is created in self.calibration, based on self.fixtresh, a property
    defined in self.__init__)

    arguments
    None

    returns
    time, gazepos   -- time is the starting time in milliseconds (from
                   expstart), gazepos is a (x,y) gaze position
                   tuple of the position from which the fixation
                   was initiated

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_saccade_end()

pygaze._eyetracker.libtobii.TobiiProTracker.wait_for_saccade_end | ( |  | self | ) |

    Returns ending time, starting and end position when a saccade is
    ended; based on Dalmaijer et al. (2013) online saccade detection
    algorithm

    arguments
    None

    returns
    endtime, startpos, endpos   -- endtime in milliseconds (from
                           expbegintime); startpos and endpos
                           are (x,y) gaze position tuples

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_saccade_start()

pygaze._eyetracker.libtobii.TobiiProTracker.wait_for_saccade_start | ( |  | self | ) |

    Returns starting time and starting position when a saccade is
    started; based on Dalmaijer et al. (2013) online saccade detection
    algorithm

    arguments
    None

    returns
    endtime, startpos   -- endtime in milliseconds (from expbegintime);
                   startpos is an (x,y) gaze position tuple

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## Member Data Documentation

## ◆ _on_gaze_data

pygaze._eyetracker.libtobii.TobiiProTracker._on_gaze_data = []
| protected

## ◆ _write_enabled

bool pygaze._eyetracker.libtobii.TobiiProTracker._write_enabled = True
| protected

## ◆ accthresh

pygaze._eyetracker.libtobii.TobiiProTracker.accthresh = saccade_acceleration_threshold

## ◆ BINOCULAR

int pygaze._eyetracker.libtobii.TobiiProTracker.BINOCULAR = 2

## ◆ blinkthresh

pygaze._eyetracker.libtobii.TobiiProTracker.blinkthresh = blink_threshold

## ◆ datafile

pygaze._eyetracker.libtobii.TobiiProTracker.datafile = open("{0}_TOBII_output.tsv".format(logfile), 'w')

## ◆ disp

pygaze._eyetracker.libtobii.TobiiProTracker.disp = display

## ◆ errdist

int pygaze._eyetracker.libtobii.TobiiProTracker.errdist = 2

## ◆ event_data

list pygaze._eyetracker.libtobii.TobiiProTracker.event_data = []

## ◆ eventdetection

str pygaze._eyetracker.libtobii.TobiiProTracker.eventdetection = eventdetection

## ◆ eye_used

int pygaze._eyetracker.libtobii.TobiiProTracker.eye_used = 0

## ◆ eyetracker

list pygaze._eyetracker.libtobii.TobiiProTracker.eyetracker = self.eyetrackers[0]

## ◆ eyetrackers

list pygaze._eyetracker.libtobii.TobiiProTracker.eyetrackers = [t for t in tr.find_all_eyetrackers() if t.serial_number == settings.TRACKERSERIALNUMBER]

## ◆ fixtimetresh

int pygaze._eyetracker.libtobii.TobiiProTracker.fixtimetresh = 100

## ◆ fixtresh

pygaze._eyetracker.libtobii.TobiiProTracker.fixtresh = 1.5

## ◆ gaze

list pygaze._eyetracker.libtobii.TobiiProTracker.gaze = []

## ◆ kb

pygaze._eyetracker.libtobii.TobiiProTracker.kb = Keyboard(keylist=['space', 'escape', 'q'], timeout=1)

## ◆ LEFT_EYE

int pygaze._eyetracker.libtobii.TobiiProTracker.LEFT_EYE = 0

## ◆ pixpercm

tuple pygaze._eyetracker.libtobii.TobiiProTracker.pixpercm

Initial value:
= (self.disp.dispsize[0] / float(self.screensize[0]) +
self.disp.dispsize[1] / float(self.screensize[1])) / 2.0

## ◆ points_to_calibrate

list pygaze._eyetracker.libtobii.TobiiProTracker.points_to_calibrate = [self._norm_2_px(p) for p in [(lb, ub), (rb, ub), (xc, yc), (lb, bb), (rb, bb)]]

## ◆ pxacctresh

pygaze._eyetracker.libtobii.TobiiProTracker.pxacctresh = self._deg2pix(self.screendist, self.accthresh / 1000.0, self.pixpercm)

## ◆ pxaccuracy

list pygaze._eyetracker.libtobii.TobiiProTracker.pxaccuracy = [(self._mean(lxacc), self._mean(lyacc)), (self._mean(rxacc), self._mean(ryacc))]

## ◆ pxdsttresh

tuple pygaze._eyetracker.libtobii.TobiiProTracker.pxdsttresh = (XRMS, YRMS)

## ◆ pxerrdist

pygaze._eyetracker.libtobii.TobiiProTracker.pxerrdist = self._deg2pix(self.screendist, self.errdist, self.pixpercm)

## ◆ pxfixtresh

pygaze._eyetracker.libtobii.TobiiProTracker.pxfixtresh = self._deg2pix(self.screendist, self.fixtresh, self.pixpercm)

## ◆ pxspdtresh

pygaze._eyetracker.libtobii.TobiiProTracker.pxspdtresh = self._deg2pix(self.screendist, self.spdtresh / 1000.0, self.pixpercm)

## ◆ recording

bool pygaze._eyetracker.libtobii.TobiiProTracker.recording = False

## ◆ RIGHT_EYE

int pygaze._eyetracker.libtobii.TobiiProTracker.RIGHT_EYE = 1

## ◆ samplerate

pygaze._eyetracker.libtobii.TobiiProTracker.samplerate = int(1000.0 / self.sampletime)

## ◆ sampletime

pygaze._eyetracker.libtobii.TobiiProTracker.sampletime = self._mean(timestamps)

## ◆ screen

pygaze._eyetracker.libtobii.TobiiProTracker.screen = Screen()

## ◆ screendist

pygaze._eyetracker.libtobii.TobiiProTracker.screendist = settings.SCREENDIST

## ◆ screensize

pygaze._eyetracker.libtobii.TobiiProTracker.screensize = settings.SCREENSIZE

## ◆ spdtresh

pygaze._eyetracker.libtobii.TobiiProTracker.spdtresh = saccade_velocity_threshold

## ◆ t0

pygaze._eyetracker.libtobii.TobiiProTracker.t0 = None

## ◆ weightdist

int pygaze._eyetracker.libtobii.TobiiProTracker.weightdist = 10

The documentation for this class was generated from the following file:

- C:/Users/lurax/eyetrackingTobii/pygaze/_eyetracker/libtobii.py