calculate fixation density at the AOIs Syntax: [ AOIDensity effectivNumFixation] = calcAOIFixDurationDist( fixStruct, aoiCenter, maxDist ) Inputs: fixStruct: struct returned by codeFixations fixStruct.fixDurVector: vector of (fx1), for duration of fications fixStruct.fixPosVector: in format [ x x x ... x; y y y ... y] aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m' maxDist: maximum distance to a nearest AOI, anything further considered not part of any AOI, returned by 'returnAOICenters.m' Outputs: AOIDensity: vector of number of time spent at particular AOI the last entry is time outside of those AOIs
0001 % calculate fixation density at the AOIs 0002 % 0003 % Syntax: [ AOIDensity effectivNumFixation] = calcAOIFixDurationDist( fixStruct, aoiCenter, maxDist ) 0004 % 0005 % Inputs: 0006 % fixStruct: struct returned by codeFixations 0007 % fixStruct.fixDurVector: vector of (fx1), for duration of fications 0008 % fixStruct.fixPosVector: in format [ x x x ... x; 0009 % y y y ... y] 0010 % aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m' 0011 % maxDist: maximum distance to a nearest AOI, anything further 0012 % considered not part of any AOI, returned by 'returnAOICenters.m' 0013 % 0014 % Outputs: 0015 % AOIDensity: vector of number of time spent at particular AOI 0016 % the last entry is time outside of those AOIs 0017 0018 0019 function [ AOIDensity effectivNumFixation] = calcAOIFixDurationDist( fixStruct, aoiCenter, maxDist ) 0020 0021 0022 % fixationVector P 0023 fixPosVector = fixStruct.fixPosVector; 0024 fixDurVector = fixStruct.fixDurVector; 0025 0026 %calculate AOI fixation density 0027 numAOI = size(aoiCenter,2); 0028 numFixation = size( fixPosVector,2); 0029 AOIDensity = zeros( numAOI+1,1); 0030 effectivNumFixation = 0; 0031 0032 for i1 = 1:numFixation 0033 dist = calc2Dist( fixPosVector(:,i1), aoiCenter); % 2-norm 0034 [minDist minIdx] = min( dist); 0035 if minDist < maxDist 0036 effectivNumFixation = effectivNumFixation+1; 0037 AOIDensity(minIdx) = AOIDensity(minIdx) + fixDurVector(i1); 0038 else 0039 AOIDensity( end) = AOIDensity( end) + fixDurVector(i1); 0040 end 0041 end 0042 0043