Skip to content

Commit 2eed622

Browse files
committed
fixation durations only, not also fixation end times should be extended by duration of the fixation end sample
1 parent fa4725f commit 2eed622

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

functions/I2MC/getFixations.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
end
7474

7575
%% beginning and end of fixation must be real data, not interpolated.
76-
% If interpolated, those bit(s) at the edge(s) is excluded from the
77-
% fixation first throw out fixations that are all missing/interpolated
76+
% If interpolated, those bit(s) at the edge(s) are excluded from the
77+
% fixation. First throw out fixations that are all missing/interpolated
7878
for p=length(starttime):-1:1
7979
if all(missing(fixstart(p):fixend(p)))
8080
fixstart(p) = [];
@@ -95,22 +95,26 @@
9595
end
9696
end
9797

98-
%% caluclate fixation duration
98+
%% calculate fixation duration
9999
% if you calculate fixation duration by means of time of last sample during
100100
% fixation minus time of first sample during fixation (our fixation markers
101101
% are inclusive), then you always underestimate fixation duration by one
102102
% sample because you're in practice counting to the beginning of the
103103
% sample, not the end of it. To solve this, as end time we need to take the
104104
% timestamp of the sample that is one past the last sample of the fixation.
105-
% so, first get new end time
106-
endtime = timestamp(min(fixend+1,length(timestamp))); % make sure we don't run off the end of the data
107-
% if last fixation ends at end of data, we need to make up how long that
108-
% sample is and add that to the end time
105+
% so, first calculate fixation duration by simple timestamp subtraction.
106+
fixdur = endtime-starttime;
107+
% then determine what duration of this last sample was
108+
extratime = timestamp(min(fixend+1,length(timestamp)))-timestamp(fixend); % make sure we don't run off the end of the data
109+
% if last fixation ends at end of data, we need to determine how long that
110+
% sample is and add that to the end time. Here we simply guess it as the
111+
% duration of previous sample
109112
if ~isempty(fixend) && fixend(end)==length(timestamp) % first check if there are fixations in the first place, or we'll index into non-existing data
110-
endtime(end) = endtime(end) + diff(timestamp(end-1:end));
113+
extratime(end) = diff(timestamp(end-1:end));
111114
end
112-
% now calculate fixation duration correctly.
113-
fixdur = endtime-starttime;
115+
% now add the duration of the end sample to fixation durations, so we have
116+
% correct fixation durations
117+
fixdur = fixdur+extratime;
114118

115119

116120
%% check if any fixations are too short

0 commit comments

Comments
 (0)