Calculate fixation density for different distances from relevant AOIs Syntax: histMatrix =calcAOIFixDistHist( eyePos, aoiCenter, numBins, AOIsOfInterest ) Inputs: eyePos: vector of complex (x+i*y) coordinates. -1-i1 to identify missing data. They are in range [ 0 ,1 ] aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m' numBins: number of bins to split up distance histogram AOIsOfInterest: index of AOIs which we are interested in Outputs: histMatrix: histogram of distances to all the AOIs, each column contains all fixation distance from to corresponding column of aoiCenter. The elements in column are repeated accordint time fixation time
0001 % Calculate fixation density for different distances from relevant AOIs 0002 % 0003 % Syntax: histMatrix =calcAOIFixDistHist( eyePos, aoiCenter, numBins, AOIsOfInterest ) 0004 % 0005 % Inputs: 0006 % eyePos: vector of complex (x+i*y) coordinates. -1-i1 to identify 0007 % missing data. They are in range [ 0 ,1 ] 0008 % aoiCenter: coordinates of AOI in image scale, returned by 'returnAOICenters.m' 0009 % numBins: number of bins to split up distance histogram 0010 % AOIsOfInterest: index of AOIs which we are interested in 0011 % 0012 % Outputs: 0013 % histMatrix: histogram of distances to all the AOIs, each column 0014 % contains all fixation distance from to corresponding column of aoiCenter. 0015 % The elements in column are repeated accordint time fixation time 0016 % 0017 0018 function histMatrix =calcAOIFixDistHistDist( fixStruct, aoiCenter, numBins, AOIsOfInterest, imRange ) 0019 0020 fixPosVector = fixStruct.fixPosVector; 0021 fixDurVector = fixStruct.fixDurVector; 0022 0023 if nargin < 5 || isempty(imRange) 0024 imRange = [1024; 1280]; 0025 end 0026 0027 % initialize some things 0028 numAOI = size(aoiCenter,2); 0029 numFixation = size( fixPosVector,2); 0030 distCell = cell( numFixation,1); 0031 if nargin < 4 || isempty(AOIsOfInterest) 0032 AOIsOfInterest = 1:numAOI; 0033 end 0034 if nargin < 3 || isempty(numBins) 0035 numBins = 10; 0036 end 0037 histMatrix = zeros( numBins, length(AOIsOfInterest)); 0038 xHist=linspace(0, imRange(2), numBins); 0039 0040 %calculate histogram of fixation distances 0041 k1 = 1; 0042 for i1 = AOIsOfInterest(:)' 0043 distTemp = calc2Dist( aoiCenter(:,i1), fixPosVector); % 2-norm 0044 for i2 = 1:numFixation; 0045 distCell{i2} = repmat(distTemp(i2), [fixDurVector(i2) ,1]); 0046 end 0047 distValuesTemp = cell2mat(distCell); 0048 n = hist( distValuesTemp, xHist); 0049 if sum(n)>0 0050 histMatrix(:,k1)= n./sum(n); 0051 end 0052 k1 = k1+1; 0053 0054 % % show it 0055 % bar( xHist,histMatrix(:,k1)); 0056 % pause(.5); 0057 0058 end 0059 0060