GazeParser.Core - core components of GazeParser

class GazeParser.Core.BlinkData(t, d, Tlist)

Holds start time, end time and duraton of a blink.

Parameters:
  • t (sequence) – TimeStamp (start, endTime)
  • d (float) – duration of blink (msec)
  • Tlist (sequence) – List of timestamps.
getNextEvent(step=1, eventType=None)
getPreviousEvent(step=1, eventType=None)
relativeEndTime(time)

Blink offset time relative to indicated time. Unit is msec.

Parameters:time – reference time. Unit is msec. If objects that has ‘time’ attribute (e.g. GazeParser.Core.MessageData) is passed, the value of ‘time’ attribute is used.
relativeStartTime(time)

Blink onset time relative to indicated time. Unit is msec.

Parameters:time – reference time. Unit is msec. If objects that has ‘time’ attribute (e.g. GazeParser.Core.MessageData) is passed, the value of ‘time’ attribute is used.
duration

Blink duration in msec.

endIndex

Blink offset index in the timestamp list.

endTime

Blink offset time in msec.

parent

Parent GazeData object.

startIndex

Blink onset index in the timestamp list.

startTime

Blink onset time in msec.

class GazeParser.Core.CalPointData(point, accuracy, precision, recordedEye)

Holds accuracy and precision at calibration points.

getAccuracy(eye=None)

Get accuracy. If data is binocular, 4 values (LX, LY, RX, RY) are returned. If monocular, 2 values (X, Y) are returned. If the value is numpy.NaN, no data is available at this calibration point.

Parameters:eye (str) – Output both-eye (‘B’), left-eye (‘L’), right-eye (‘R’) data or None (recorded eye). Default value is None.
getPrecision(eye=None)

Get precision. If data is binocular, 4 values (LX, LY, RX, RY) are returned. If monocular, 2 values (X, Y) are returned. If the value is numpy.NaN, no data is available at this calibration point.

Parameters:eye (str) – Output both-eye (‘B’), left-eye (‘L’), right-eye (‘R’) data or None (recorded eye). Default value is None.
accuracy

Accuracy in screen coordinate (Lelt-X, Left-Y, Right-X, Right-Y). None if not available.

point

Location of calibration target in screen coordinate (x,y)

precision

Precision in screen coordinate (Lelt-X, Left-Y, Right-X, Right-Y). None if not available.

recordedEye

Precision in screen coordinate (Lelt-X, Left-Y, Right-X, Right-Y). None if not available.

class GazeParser.Core.FixationData(t, d, Tlist)

Holds various parameters of a single fixation such as start time, end time and so on.

Parameters:
  • t – Timestamp (start, endTime)
  • d – Tuple of 3 elements. (duration, center location X, Y)
  • Tlist – List of TimeStamps.
getNextEvent(step=1, eventType=None)
getPreviousEvent(step=1, eventType=None)
getTraj(eye=None)

Get fixation trajectory. If eye is ‘L’ or ‘R’, the returned value is a numpy.ndarray object. If ‘B’, the returned value is a tuple of two numpy.ndarray objects. The first and second element represent left and right eye’s trajectory, respectively.

Parameters:eye (str) – ‘L’, ‘R’ or ‘B’. If none, recorded eye is used.
relativeEndTime(time)

Fixation offset time relative to indicated time. Unit is msec.

Parameters:time – reference time. Unit is msec. If objects that has ‘time’ attribute (e.g. GazeParser.Core.MessageData) is passed, the value of ‘time’ attribute is used.
relativeStartTime(time)

Fixation onset time relative to indicated time. Unit is msec.

Parameters:time – reference time. Unit is msec. If objects that has ‘time’ attribute (e.g. GazeParser.Core.MessageData) is passed, the value of ‘time’ attribute is used.
center

Fixation center in screen coordinate (x, y). ‘Fixation center’ means an average of whole gaze trajectory during fixation.

duration

Fixation duration in msec.

endIndex

Fixation offset index in the timestamp list.

endTime

Fixation offset time in msec.

parent

Parent GazeData object.

startIndex

Fixation onset index in the timestamp list.

startTime

Fixation onset time in msec.

class GazeParser.Core.GazeData(Tlist, Llist, Rlist, SacList, FixList, MsgList, BlinkList, PupilList, recordedEye, config=None, recordingDate=None)

Holds saccades, fixations, blinks, messages, timestamps and gaze trajectory in a single recording.

Constructor GazeData.

DegToPixel(degValue)

Convert visual angle to screen pixel.

Parameters:degValue (float) – A value in screen pixel.
PixelToDeg(pixValue)

Convert screen pixel to visual angle.

Parameters:pixValue (float) – A value in visual angle.
deleteMessage(message)

Delete a message from message list.

Parameters:message – MessageData to be deleted. a MessageData object or an integer is accepted.
findIndexFromTime(time)

Return index of the timestamp of the sample that is nearest to the argument value. For example, 1000.0 is given as an argument and timestamp of the 251st and 252nd sample are 999.6 and 1003.4 respectively, 251 is returned.

Parameters:time (float) – Time in msec.
findMessage(text, byIndices=False, useRegexp=False)

Get messages including specified text.

Parameters:
  • text (str) – A text to be found.
  • byIndices (bool) – If ture, matched messages are returned by a list of indices. Otherwise, matched messages are returned by a list of GazeParser.Core.MessageData objects. Default value is False.
  • useRegexp (bool) – If true, ‘text’ parapeter is considered as a regular expression. Default value is False.
findNearestIndexFromMessage(message)

Return index of the timestamp of the sample that is nearest to the time of given message.

Note

This method is deprecated. Use GazeData`findIndexFromTime() instead. gazedata.findNearestIndexFromMessage(msg) is equivalent to gazedata.findIndexFromTime(msg.time)

getBlinkTime(index=None)

Get the start and end time of blinks.

Parameters:index – An index or a list of indices of blink(s). Give n-1 to get the start and end time of n-th blink. If None, all fixations are included. Default value is None.
Returns:If an integer is passed, starting and finish time of the blink is returned. Otherwise, an n x 2 numpy.ndarray object is returned.
getCalPointDataByList(contents='all')

Get calibration point data by numpy.ndarray.

Parameters:contents – Contents of the list. ‘point’, ‘accuracy’, ‘precision’ and ‘all’ are supported. Default value is ‘all’.
getFixCenter(index=None)

Get the center of fixations in screen coordinate.

Parameters:index – An index or a list of indices of fixation(s). Give n-1 to get the center of n-th fixation. If None, all fixations are included. Default value is None.
Returns:If an integer is passed, horizontal and vertical position of the fixation center is returned. Otherwise, an n x 2 numpy.ndarray object is returned.
getFixDur(index=None)

Get duration of fixations in milliseconds.

Parameters:index – An index or a list of indices of fixation(s). Give n-1 to get duration of n-th fixation. If None, all fixations are included. Default value is None.
Returns:If an integer is passed, a float value is returned. Otherwise, an n x 1 numpy.ndarray object is returned.
getFixTime(index=None)

Get the start and end time of fixations.

Parameters:index – An index or a list of indices of fixation(s). Give n-1 to get the starting and finish time of n-th fixation. If None, all fixations are included. Default value is None.
Returns:If an integer is passed, starting and finish time of the fixation is returned. Otherwise, an n x 2 numpy.ndarray object is returned.
getFixTraj(index, eye=None)

Get gaze trajectory during a fixation.

Parameters:
  • index (integer) – Index of fixation. Give n-1 to get gaze trajectory during n-th fixation.
  • eye (str) – Output both-eye (‘B’), left-eye (‘L’), right-eye (‘R’) data or None (recorded eye). Default value is None.
getMessageTextList()

Get a list of all message texts.

getMsgTime(index=None)

Get the recorded time of messages.

Parameters:index – An index or a list of indices of message(s). Give n-1 to get timestamp of n-th message. If None, all messages are included. Default value is None.
Returns:If an integer is passed, a float value is returned. Otherwise, an n x 1 numpy.ndarray object is returned.
getNextEvent(event, step=1, eventType=None)

Get an event next to the argument. If no next event, return None.

Parameters:
  • event – An instance of SaccadeData, FixaionData, BlinkData or MessageData. Timestamp (a float value) is also accepted.
  • step (integer) – If an integer (n) is given, the n-th next event is returned. Default value is 1.
  • eventType (str) – If ‘saccade’, ‘fixation’, ‘blink’ or ‘message’ is given, only events of given type are considered.
Returns:

Event object. If there is no next event, return None.

getPathLength(sac)

Get saccade length along saccade trajectory. If a list of SaccadeData object is provided, a list of the length of each saccades in the input list is returned.

Parameters:sac – a SaccadeData object or a list of SaccadeData object.
Returns:a float value or a numpy.ndarray object depending on the argument
getPreviousEvent(event, step=1, eventType=None)

Get an event previous to the argument. If no previous event, return None.

Parameters:
  • event – An instance of SaccadeData, FixaionData, BlinkData or MessageData. Timestamp is also accepted.
  • step (integer) – If an integer (n) is given, the n-th previous event is returned. Default value is 1.
  • eventType (str) – If ‘saccade’, ‘fixation’, ‘blink’ or ‘message’ is given, only events of given type are considered.
Returns:

Event object. If there is no previous event, return None.

getSacAmp(index=None)

Get saccade amplitude.

Parameters:index – An index or a list of indices of saccade(s). Give n-1 to get amplitude of n-th saccade. If None, all saccades are included. Default value is None.
Returns:If an integer is passed, a float value is returned. Otherwise, an n x 1 numpy.ndarray object is returned.
getSacDur(index=None)

Get duration of saccades in milliseconds.

Parameters:index – An index or a list of indices of saccade(s). Give n-1 to get duration of n-th saccade. If None, all saccades are included. Default value is None.
Returns:If an integer is passed, a float value is returned. Otherwise, an n x 1 numpy.ndarray object is returned.
getSacLen(index=None)

Get saccade length.

Parameters:index – An index or a list of indices of saccade(s). Give n-1 to get length of n-th saccade. If None, all saccades are included. Default value is None.
Returns:If an integer is passed, a float value is returned. Otherwise, an n x 1 numpy.ndarray object is returned.
getSacTime(index=None)

Get the start and end time of saccades.

Parameters:index – An index or a list of indices of saccade(s). Give n-1 to get the start and end time of n-th saccade. If None, all saccades are included. Default value is None.
Returns:If an integer is passed, starting and finish time of the saccade is returned. Otherwise, an n x 2 numpy.ndarray object is returned.
getSacTraj(index, eye=None)

Get gaze trajectory during a saccade.

Parameters:
  • index (integer) – Index of saccade. Give n-1 to get gaze trajectory during n-th saccade.
  • eye (str) – Output both-eye (‘B’), left-eye (‘L’), right-eye (‘R’) data or None (recorded eye). Default value is None.
hasCalPointData()

Return True if calibration point data is included.

hasCameraSpecificData()

Return True if camera specific data is included.

hasUSBIOData()

Return True if USBIO data is included.

insertNewMessage(time, text)

Insert a new message to MessageList.

Parameters:
  • time – Timestamp of the new message.
  • text – Message text of the new message.
setCalPointData(calpointdata)

Set calibration point data.

Parameters:calpointdata – A list of calibration point location, accuracy and precision.
setCameraSpecificData(data)

Set camera specific data.

Parameters:data – Camera specific data.
setUSBIOData(channels, data)

Set USBIO data.

Parameters:
  • channels – List of USBIO channels.
  • data – USBIO data.
sortEventListByTime()

Sort event list by time.

sortMessagesByTime()

Sort messages by time.

List of BlinkData objects.

CalPointData
CameraSpecificData
EventList

List of all events (saccades, fixations, blinks and messages) in chronological order.

Fix

List of FixationData objects.

L

List of gaze position (x, y) of left eye.

Msg

List of MessageData objects.

Pupil
R

List of gaze position (x, y) of right eye.

Sac

List of SaccadeData objects.

T

List of timestamps when each gaze position was recorded.

USBIOChannels
USBIOData
config

Config object which holds recording and parsing options.

Number of blinks detected in this trial.

nFix

Number of fixations detected in this trial.

nMsg

Number of messages recorded in this trial.

nSac

Number of saccades detected in this trial.

recordedEye
recordingDate
class GazeParser.Core.MessageData(m)

Holds a message received during recording.

Parameters:m – A tuple of 2 elements. The 1st element is timestamp (in msec). The 2nd element is received text.
delete()
getNextEvent(step=1, eventType=None)
getPreviousEvent(step=1, eventType=None)
updateMessage(newTime=None, newText=None)

Update message time and/or text.

Parameters:
  • newTime – New timestamp. If None, timestamp is not updated.
  • newText – New text. If None, text is not updated.
parent

Parent GazeData object.

text

Message text.

time

Time when message was recorded.

class GazeParser.Core.SaccadeData(t, d, Tlist)

Holds various parameters of a single saccade such as start time, end time, amplitude and so on.

Parameters:
  • t – Timestamp (start, endTime).
  • d – Tuple of 6 elements (Startpoint X, Y, Endpoint X, Y, amplitude, length).
  • Tlist – List of TimeStamps.
getNextEvent(step=1, eventType=None)
getPreviousEvent(step=1, eventType=None)
getTraj(eye=None)

Get saccade trajectory. If eye is ‘L’ or ‘R’, the returned value is a numpy.ndarray object. If ‘B’, the returned value is a tuple of two numpy.ndarray objects. The first and second element represent left and right eye’s trajectory, respectively.

Parameters:eye (str) – ‘L’, ‘R’ or ‘B’. If none, recorded eye is used.
relativeEndTime(time)

Saccade offset time relative to indicated time. Unit is msec.

Parameters:time – reference time. Unit is msec. If objects that has ‘time’ attribute (e.g. GazeParser.Core.MessageData) is passed, the value of ‘time’ attribute is used.
relativeStartTime(time)

Saccade onset time relative to indicated time. Unit is msec.

Parameters:time – reference time. Unit is msec. If objects that has ‘time’ attribute (e.g. GazeParser.Core.MessageData) is passed, the value of ‘time’ attribute is used.
amplitude

Saccade length in degree.

direction

Saccade direction in radian.

duration

Saccade duration in msec.

end

Saccade end location in screen coordinate (x, y).

endIndex

Saccade offset index in the timestamp list.

endTime

Saccade offset time in msec.

length

Saccade length in screen coordinate.

parent

Parent GazeData object.

start

Saccade start location in screen coordinate (x, y).

startIndex

Saccade onset index in the timestamp list.

startTime

Saccade onset time in msec.