calculate matrix representing the sequence of AOIs fixated Syntax: [ AOISequence AOIDuration] =calcAOIFixSequence( eyePos, aoiCenter, maxDist, maxFixations) Inputs: fixStruct: returned from codeFixationsDist 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' maxFixations: number of fixations in the sequence to keep Outputs: AOISequence: matrix (numAOI x numFix) with an indicator (1) for in each column corresponding to the AOI of interest. If no AOI, it will be an all 0; AOIDuration: matrix (1 x numFix) for duration in number samples at that AOI, will be 0 if no AOI
0001 % calculate matrix representing the sequence of AOIs fixated 0002 % 0003 % Syntax: [ AOISequence AOIDuration] =calcAOIFixSequence( eyePos, aoiCenter, maxDist, maxFixations) 0004 % 0005 % Inputs: 0006 % fixStruct: returned from codeFixationsDist 0007 % aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m' 0008 % maxDist: maximum distance to a nearest AOI, anything further 0009 % considered not part of any AOI, returned by 'returnAOICenters.m' 0010 % maxFixations: number of fixations in the sequence to keep 0011 % 0012 % Outputs: 0013 % AOISequence: matrix (numAOI x numFix) with an indicator (1) for 0014 % in each column corresponding to the AOI of interest. If no 0015 % AOI, it will be an all 0; 0016 % AOIDuration: matrix (1 x numFix) for duration in number samples at that 0017 % AOI, will be 0 if no AOI 0018 0019 function [ AOISequence AOIDuration ] =calcAOIFixSequenceDist( fixStruct, aoiCenter, maxDist, maxFixations ) 0020 0021 0022 fixPosVector = fixStruct.fixPosVector; 0023 fixDurVector = fixStruct.fixDurVector; 0024 0025 % % % initialize some parameters 0026 if nargin < 4 || isempty( maxFixations ) 0027 maxFixations = 4; 0028 end 0029 0030 numAOI = size(aoiCenter,2); 0031 numFixation = size( fixPosVector,2); 0032 AOIOrderList = zeros(numFixation,1); 0033 AOIDurationList = zeros(numFixation,1); 0034 effectivNumFixation = 0; 0035 0036 % find AOI fixation sequence 0037 for i1 = 1:numFixation 0038 dist = calc2Dist( fixPosVector(:,i1), aoiCenter); % 2-norm 0039 [minDist minIdx] = min( dist); 0040 if minDist < maxDist 0041 effectivNumFixation = effectivNumFixation+1; 0042 AOIOrderList(effectivNumFixation) = minIdx; 0043 AOIDurationList(effectivNumFixation ) = fixDurVector(i1); %length(find(fixationVector==i1)); 0044 end 0045 end 0046 0047 % code as a matrix of indicator variables 0048 if effectivNumFixation >0 0049 AOISequence = zeros( numAOI, maxFixations); 0050 AOIDuration = zeros( 1, maxFixations); 0051 for i1 = 1:min(effectivNumFixation, maxFixations) 0052 AOISequence(AOIOrderList(i1),i1) = 1; % indicator for AOI (1) 0053 AOIDuration(i1) = AOIDurationList(i1); 0054 end 0055 0056 else % all 0 if no relevant AOI 0057 AOISequence = zeros( numAOI,maxFixations); 0058 AOIDuration = zeros( 1, maxFixations); 0059 end 0060 0061 0062 0063