Saccade Detection Example

Software to accompany the paper "Detection of normal and slow saccades using implicit piecewise polynomial approximation" by Weiwei Dai, Ivan Selesnick, John-Ross Rizzo, Janet Rucker, and Todd Hudson

Tandon School of Engineering and School of Medicine
New York University
New York
USA

Contact: Ivan Selesnick selesi@nyu.edu Weiwei Dai wd471@nyu.edu

Contents

Load data

close all

% simulated eye movement data
load('data/simulation_type1.mat');  % 50 saccades of different amplitudes
Fs = 500;   % sampling rate (samples/second)
N = length(signal);

rng('default')
sigma = 0.7;
w = sigma * randn(N, 1);
y = signal + w;

DATA = [y zeros(N, 1) t];

Detect saccades

Tvelp = 30;
Tvel = 30;
Tdur = 12;

[sacc, nsac, xx1, mov_type] = eyetracking_denoising(DATA, Tvel, Fs, 1, Tdur);

SP1 = cell2mat(sacc(:,1));
EP1 = cell2mat(sacc(:,2));
amp1 = zeros(nsac,1);
pv1 = amp1;

for i = 1:nsac
    amp1(i) = abs(sacc{i,3}.amp);
    pv1(i) = abs(sacc{i,3}.pvel);
end

Plots

t = t - 35.5;
ax_pos = [0 2 5 30];
ax_vel = [0 2 -700 700];

% Position plot
figure(1), clf
ax1 = subplot(2,1,1);
hold on
l1 = plot(t, y, 'k');
l2 = plot(t, xx1(:,2), 'r');
line([1; 1]*t(SP1)', [-30 30], 'Color', [1 1 1]*0.8)
line([1; 1]*t(EP1)', [-30 30], 'Color', [1 1 1]*0.8, 'LineStyle', '--')
% line(t, reference*8, 'Color', 'm')
hold off
title(sprintf('%d saccades detected', nsac))
ylabel('Position (deg)')
axis(ax_pos)
legend([l1, l2], 'Noisy data', 'Denoised data')

% Velocity plot
ax2 = subplot(2,1,2);
plot(t, xx1(:,4), 'r')
line(t([1 end]), [Tvelp(1) Tvelp(1)], 'Color', 'g', 'LineStyle', '-.')
xlabel('Time (s)')
ylabel('Velocity (deg/s)')
axis(ax_vel)