Eyetracker |

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

## 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)
| calibrate (self)
| close (self)
| connected (self)
| drift_correction (self, pos=None, fix_triggered=False)
| draw_drift_correction_target (self, x, y)
| draw_calibration_target (self, x, y)
| fix_triggered_drift_correction (self, pos=None, min_samples=4, max_dev=120, timeout=10000)
| get_eyetracker_clock_async (self)
| log (self, msg)
| prepare_drift_correction (self, pos)
| pupil_size (self)
| sample (self)
| send_command (self, cmd)
| start_recording (self)
| status_msg (self, msg)
| stop_recording (self)
| set_detection_type (self, eventdetection)
| wait_for_event (self, event)
| wait_for_blink_end (self)
| wait_for_blink_start (self)
| wait_for_fixation_end (self)
| wait_for_fixation_start (self)
| wait_for_saccade_end (self)
| wait_for_saccade_start (self)
| is_valid_sample (self, gazepos)
Public Member Functions inherited from pygaze._eyetracker.baseeyetracker.BaseEyeTracker
| __init__ (self)
| log_var (self, var, val)
| set_eye_used (self)
| set_draw_calibration_target_func (self, func)
| set_draw_drift_correction_target_func (self, func)

## Public Attributes
| disp = display
| screen = Screen()
| dispsize = settings.DISPSIZE
| screensize = settings.SCREENSIZE
| kb = Keyboard(keylist=['space', 'escape', 'q'], timeout=1)
| errorbeep = Sound(osc='saw', freq=100, length=100)
str | outputfile = logfile + '.tsv'
str | extralogname = logfile + '_log.txt'
| extralogfile = open(self.extralogname, 'w')
bool | has_been_calibrated_before = False
bool | recording = False
int | errdist = 2
int | pxerrdist = 30
int | maxtries = 100
tuple | prevsample = (-1,-1)
int | prevps = -1
float | fixtresh = 1.5
int | fixtimetresh = 100
| spdtresh = saccade_velocity_threshold
| accthresh = saccade_acceleration_threshold
| blinkthresh = blink_threshold
str | eventdetection = eventdetection
int | weightdist = 10
| opengaze
float | samplerate = 60.0
float | sampletime = 1000.0 / self.samplerate
tuple | pxdsttresh = (xnoise, ynoise)
tuple | accuracy
| pxfixtresh = deg2pix(screendist, self.fixtresh, pixpercm)
tuple | pxaccuracy
| pxspdtresh = deg2pix(screendist, self.spdtresh/1000.0, pixpercm)
| pxacctresh = deg2pix(screendist, self.accthresh/1000.0, pixpercm)

## Protected Member Functions
| _elog (self, msg)

## Detailed Description

    A class for OpenGazeTracker objects

## Constructor & Destructor Documentation

## ◆ __init__()

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

    Initializes the OpenGazeTracker object

            arguments
            display -- a pygaze.display.Display instance

            keyword arguments
            logfile -- logfile name (string value); note that this is the
                       name for the eye data log file (default = LOGFILE)

## Member Function Documentation

## ◆ _elog()

pygaze._eyetracker.libopengaze.OpenGazeTracker._elog | ( |  | self,
|  |  | msg )
| protected

    Logs a message to the additional log.

## ◆ calibrate()

pygaze._eyetracker.libopengaze.OpenGazeTracker.calibrate | ( |  | self | ) |

    Calibrates the eye tracking system

            arguments
            None

            keyword arguments
            None

            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.libopengaze.OpenGazeTracker.close | ( |  | self | ) |

    Neatly close connection to tracker

            arguments
            None

            returns
            Nothing -- saves data and sets self.connected to False

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ connected()

pygaze._eyetracker.libopengaze.OpenGazeTracker.connected | ( |  | self | ) |

    Checks if the tracker is connected

            arguments
            None

            returns
            connected   -- True if connection is established, False if not;
                       sets self.connected to the same value

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ draw_calibration_target()

pygaze._eyetracker.libopengaze.OpenGazeTracker.draw_calibration_target | ( |  | self,
|  |  | x,
|  |  | y )

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ draw_drift_correction_target()

pygaze._eyetracker.libopengaze.OpenGazeTracker.draw_drift_correction_target | ( |  | self,
|  |  | x,
|  |  | y )

            Draws the drift-correction target.

            arguments

            x       --  The X coordinate
            y       --  The Y coordinate

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ drift_correction()

pygaze._eyetracker.libopengaze.OpenGazeTracker.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     -- Boolaan 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.libopengaze.OpenGazeTracker.fix_triggered_drift_correction | ( |  | self,
|  |  | pos = None,
|  |  | min_samples = 4,
|  |  | max_dev = 120,
|  |  | timeout = 10000 )

    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 a
                           fixation is accepted (default = 4)
            max_dev     -- maximal deviation from fixation in pixels
                           (default = 120)
            timeout     -- Time in milliseconds until fixation-triggering is
                           given up on, and calibration is started
                           (default = 10000)

            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.

## ◆ get_eyetracker_clock_async()

pygaze._eyetracker.libopengaze.OpenGazeTracker.get_eyetracker_clock_async | ( |  | self | ) |

    Not supported for OpenGazeTracker (yet)

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ is_valid_sample()

pygaze._eyetracker.libopengaze.OpenGazeTracker.is_valid_sample | ( |  | self,
|  |  | gazepos )

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

            arguments
            gazepos     --  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.libopengaze.OpenGazeTracker.log | ( |  | self,
|  |  | msg )

    Writes a message to the log file

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

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

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ prepare_drift_correction()

pygaze._eyetracker.libopengaze.OpenGazeTracker.prepare_drift_correction | ( |  | self,
|  |  | pos )

    Not supported for OpenGazeTracker (yet)

## ◆ pupil_size()

pygaze._eyetracker.libopengaze.OpenGazeTracker.pupil_size | ( |  | self | ) |

    Return pupil size

            arguments
            None

            returns
            pupil size  -- returns pupil diameter for the eye that is currently
                       being tracked (as specified by self.eye_used) or -1
                       when no data is obtainable

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ sample()

pygaze._eyetracker.libopengaze.OpenGazeTracker.sample | ( |  | self | ) |

    Returns newest available gaze position

            arguments
            None

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

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ send_command()

pygaze._eyetracker.libopengaze.OpenGazeTracker.send_command | ( |  | self,
|  |  | cmd )

    Function not supported. Use self.opengaze instead; it supports
            all possible API calls.

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ set_detection_type()

pygaze._eyetracker.libopengaze.OpenGazeTracker.set_detection_type | ( |  | self,
|  |  | eventdetection )

    Set the event detection type to either PyGaze algorithms, or
            native algorithms as provided by the manufacturer (only if
            available: detection type will default to PyGaze if no native
            functions are available)

            arguments
            eventdetection  --  a string indicating which detection type
                            should be employed: either 'pygaze' for
                            PyGaze event detection algorithms or
                            'native' for manufacturers algorithms (only
                            if available; will default to 'pygaze' if no
                            native event detection is available)
            returns     --  detection type for saccades, fixations and
                            blinks in a tuple, e.g.
                            ('pygaze','native','native') when 'native'
                            was passed, but native detection was not
                            available for saccade detection

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ start_recording()

pygaze._eyetracker.libopengaze.OpenGazeTracker.start_recording | ( |  | self | ) |

    Starts recording eye position

            arguments
            None

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

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ status_msg()

pygaze._eyetracker.libopengaze.OpenGazeTracker.status_msg | ( |  | self,
|  |  | msg )

    Not supported for OpenGazeTracker (yet)

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ stop_recording()

pygaze._eyetracker.libopengaze.OpenGazeTracker.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.libopengaze.OpenGazeTracker.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.libopengaze.OpenGazeTracker.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_event()

pygaze._eyetracker.libopengaze.OpenGazeTracker.wait_for_event | ( |  | self,
|  |  | event )

    Waits for event

            arguments
            event       -- an integer event code, one of the following:
                        3 = STARTBLINK
                        4 = ENDBLINK
                        5 = STARTSACC
                        6 = ENDSACC
                        7 = STARTFIX
                        8 = ENDFIX

            returns
            outcome -- a self.wait_for_* method is called, depending on the
                       specified event; the return values of corresponding
                       method are returned

Reimplemented from pygaze._eyetracker.baseeyetracker.BaseEyeTracker.

## ◆ wait_for_fixation_end()

pygaze._eyetracker.libopengaze.OpenGazeTracker.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.libopengaze.OpenGazeTracker.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.libopengaze.OpenGazeTracker.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.libopengaze.OpenGazeTracker.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

## ◆ accthresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.accthresh = saccade_acceleration_threshold

## ◆ accuracy

tuple pygaze._eyetracker.libopengaze.OpenGazeTracker.accuracy

Initial value:
= ( \
(pix2deg(screendist, sum(err['LX']) / float(len(err['LX'])), pixpercm), \
pix2deg(screendist, sum(err['LY']) / float(len(err['LY'])), pixpercm)), \
(pix2deg(screendist, sum(err['RX']) / float(len(err['RX'])), pixpercm), \
pix2deg(screendist, sum(err['RY']) / float(len(err['RY'])), pixpercm)))

## ◆ blinkthresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.blinkthresh = blink_threshold

## ◆ disp

pygaze._eyetracker.libopengaze.OpenGazeTracker.disp = display

## ◆ dispsize

pygaze._eyetracker.libopengaze.OpenGazeTracker.dispsize = settings.DISPSIZE

## ◆ errdist

int pygaze._eyetracker.libopengaze.OpenGazeTracker.errdist = 2

## ◆ errorbeep

pygaze._eyetracker.libopengaze.OpenGazeTracker.errorbeep = Sound(osc='saw', freq=100, length=100)

## ◆ eventdetection

pygaze._eyetracker.libopengaze.OpenGazeTracker.eventdetection = eventdetection

## ◆ extralogfile

pygaze._eyetracker.libopengaze.OpenGazeTracker.extralogfile = open(self.extralogname, 'w')

## ◆ extralogname

str pygaze._eyetracker.libopengaze.OpenGazeTracker.extralogname = logfile + '_log.txt'

## ◆ fixtimetresh

int pygaze._eyetracker.libopengaze.OpenGazeTracker.fixtimetresh = 100

## ◆ fixtresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.fixtresh = 1.5

## ◆ has_been_calibrated_before

bool pygaze._eyetracker.libopengaze.OpenGazeTracker.has_been_calibrated_before = False

## ◆ kb

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

## ◆ maxtries

int pygaze._eyetracker.libopengaze.OpenGazeTracker.maxtries = 100

## ◆ opengaze

pygaze._eyetracker.libopengaze.OpenGazeTracker.opengaze

Initial value:
= OpenGaze(ip='127.0.0.1', port=4242, \
logfile=self.outputfile, debug=False)

## ◆ outputfile

str pygaze._eyetracker.libopengaze.OpenGazeTracker.outputfile = logfile + '.tsv'

## ◆ prevps

int pygaze._eyetracker.libopengaze.OpenGazeTracker.prevps = -1

## ◆ prevsample

tuple pygaze._eyetracker.libopengaze.OpenGazeTracker.prevsample = (-1,-1)

## ◆ pxacctresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.pxacctresh = deg2pix(screendist, self.accthresh/1000.0, pixpercm)

## ◆ pxaccuracy

tuple pygaze._eyetracker.libopengaze.OpenGazeTracker.pxaccuracy

Initial value:
= ( \
(sum(err['LX']) / float(len(err['LX'])), \
sum(err['LY']) / float(len(err['LY']))), \
(sum(err['RX']) / float(len(err['RX'])), \
sum(err['RY']) / float(len(err['RY']))))

## ◆ pxdsttresh

tuple pygaze._eyetracker.libopengaze.OpenGazeTracker.pxdsttresh = (xnoise, ynoise)

## ◆ pxerrdist

int pygaze._eyetracker.libopengaze.OpenGazeTracker.pxerrdist = 30

## ◆ pxfixtresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.pxfixtresh = deg2pix(screendist, self.fixtresh, pixpercm)

## ◆ pxspdtresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.pxspdtresh = deg2pix(screendist, self.spdtresh/1000.0, pixpercm)

## ◆ recording

bool pygaze._eyetracker.libopengaze.OpenGazeTracker.recording = False

## ◆ samplerate

pygaze._eyetracker.libopengaze.OpenGazeTracker.samplerate = 60.0

## ◆ sampletime

pygaze._eyetracker.libopengaze.OpenGazeTracker.sampletime = 1000.0 / self.samplerate

## ◆ screen

pygaze._eyetracker.libopengaze.OpenGazeTracker.screen = Screen()

## ◆ screensize

pygaze._eyetracker.libopengaze.OpenGazeTracker.screensize = settings.SCREENSIZE

## ◆ spdtresh

pygaze._eyetracker.libopengaze.OpenGazeTracker.spdtresh = saccade_velocity_threshold

## ◆ weightdist

int pygaze._eyetracker.libopengaze.OpenGazeTracker.weightdist = 10

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

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