eye-eeg icon indicating copy to clipboard operation
eye-eeg copied to clipboard

Bug? Incorrect saccade offset assigned in detecteyemovements.m

Open nabusch opened this issue 2 years ago • 2 comments

The landing position of the last saccade of each epoch is incorrect. This seems to be due to a bug in function detecteyemovements.m in line 360:

if endsmp(end) > size(gazexy,2), endsmp(end) = size(gazexy,2); end

The intention here seems to be that if the temporal offset of the last saccade ensmp(end) is later than the last sampling point of the epoch, then the offset should simply be the last available sampling point. However, if I understand correctly the code above refers to the wrong dimension of gazexy, which represents sampling points * eye channels (vertical, horizontal). Thus, the offset of the last saccade is almost garanteed to be later than size(gazexy,2) = 2.

I think the correct code should refer to the first dimension of gazexy:

if endsmp(end) > size(gazexy,1), endsmp(end) = size(gazexy,1); end

nabusch avatar Jun 02 '22 13:06 nabusch

Indeed, thanks for spotting this (major) bug. Gaze samples are indeed stored in rows, not columns (transposed from standared EEG.data format). Hotfixed in b4083ffcc4f325a45e7081f7ea3b8e572f369b3a

olafdimigen avatar Jun 02 '22 13:06 olafdimigen

What does this bug mean? This serious bug meant that a wrong offset latency (saccade offset sample) and a wrong saccade end position (gaze position at end of saccade) was assigned to the last saccade event in a given epoch, detected with the Engbert & Kliegl (2003) algorithm (function detecteyemovements()). Only the last detected saccade in any epoch is affected. This bug is obviously more severe if saccades were detected in epoched data, rather than in continuous data. Imported saccade events (e.g. Eyelink events) are not affected. Similarly fixation events, their (fixation) onset/offset latencies or their (fixation) gaze positions are not affected by the bug.

olafdimigen avatar Jun 03 '22 12:06 olafdimigen