calculate fixation density at the AOIs Syntax: [ AOIDensity effectivNumFixation] = calcAOIFixDensityDist( 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 relative time spent at particular AOI
0001 % calculate fixation density at the AOIs 0002 % 0003 % Syntax: [ AOIDensity effectivNumFixation] = calcAOIFixDensityDist( 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 relative time spent at particular AOI 0016 0017 0018 function [ AOIDensity effectivNumFixation] = calcAOIFixDensityDist( fixStruct, aoiCenter, maxDist ) 0019 0020 0021 % fixationVector P 0022 fixPosVector = fixStruct.fixPosVector; 0023 fixDurVector = fixStruct.fixDurVector; 0024 0025 %calculate AOI fixation density 0026 numAOI = size(aoiCenter,2); 0027 numFixation = size( fixPosVector,2); 0028 AOIDensity = zeros( numAOI,1); 0029 effectivNumFixation = 0; 0030 0031 for i1 = 1:numFixation 0032 dist = calc2Dist( fixPosVector(:,i1), aoiCenter); % 2-norm 0033 [minDist minIdx] = min( dist); 0034 if minDist < maxDist 0035 effectivNumFixation = effectivNumFixation+1; 0036 AOIDensity(minIdx) = AOIDensity(minIdx) + fixDurVector(i1); 0037 end 0038 end 0039 0040 % normalize so the sum is 1 0041 if effectivNumFixation > 0 0042 AOIDensity = AOIDensity/sum( AOIDensity); 0043 end 0044 0045