|
73 | 73 | end |
74 | 74 |
|
75 | 75 | %% 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 |
78 | 78 | for p=length(starttime):-1:1 |
79 | 79 | if all(missing(fixstart(p):fixend(p))) |
80 | 80 | fixstart(p) = []; |
|
95 | 95 | end |
96 | 96 | end |
97 | 97 |
|
98 | | -%% caluclate fixation duration |
| 98 | +%% calculate fixation duration |
99 | 99 | % if you calculate fixation duration by means of time of last sample during |
100 | 100 | % fixation minus time of first sample during fixation (our fixation markers |
101 | 101 | % are inclusive), then you always underestimate fixation duration by one |
102 | 102 | % sample because you're in practice counting to the beginning of the |
103 | 103 | % sample, not the end of it. To solve this, as end time we need to take the |
104 | 104 | % 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 |
109 | 112 | 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)); |
111 | 114 | 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; |
114 | 118 |
|
115 | 119 |
|
116 | 120 | %% check if any fixations are too short |
|
0 commit comments