TRACKPixx Demo 4 -- Recording and plotting eye position data from the TRACKPixx3 ==================================================================================== .. Note:: This demo requires TRACKPixx Revision 18 or later. You can check for recent firmware updates at vpixx.com/whatsnew .. Note:: This demo assumes you have already calibrated the TRACKPixx3 for the session. You can calibrate using the PyPixx GUI, or run TPxTrackpixx3CalibrationTesting() in MATLAB. If the tracker is not calibrated, the eye positions returned by this demo will be NaN. In this demo we display a series of squares. When the user presses "Enter", the TRACKPixx3 records eye data for 4 seconds, and then plots the result. We trigger recording using the sequence ``Datapixx('SetupTPxSchedule');`` , ``Datapixx('StartTPxSchedule');`` , and when finished, ``Datapixx('StopTPxSchedule');``. Each of these commands must be followed by a ``Datapixx('RegWrRd');`` to push them to the device register and initiate/finish recording. To read the buffer of recorded data from the TRACKPixx, we call ``status = Datapixx('GetTPxStatus');``. New data is first isolated in ``toRead = status.newBufferFrames;``, and then interpreted using ``Datapixx('ReadTPxData', toRead);``. TRACKPixx buffer data has the following format: Timetag, Left Eye X, Left Eye Y, Left Pupil Diameter, Right Eye X, Right Eye Y, Right Pupil Diameter, Digital Input Values (24 bits), Left Blink Detection, Right Blink Detection, Digital Output Values (24 bits), Left Eye Fixation Flag, Right Eye Fixation Flag, Left Eye Saccade Flag, Right Eye Saccade Flag, Message code, Left Eye Raw X, Left Eye Raw Y, Right Eye Raw X, Right Eye Raw Y. Finally, we generate three figures, which plot X and Y position over time for the left eye, the right eye, and both eyes. By default, we plot the calibrated eye positions. Raw position can be plotted instead by changing the column of the buffer data used in ``plot()``. Data points where the X and Y positions equal 9000 are frames in which the eye position was lost (i.e., the participant blinked). .. literalinclude:: ../DatapixxToolbox/DatapixxDemos/TPxRawRecordAndPlot.m :language: matlab :linenos: