|
1 | | -function [cutoff,fixstart,fixend,starttime,endtime,fixdur,xmedian,ymedian,flankdataloss,fracinterped] = getFixations(finalweights,timestamp,xpos,ypos,missing,cutoffstd,maxMergeDist,maxMergeTime,minFixDur) |
| 1 | +function [cutoff,fixstart,fixend,starttime,endtime,fixdur,xmedian,ymedian,flankdataloss,fracinterped] = getFixations(finalweights,timestamp,xpos,ypos,missing,cutoffstd,onoffsetThresh,maxMergeDist,maxMergeTime,minFixDur) |
2 | 2 | % determine fixations based on finalweights from 2-means clustering |
3 | 3 |
|
4 | 4 | % Roy Hessels - 2014 |
|
12 | 12 | % missing (originally, before interpolation!) |
13 | 13 | % cutoffstd = number of std above mean clustering-weight to |
14 | 14 | % use as fixation cutoff |
| 15 | +% onoffsetThresh = threshold (x*MAD of fixation) for walking |
| 16 | +% forward/back for saccade off- and onsets |
15 | 17 | % maxMergeDist = maximum Euclidean distance in pixels between fixations for merging |
16 | 18 | % maxMergeTime = maximum time in ms between fixations for merging |
17 | 19 |
|
|
43 | 45 | % get indices of where fixations start and end |
44 | 46 | [fixstart,fixend] = bool2bounds(fixbool); |
45 | 47 |
|
| 48 | +% for each fixation start, walk forward until recorded position is below a |
| 49 | +% threshold of lambda*MAD away from median fixation position. |
| 50 | +% same for each fixation end, but walk backward |
| 51 | +for p=1:length(fixstart) |
| 52 | + xmedThis = median(xpos(fixstart(p):fixend(p))); |
| 53 | + ymedThis = median(ypos(fixstart(p):fixend(p))); |
| 54 | + % MAD = median(abs(x_i-median({x}))). For the 2D version, I'm using |
| 55 | + % median 2D distance of a point from the median fixation position. Not |
| 56 | + % exactly MAD, but makes more sense to me for 2D than city block, |
| 57 | + % especially given that we use 2D distance in our walk here |
| 58 | + MAD = median(hypot(xpos(fixstart(p):fixend(p))-xmedThis, ypos(fixstart(p):fixend(p))-ymedThis)); |
| 59 | + |
| 60 | + thresh = MAD*onoffsetThresh; |
| 61 | + |
| 62 | + % walk until distance less than threshold away from median fixation |
| 63 | + % position. No walking occurs when we're already below threshold. |
| 64 | + i = fixstart(p); |
| 65 | + if i>1 % don't walk when fixation starting at start of data |
| 66 | + while hypot(xpos(i)-xmedThis,ypos(i)-ymedThis)>thresh |
| 67 | + i = i+1; |
| 68 | + end |
| 69 | + fixstart(p) = i; |
| 70 | + end |
| 71 | + |
| 72 | + % and now fixation end. |
| 73 | + i = fixend(p); |
| 74 | + if i<length(xpos) % don't walk when fixation ending at end of data |
| 75 | + while hypot(xpos(i)-xmedThis,ypos(i)-ymedThis)>thresh |
| 76 | + i = i-1; |
| 77 | + end |
| 78 | + fixend(p) = i; |
| 79 | + end |
| 80 | +end |
| 81 | + |
46 | 82 | % get start time, end time, and fix duration |
47 | 83 | starttime = timestamp(fixstart); |
48 | 84 | endtime = timestamp(fixend); |
|
0 commit comments