|
131 | 131 | end |
132 | 132 | end |
133 | 133 |
|
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 |
140 | 139 | % 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 | + |
145 | 148 | % if last fixation ends at end of data, we need to determine how long that |
146 | 149 | % sample is and add that to the end time. Here we simply guess it as the |
147 | 150 | % duration of previous sample |
148 | 151 | 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 |
149 | 152 | extratime(end) = diff(timestamp(end-1:end)); |
150 | 153 | 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; |
155 | 161 |
|
156 | 162 | %% check if any fixations are too short |
157 | 163 | qTooShort = fixdur<minFixDur; |
|
0 commit comments