Jump to content

Contributions:EyetrackerLoggerTobii3: Difference between revisions

From BCI2000 Wiki
Kgoering (talk | contribs)
Mellinger (talk | contribs)
 
(27 intermediate revisions by 3 users not shown)
Line 7: Line 7:
==Versioning==
==Versioning==
===Authors===
===Authors===
Kaleb Goering (kaleb.goering@gmail.com)
Kristopher Kaleb Goering (kaleb.goering@gmail.com)
 
Jürgen Mellinger (mellinger@neurotechcenter.org)
===Version History===
===Version History===
06/23/2015: Initial public release;
*2015-06-23: Initial public release
*2017-08-21:
**adapted code to current version of BCI2000 framework
**rewrote large parts for clarity
**unified coordinate system for eye position, and gaze data


===Source Code Revisions===
===Source Code Revisions===
*Initial development: 3318
*Initial development: 4879
*Tested under: 3318
*Tested under: 5696
*Known to compile under: 3318
*Known to compile under: 5696
*Broken since: --
*Broken since: --


==Functional Description==
==Functional Description==
In many cases, an experiment may require data about where the participant is looking.  In these experiments, an eyetracker is the only way to gather data relating to gaze position and eye location.  There are many eyetracking methods currently on the market, but many of these require the subject to hold their head steady -- often while strapped to a structure of some sort.  The Tobii eyetrackers require no such restriction so they were a natural choice when it came to interfacing with BCI2000.
Records data collected by a Tobii eye tracker, using version 3 of the Tobii SDK.


==Integration into BCI2000==
==Integration into BCI2000==
Compile the extension into your source module by enabling contributed extensions in your CMake configuration.  You can do this by going into your root build folder and deleting <code>CMakeCache.txt</code> and re-running the project batch file, or by running <code>cmake -i</code> and enabling '''BUILD_EYETRACKERLOGGERTOBII3'''. Once the extension is built into the source module, enable it by starting the source module with the <code>--LogEyetrackerTobii3=1</code> command line argument.
Compile the extension into your source module by enabling contributed extensions in your CMake configuration, and setting <tt>EXTENSIONS_EYETRACKERLOGGERTOBII3=On</tt>.
Once the extension is built into the source module, enable it by starting the source module with the <code>--LogEyetrackerTobii3=1</code> command line argument.


==Usage and Calibration==
==Usage and Calibration==
Set up the eyetracker as detailed in the documentation that came with your deviceThe device will connect to your machine and communicate through the ethernet portAs such, it'd be wise to disconnect and turn off any other networking devices while using the eyetrackerIt is possible that your network request could go out over a different network interface if you're not careful which makes for a troubleshooting nightmare. When you start the source module, ensure that the <code>--LogEyetrackerTobii3=1</code> command line parameter is set.  Run the Eyetracker Browser utility which came with your eyetracker drivers and use it to locate the device on your local network.  
Make sure the eye tracker is set up according to its user manual, and make sure it is able to
connect to the Tobii calibration utility.
 
Calibration can now occurCalibration should be done per subject per sittingRe-calibration is not necessary between runs, but any time that the subject changes eye wear, makeup, or position, or if the lighting conditions change it should be re-calibrated. A good rule of thumb would be to recalibrate at the start of every sessionOnce a calibration is performed, it is saved in the Tobii device until the next calibration (even if there's a power loss).
 
Quit the calibration utility before starting BCI2000.
When you start the source module, ensure that the <code>--LogEyetrackerTobii3=1</code> command line parameter is set.


Calibration can now occur. Calibration should be done per subject per sitting.  Re-calibration is not necessary between runs, but any time that the subject changes eyewear, makeup, or position, or if the lighting conditions change it should be re-calibrated. A good rule of thumb would be to recalibrate at the start of every session.  Once a calibration is performed, it is saved in the Tobii device until the next calibration (even if there's a power loss).
==Coordinate System==
When properly calibrated, the eye tracker will know about location, orientation, and extent of the
display surface, relative to itself.
Observing the subject through a camera, the eye tracker will be able to detect eye position and gaze direction, relative to its own position and orientation.
Using calibration information, it can then determine gaze location as the intersection of gaze direction, and display surface, and it will transform gaze location into a more convenient
coordinate system which is aligned to the display's edges.


BCI2000 does not provide any way to calibrate the eyetracker. This should be done using the Tobii SDK sample application.  The SDK can be obtained here: http://www.tobii.com/analysis-and-research/global/products/software/tobii-software-development-kit/.  The 2.0 or Beta 3.0 SDK can be used to calibrate the device.  When installed, open <code>C:\Program Files\Tobii\Tobii Eye Tracker SDK 2.0.1\samples\<\code> for the 2.0.1 SDK or <code>C:\Program Files\Tobii\SDK\Samples\</code> for the 3.0 Beta SDK and find the "Eye Tracker Components C++" or "EyetrackerComponents.Cpp" sample project.  There should be a pre-built executable in this directory or a "prebuild" directory which can be used to run a calibration.  Use the network address from the Eyetracker Browser and follow the instructions to calibrate and test your device. When you're done you can close the calibration utility and run BCI2000 - which will use the calibration saved on the device.
To an experimenter, none of the involved coordinate systems is relevant, except for the
screen-relative one in which gaze location is reported. Thus, it appears most natural to report
eye position in the same screen-relative coordinate system, extended with a Z axis perpendicular
to the screen, as illustrated below:
[[File:EyetrackerCoordinateSystem.png|center|615px]]
In this coordinate system, gaze position will always have a Z coordinate of 0, and the eye's Z
coordinate will be its distance from the screen plane.
An eye's position and gaze may thus be expressed by 5 coordinate values,
*''GazeX'': X coordinate of gaze position,
*''GazeY'': Y coordinate of gaze position,
*''EyePosX'': X coordinate of eye,
*''EyePosY'': Y coordinate of eye,
*''EyeDist'': Z coordinate of eye
in the above coordinate system.


If you're using an T60/T120 or any future Tobii eyetracker with an attached display, you'll probably have it in a dual screen setup showing different things on both monitors - either extended or dualview. Typically, the Tobii monitor is used to present the task to the subject and the other monitor is used for the experimenter to control BCI2000 from.  This can present a bit of a problem when calibrating because the sample application will only run on your "primary display" which may or may not be your Tobii monitor.  Either set your primary display to be the Tobii screen or temporarily set the screen configuration into "clone" mode.  A different screen resolution or aspect ratio does not impact the Tobii calibration process.
For the experimenter's convenience, X and Y coordinates are also normalized to a fixed range
such that the Active Display Area's bottom right corner has coordinates (65535, 65535, 0)
when expressed in raw recorded values.
For compatibility reasons, eye position coordinates use the same normalized raw units as
gaze position does in X and Y directions, but uses raw steps of 1mm for its Z coordinate.


Once the device is calibrated, it can be used reliably in BCI2000.  The logger will report information about eye validity in a text visualization window and feed states into the system.
Recovering original physical dimensions is possible using the  
[[#EyetrackerData|EyetrackerData Parameter]] as explained below.


==Parameters==
==Parameters==
The eyetracker is configured in the Source tab within the EyetrackerLogger section. The configurable parameters are:
===User configurable Parameters===
The eye tracker is configured in the Source tab within the EyetrackerLogger section.
 
====LogEyetrackerTobii3====
Set to 0 to disable the eye tracker logger.
 
====GazeScale, GazeOffset (deprecated)====
Incoming gaze and position data are transformed by first multiplying with <tt>GazeScale</tt>, then
subtracting <tt>GazeOffset</tt>.
These values may affect the precision in which gaze data is stored, and should always be set to
<tt>GazeScale=1, GazeOffset=0.</tt>
 
<tt>GazeScale</tt> and <tt>GazeOffset</tt> were hacks introduced in the original
[[Contributions:EyetrackerLogger|EyetrackerLogger]] to address an issue with gaze data being clamped around the edges of the screen.
EyetrackerLoggerTobii3 uses additional bits to avoid issues with values being out of range, so these parameters serve no useful purpose any more, and are kept solely for backward compatibility
with the original [[Contributions:EyetrackerLogger|EyetrackerLogger]].
 
===Descriptive Parameters===
These parameters are used by the eye tracker logger in order to store information about
the eye tracker's configuration, and to help interpretation of logged data in data analysis.
 
====EyetrackerInfo====
A list-valued parameter with a variable number of named entries, providing information about the eye tracker's properties and configuration.
 
Depending on eye tracker model and setup, the following entries may be present:
*SerialNumber, Model, Generation, FirmwareVersion
*UnitName (if set by the user)
*FrameRate (if available)
*IlluminationMode (if available)
*LowBlinkMode (if available)
 
====EyetrackerData====
A matrix-valued parameter with two columns,
and one row for each state variable written by the eye tracker logger,
containing information required to recover the original physical units associated with
eye tracker data when reading a data file.


*<code>LogEyetrackerTobii3</code>  - Enables/Disables logging of Eyetracker states
For each row, its label matches the name of a BCI2000 state variable holding eye tracker
*<code>LogGazeData</code> - Enables/Disables logging of gaze data
data.
*<code>LogEyePos</code> - Enables/Disables logging of eye position (as seen from the camera)
*<code>LogPupilSize</code> - Enables/Disables logging of pupil size (very rough)
*<code>LogEyeDist</code> - Enables/Disables logging of the distance from the screen to the eyes (again, rough)
*<code>GazeScale</code> - Scales the incoming gaze data first
*<code>GazeOffset</code> - Offsets the incoming gaze data after scaling


Note: GazeScale and GazeOffset are quick hacks to address an issue with gaze data being clamped around the edges of the screen.  The eyetracker gives back values which are between 0.0 and 1.0 for onscreen gaze but supports looking slightly offscreen by allowing gaze data returned to go above 1.0 and below 0.0.  BCI2000 needs this scaled between 0.0 and 1.0 before the gaze data is multiplied by 65535 for storage in the 16 bit state.  These two parameters account for this scaling and offset and prevents the clamping from happening as often as it would otherwise.  These parameters will be removed once BCI2000 supports typed states. Brought from EyetrackerLogger
The row's first column contains a ''data type'' of the form <tt>[u]int<N></tt> where
<tt>N</tt> is the number of bits, and a <tt>u</tt> prefix indicates that a value is to be
interpreted as unsigned rather than signed. (For signed values, the most significant bit
represents sign, and must be specially taken account for.)


The following code retreives the actual ~(0.0-1.0) range that the eyetracker outputs directly (assuming you've scaled and offset the signal to avoid clipping) from each eye and averages it to find a gaze position.
In the second column, the data elements of a  
<pre>
<tt>[[Programming_Reference:PhysicalUnit_Class|PhysicalUnit]]</tt> object are present,
float x = State( "EyetrackerLeftEyeGazeX" ) + State( "EyetrackerRightEyeGazeX" ); x /= ( 2.0f * 65535.0f );
separated with spaces, and in the following order:
float y = State( "EyetrackerLeftEyeGazeY" ) + State( "EyetrackerRightEyeGazeY" ); y /= ( 2.0f * 65535.0f );
*''offset'' in raw units,
x -= ( float )Parameter( "GazeOffset" ); x /= ( float )Parameter( "GazeScale" );
*''gain,''
y -= ( float )Parameter( "GazeOffset" ); y /= ( float )Parameter( "GazeScale" );
*''symbol'' (of an SI unit, without prefix),
</pre>
* ''raw minimum'' (typically 0, but may indicate an estimated raw data minimum if different from ''raw maximum''),
*''raw maximum'' (typically 0, but may indicate an estimated raw data maximum if different from ''raw minimum'').


==State Variables==
'''Examples:'''
Unless otherwise specified, all states are prefixed with <code>Eyetracker<Left/Right>Eye</code> which corresponds with each individual eye. The EyetrackerLogger extension does not support subjects with more than two eyes at the moment.
<tt>EyetrackerData</tt> may contain a row labeled <tt>EyetrackerRightEyeGazeX</tt> with a data type of "int18" and a physical unit of "-6.3 1e-5 m 0 0". At some sample offset, the value of the <tt>EyetrackerRightEyeGazeX</tt> state may be read as 2345.
To recover the right gaze point's distance from the screen's left edge in original units,
you may proceed as follows:
*interpret 2345 as a signed 18 bit number -> 2345
*subtract -6.3 -> 2345-(-6.3) = 2351.3
*multiply with 1e-5 -> 0.023513
*concatenate with "m" -> 0.023513m = 23.513mm.


===GazeX, GazeY===
At another sample offset, the value of the <tt>EyetrackerRightEyeGazeX</tt> state may be read as 262138:
The eye gaze position (where - on the screen - the subject is looking) is returned from the Tobii SDK as 32 bit floating point numbers which (roughly) range from 0.0 to 1.0. They are multiplied by 65535 and stored as 16 bit integers in these states if the <code>LogGazeData</code> parameter is enabled.  (0,0) corresponds to the top left of the screen, (65535,65535) corresponds to the right bottom of the screen. -- See [[Contributions:EyetrackerLogger#EyetrackerStatesOK|EyetrackerStatesOK]].
*interpret 262138 as a signed 18 bit number -> -6
*subtract -6.3 -> -6-(-6.3) = 0.3
*multiply with 1e-5 -> 0.000003
*concatenate with "m" -> 0.000003m = 0.03mm.


===PosX, PosY===
'''Extending the sign bit:'''
The eye position relative to the camera in 2D space is returned if <code>LogEyePos</code> is enabled. Again, these are returned from the library as floating point numbers from 0.0 to 1.0 and are scaled to 16 bit integer values from 0 to 65535.  (0,0) corresponds to the top left of the camera's view, and (65535,65535) corresponds to the bottom right of the camera's view.
In order to interpret a positive 32-bit integer value as a signed N bit integer with N<32, bits
18 to 31 must be set to the same value (1 or 0) as the sign bit.
In Matlab, this may be achieved as follows:
x = ...
idx = find(x >= 2^(N-1));
  x(idx) = 2^N - x(idx);


===PupilSize===
In C or C++, one may write
The pupil size in mm is saved in this state if <code>LogPupilSize</code> is enabled. It corresponds to the length of the longest chord drawn from one side of the pupil to the other.  The size will change depending on the eye position and distance from the screen.  Although it is given in mm, it would be best to use this as a relative measurement.
int32_t x = ...
uint32_t mask = ~((1<<N)-1);
  if(x & mask)
  x |= mask;


===EyeDist===
==State Variables==
The distance between the screen and the eyes in mm is saved in this state if <code>LogEyeDist</code> is enabled.  This measurement is an approximation.  The actual measurement will depend on whether or not the test subject is wearing glasses or not.
===EyetrackerTime===
Time stamp of eye data as reported by the eye tracker, and converted into time units compatible
with the [[User_Reference:DataIOFilter#SourceTime|SourceTime data time stamp]].
Eye tracker data will be sample-aligned using this time stamp if possible, but may appear delayed
in a data file if transmission from the eye tracker is late.
In this case, the value of <tt>EyetrackerTime</tt> will differ from the value of [[User_Reference:DataIOFilter#SourceTime|SourceTime]] by more than a sample block duration in milliseconds.


===EyeValidity===
===EyetrackerLeftEyeGazeX, EyetrackerLeftEyeGazeY, EyetrackerRightEyeGazeX, EyetrackerRightEyeGazeY===
This state is a number from 0 to 4 and is documented in the Tobii SDK manual.  It is repeated here for convenience.
Screen position where the subject is looking at, rescaled such that, in raw state values, point (0,0) corresponds to the top left of the screen, and (65535, 65535) corresponds to the bottom right of the screen.
* 0 - The eye tracker is certain that the data for this eye is right.  There is no risk of confusing data from the other eye.
* 1 - The eye tracker has only recorded one eye and made some assumptions and estimations regarding which is the left and which is the right eye.  However, it is still very likely that the assumption made is correct.  The validity code for the other eye is in this case always set to 3.
* 2 - The eye tracker has only recorded one eye, and has no way of determining which one is the left eye and which one is the right eye.  The validity code for both eyes is set to 2.
* 3 - The eye tracker is fairly confident that the actual gaze data belongs to the other eye.  The other eye will always have validity code 1.
* 4 - The actual gaze data is missing or definitely belonging to the other eye.


{| class="wikitable"
===EyetrackerLeftEyePosX, EyetrackerLeftEyePosY, EyetrackerLeftEyeDist, EyetrackerRightEyePosX, EyetrackerRightEyePosY, EyetrackerRightEyeDist===
|-
Eye position in the same screen-relative coordinate system used for gaze data, extended by a Z axis normal to the screen plane, pointing towards the subject. Unlike X and Y coordinates, the Z coordinate's raw state value is not normalized but represents screen distance in millimeters. This measurement is an approximationThe actual measurement may depend on whether or not the test subject is wearing glasses or not.
! Code (Right - Left)
! Description
|-
| 0 - 0
| Both eyes found.  Data is valid for both eyes.
|-
| 0 - 4 or 4 - 0
| One eye found.  Gaze data is the same for both eyes.
|-
| 1 - 3 or 3 - 1
| One eye found. Gaze data is the same for both eyes.
|-
| 2 - 2
| One eye foundGaze data is the same for both eyes.
|-
| 4 - 4
| No eye found.  Gaze data for both eyes are invalid.
|}


It'd probably be wise to remove all data points with a validity state of 2 or higher while running your analysis.
===EyetrackerLeftPupilSize, EyetrackerRightPupilSize===
Pupil diameter as estimated by the eye tracker, scaled such that the raw state value represents the pupil diameter in tenths of millimeters (0.1mm).


===EyetrackerStatesOK===
===EyetrackerLeftEyeValidity, EyetrackerRightEyeValidity===
Early versions of the extension didn't take into account that the library may return a number greater than 1.0 or less than 0.0.  This resulted in "pac-man" style wrap around of gaze coordinates in 2.0 and crashes in 3.0.  If the output from the library is out of bounds, it is clamped to the boundaries and the "EyetrackerStatesOK" parameter is changed.  A value of "1" corresponds to valid gaze data, a value of "0" corresponds to invalid "clamped" gaze data. Use the "GazeOffset" and "GazeScale" parameters to avoid clamping.  Those parameters scale and offset the data so that when it does go out of range, it can still be fit into the 16 bit state.
A number ranging between 0 and 4, representing the eye tracker's confidence to have identified
the eye in question. As suggested in the Tobii3 SDK's manual, <tt>EyetrackerLoggerTobii3</tt> will ignore
any eye data with an associated validity value greater or equal to 2, but will report
time stamp and validity value for that data point nevertheless.
When eye data are being ignored, all respective state variables will keep their previous values.


==See also==
==See also==

Latest revision as of 14:58, 30 August 2017

Synopsis

A filter that records state information from Tobii Eyetrackers using the Tobii SDK 3.0 into state variables.

Location

http://www.bci2000.org/svn/trunk/src/contrib/Extensions/EyetrackerLoggerTobii3

Versioning

Authors

Kristopher Kaleb Goering (kaleb.goering@gmail.com)

Jürgen Mellinger (mellinger@neurotechcenter.org)

Version History

  • 2015-06-23: Initial public release
  • 2017-08-21:
    • adapted code to current version of BCI2000 framework
    • rewrote large parts for clarity
    • unified coordinate system for eye position, and gaze data

Source Code Revisions

  • Initial development: 4879
  • Tested under: 5696
  • Known to compile under: 5696
  • Broken since: --

Functional Description

Records data collected by a Tobii eye tracker, using version 3 of the Tobii SDK.

Integration into BCI2000

Compile the extension into your source module by enabling contributed extensions in your CMake configuration, and setting EXTENSIONS_EYETRACKERLOGGERTOBII3=On. Once the extension is built into the source module, enable it by starting the source module with the --LogEyetrackerTobii3=1 command line argument.

Usage and Calibration

Make sure the eye tracker is set up according to its user manual, and make sure it is able to connect to the Tobii calibration utility.

Calibration can now occur. Calibration should be done per subject per sitting. Re-calibration is not necessary between runs, but any time that the subject changes eye wear, makeup, or position, or if the lighting conditions change it should be re-calibrated. A good rule of thumb would be to recalibrate at the start of every session. Once a calibration is performed, it is saved in the Tobii device until the next calibration (even if there's a power loss).

Quit the calibration utility before starting BCI2000. When you start the source module, ensure that the --LogEyetrackerTobii3=1 command line parameter is set.

Coordinate System

When properly calibrated, the eye tracker will know about location, orientation, and extent of the display surface, relative to itself. Observing the subject through a camera, the eye tracker will be able to detect eye position and gaze direction, relative to its own position and orientation. Using calibration information, it can then determine gaze location as the intersection of gaze direction, and display surface, and it will transform gaze location into a more convenient coordinate system which is aligned to the display's edges.

To an experimenter, none of the involved coordinate systems is relevant, except for the screen-relative one in which gaze location is reported. Thus, it appears most natural to report eye position in the same screen-relative coordinate system, extended with a Z axis perpendicular to the screen, as illustrated below:

In this coordinate system, gaze position will always have a Z coordinate of 0, and the eye's Z coordinate will be its distance from the screen plane. An eye's position and gaze may thus be expressed by 5 coordinate values,

  • GazeX: X coordinate of gaze position,
  • GazeY: Y coordinate of gaze position,
  • EyePosX: X coordinate of eye,
  • EyePosY: Y coordinate of eye,
  • EyeDist: Z coordinate of eye

in the above coordinate system.

For the experimenter's convenience, X and Y coordinates are also normalized to a fixed range such that the Active Display Area's bottom right corner has coordinates (65535, 65535, 0) when expressed in raw recorded values. For compatibility reasons, eye position coordinates use the same normalized raw units as gaze position does in X and Y directions, but uses raw steps of 1mm for its Z coordinate.

Recovering original physical dimensions is possible using the EyetrackerData Parameter as explained below.

Parameters

User configurable Parameters

The eye tracker is configured in the Source tab within the EyetrackerLogger section.

LogEyetrackerTobii3

Set to 0 to disable the eye tracker logger.

GazeScale, GazeOffset (deprecated)

Incoming gaze and position data are transformed by first multiplying with GazeScale, then subtracting GazeOffset. These values may affect the precision in which gaze data is stored, and should always be set to GazeScale=1, GazeOffset=0.

GazeScale and GazeOffset were hacks introduced in the original EyetrackerLogger to address an issue with gaze data being clamped around the edges of the screen. EyetrackerLoggerTobii3 uses additional bits to avoid issues with values being out of range, so these parameters serve no useful purpose any more, and are kept solely for backward compatibility with the original EyetrackerLogger.

Descriptive Parameters

These parameters are used by the eye tracker logger in order to store information about the eye tracker's configuration, and to help interpretation of logged data in data analysis.

EyetrackerInfo

A list-valued parameter with a variable number of named entries, providing information about the eye tracker's properties and configuration.

Depending on eye tracker model and setup, the following entries may be present:

  • SerialNumber, Model, Generation, FirmwareVersion
  • UnitName (if set by the user)
  • FrameRate (if available)
  • IlluminationMode (if available)
  • LowBlinkMode (if available)

EyetrackerData

A matrix-valued parameter with two columns, and one row for each state variable written by the eye tracker logger, containing information required to recover the original physical units associated with eye tracker data when reading a data file.

For each row, its label matches the name of a BCI2000 state variable holding eye tracker data.

The row's first column contains a data type of the form [u]int<N> where N is the number of bits, and a u prefix indicates that a value is to be interpreted as unsigned rather than signed. (For signed values, the most significant bit represents sign, and must be specially taken account for.)

In the second column, the data elements of a PhysicalUnit object are present, separated with spaces, and in the following order:

  • offset in raw units,
  • gain,
  • symbol (of an SI unit, without prefix),
  • raw minimum (typically 0, but may indicate an estimated raw data minimum if different from raw maximum),
  • raw maximum (typically 0, but may indicate an estimated raw data maximum if different from raw minimum).

Examples: EyetrackerData may contain a row labeled EyetrackerRightEyeGazeX with a data type of "int18" and a physical unit of "-6.3 1e-5 m 0 0". At some sample offset, the value of the EyetrackerRightEyeGazeX state may be read as 2345. To recover the right gaze point's distance from the screen's left edge in original units, you may proceed as follows:

  • interpret 2345 as a signed 18 bit number -> 2345
  • subtract -6.3 -> 2345-(-6.3) = 2351.3
  • multiply with 1e-5 -> 0.023513
  • concatenate with "m" -> 0.023513m = 23.513mm.

At another sample offset, the value of the EyetrackerRightEyeGazeX state may be read as 262138:

  • interpret 262138 as a signed 18 bit number -> -6
  • subtract -6.3 -> -6-(-6.3) = 0.3
  • multiply with 1e-5 -> 0.000003
  • concatenate with "m" -> 0.000003m = 0.03mm.

Extending the sign bit: In order to interpret a positive 32-bit integer value as a signed N bit integer with N<32, bits 18 to 31 must be set to the same value (1 or 0) as the sign bit. In Matlab, this may be achieved as follows:

x = ...
idx = find(x >= 2^(N-1));
x(idx) = 2^N - x(idx);

In C or C++, one may write

int32_t x = ...
uint32_t mask = ~((1<<N)-1);
if(x & mask)
  x |= mask;

State Variables

EyetrackerTime

Time stamp of eye data as reported by the eye tracker, and converted into time units compatible with the SourceTime data time stamp. Eye tracker data will be sample-aligned using this time stamp if possible, but may appear delayed in a data file if transmission from the eye tracker is late. In this case, the value of EyetrackerTime will differ from the value of SourceTime by more than a sample block duration in milliseconds.

EyetrackerLeftEyeGazeX, EyetrackerLeftEyeGazeY, EyetrackerRightEyeGazeX, EyetrackerRightEyeGazeY

Screen position where the subject is looking at, rescaled such that, in raw state values, point (0,0) corresponds to the top left of the screen, and (65535, 65535) corresponds to the bottom right of the screen.

EyetrackerLeftEyePosX, EyetrackerLeftEyePosY, EyetrackerLeftEyeDist, EyetrackerRightEyePosX, EyetrackerRightEyePosY, EyetrackerRightEyeDist

Eye position in the same screen-relative coordinate system used for gaze data, extended by a Z axis normal to the screen plane, pointing towards the subject. Unlike X and Y coordinates, the Z coordinate's raw state value is not normalized but represents screen distance in millimeters. This measurement is an approximation. The actual measurement may depend on whether or not the test subject is wearing glasses or not.

EyetrackerLeftPupilSize, EyetrackerRightPupilSize

Pupil diameter as estimated by the eye tracker, scaled such that the raw state value represents the pupil diameter in tenths of millimeters (0.1mm).

EyetrackerLeftEyeValidity, EyetrackerRightEyeValidity

A number ranging between 0 and 4, representing the eye tracker's confidence to have identified the eye in question. As suggested in the Tobii3 SDK's manual, EyetrackerLoggerTobii3 will ignore any eye data with an associated validity value greater or equal to 2, but will report time stamp and validity value for that data point nevertheless. When eye data are being ignored, all respective state variables will keep their previous values.

See also

User Reference:Logging Input, Contributions:Extensions, Contributions:EyetrackerLogger