Getting Started: Analysing Smooth Pursuit Data in R
The attached R Script takes a Sample Report from Data Viewer, and outputs some basic smooth pursuit metrics. It expects the sample report to contain target position data - please see section 7.3.7 of the Data Viewer manual for details of how to send target position messages from your stimulus presentation script. The exception is if your pursuit target has a constant velocity, in which case the target_v variable in the main PursuitCalc functions can be given a constant value rather than reading in the target velocity from the sample report.

The parsing algorithm on the Host PC does not distinguish between fixations and smooth pursuit, so the script treats each fixation as a candidate "Pursuit Segment" and computes metrics for the samples within each segment (there are separate functions for the  X and Y dimensions).  The script will loop through all trials and participants in the report, and output the following metrics for each pursuit segment:

- Length (the number of samples in each candidate pursuit segment. Equivalent to ms if data is 1000Hz. Can be used to exclude short segments from further analysis, and to weight averages of velocity gain / RMSE. Can also be summed and divided by the number of pursuit segments to derive average pursuit duration.)
- Velocity Gain (the average of the ratio of eye velocity to target velocity for the samples in each pursuit segment. Low values (e.g. < 0.5) are unlikely to represent genuine pursuit and can be excluded from further analysis)
- RMSE (the average spatial offset between the eye and the target for the samples in each pursuit segment, in degrees of visual angle)

To use the R script, first run a Sample Report in Data Viewer and output the following variables:


Then set the working directory in R to the folder where this report was saved, and edit the script to read the correct report:


Run the script.

The script will automatically detect whether the trial contained horizontal or vertical pursuit data and run the appropriate function (PursuitCalcX or PursuitCalcY). For circular or diagonal pursuit, run the PursuitCalcX and PursuitCalcY functions separately. The script is set up to analyse data from the RIGHT eye - to output LEFT eye data do a simple search and replace of RIGHT for LEFT.

.zip (Size: 1.47 KB / Downloads: 40)

If you have any questions about this script or need assistance adapting it to suit your data, please contact