Skip to content

Commit b051bbb

Browse files
committed
endT and dur fields of fixation output are now consistent
1 parent 738df22 commit b051bbb

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

functions/I2MC/getFixations.m

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,27 +131,33 @@
131131
end
132132
end
133133

134-
%% calculate fixation duration
135-
% if you calculate fixation duration by means of time of last sample during
136-
% fixation minus time of first sample during fixation (our fixation markers
137-
% are inclusive), then you always underestimate fixation duration by one
138-
% sample because you're in practice counting to the beginning of the
139-
% sample, not the end of it. To solve this, as end time we need to take the
134+
%% adjust fixation end time
135+
% since our fixation markers are inclusive, endT is at the end of the sample,
136+
% not at its start. At this stage in the code, endtime simply reflects the
137+
% timestamp of the end sample. But such a timestamp is for the beginning of
138+
% the sample, not for its end. To solve this, as end time we need to take the
140139
% timestamp of the sample that is one past the last sample of the fixation.
141-
% so, first calculate fixation duration by simple timestamp subtraction.
142-
fixdur = endtime-starttime;
143-
% then determine what duration of this last sample was
144-
extratime = timestamp(min(fixend+1,length(timestamp)))-timestamp(fixend); % make sure we don't run off the end of the data
140+
% this is also important for calculating fixation duration. Without this
141+
% adjustment, we would always underestimate fixation duration by one sample
142+
% because you're in practice counting to the beginning of the sample, not
143+
% the end of it.
144+
145+
% determine what the duration of each end sample was
146+
extratime = timestamp(min(fixend+1,length(timestamp)))-timestamp(fixend); % make sure we don't run off the end of the data
147+
145148
% if last fixation ends at end of data, we need to determine how long that
146149
% sample is and add that to the end time. Here we simply guess it as the
147150
% duration of previous sample
148151
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
149152
extratime(end) = diff(timestamp(end-1:end));
150153
end
151-
% now add the duration of the end sample to fixation durations, so we have
152-
% correct fixation durations
153-
fixdur = fixdur+extratime;
154-
154+
155+
% now add the duration of the sample to each fixation end time, so that they are
156+
% correct
157+
endtime = endtime+extratime;
158+
159+
%% calculate fixation duration
160+
fixdur = endtime-starttime;
155161

156162
%% check if any fixations are too short
157163
qTooShort = fixdur<minFixDur;

0 commit comments

Comments
 (0)