Commit a82761ad authored by Efe's avatar Efe

Relevant code and .mat files are added.

parents
clc;clear;
% Set this accordingly:
datasetToUse = 1; %% For MPIIDPEye
% datasetToUse = 2; %% For MPIIPrivacEye
if datasetToUse == 1
ReadMPIIDPEye;
differenceOutputPath = './DifferenceMatrices/MPIIDPEyeDifference.mat';
elseif datasetToUse == 2
ReadMPIIPrivacEye;
differenceOutputPath = './DifferenceMatrices/MPIIPrivacEyeDifference.mat';
end
calculateDifferencesAndStore(pamiFeaturesAll, recordingSizeArr, differenceOutputPath);
\ No newline at end of file
% For demonstration purposes:
relativeFilePath = './datasets/MPIIDPEye/Eye_Movement_Features/'
filenamePrefix = 'Data_P';
filenameMid = '_R';
filenameSuffix = '_Pami_Features_52.csv';
participantCounter = 20;
recordingCounter = 3;
filepathPrefix = strcat(relativeFilePath, filenamePrefix);
recordingSizeArr = [];
pamiFeaturesAll = [];
minPamiFeatures = [];
maxPamiFeatures = [];
for participantId = 1:participantCounter
for recordingId = 1:recordingCounter
fullFilePath = strcat(filepathPrefix, int2str(participantId), filenameMid, int2str(recordingId), filenameSuffix);
completePamiTable = readtable(fullFilePath, 'ReadVariableNames',false);
pamiFeatures = completePamiTable(:,:);
pamiFeaturesArr = pamiFeatures{:,:};
pamiFeaturesAll = [pamiFeaturesAll; pamiFeaturesArr];
recordingSizeArr = [recordingSizeArr; size(pamiFeaturesArr, 1)];
end
end
currentBlockStartIndx = 1;
startEndIndexMatRawPami = [];
for idx = 1:size(recordingSizeArr, 1)
currentArrSize = recordingSizeArr(idx,1);
startOfCurrentBlock = currentBlockStartIndx;
endOfCurrentBlock = startOfCurrentBlock + currentArrSize - 1;
currentBlock = pamiFeaturesAll(startOfCurrentBlock:endOfCurrentBlock,:);
startEndVector = [startOfCurrentBlock, endOfCurrentBlock];
startEndIndexMatRawPami = [startEndIndexMatRawPami; startEndVector];
currentBlockStartIndx = currentBlockStartIndx + currentArrSize;
end
% For demonstration purposes:
relativeFilePath = 'datasets/MPIIPrivacEye/Features_and_Ground_Truth/'
filenamePrefix = 'P';
filenameMid = '_R';
filenameSuffix = '_data.csv';
participantCounter = 20;
recordingCounter = 3;
totalNumberOfEyeMovementFeatures = 52;
filepathPrefix = strcat(relativeFilePath, filenamePrefix);
recordingSizeArr = [];
pamiFeaturesAll = [];
minPamiFeatures = [];
maxPamiFeatures = [];
for participantId = 1:participantCounter
% These participantIds do not exist in the dataset, skip.
% It makes 17 participants in total.
if participantId == 4 || participantId == 6 || participantId == 15
continue;
end
for recordingId = 1:recordingCounter
fullFilePath = strcat(filepathPrefix, int2str(participantId), filenameMid, int2str(recordingId), filenameSuffix);
completePamiTable = readtable(fullFilePath, 'ReadVariableNames',false);
pamiFeatures = completePamiTable(:,1:totalNumberOfEyeMovementFeatures);
pamiFeaturesArr = pamiFeatures{:,:};
pamiFeaturesAll = [pamiFeaturesAll; pamiFeaturesArr];
recordingSizeArr = [recordingSizeArr; size(pamiFeaturesArr, 1)];
end
end
currentBlockStartIndx = 1;
startEndIndexMatRawPami = [];
for idx = 1:size(recordingSizeArr, 1)
currentArrSize = recordingSizeArr(idx,1);
startOfCurrentBlock = currentBlockStartIndx;
endOfCurrentBlock = startOfCurrentBlock + currentArrSize - 1;
currentBlock = pamiFeaturesAll(startOfCurrentBlock:endOfCurrentBlock,:);
startEndVector = [startOfCurrentBlock, endOfCurrentBlock];
startEndIndexMatRawPami = [startEndIndexMatRawPami; startEndVector];
currentBlockStartIndx = currentBlockStartIndx + currentArrSize;
end
clear;clc;
% For demo purposes:
% Config:
datasetToUse = 1; %% For MPIIDPEye
% datasetToUse = 2; %% For MPIIPrivacEye
selectedFeatureIdx = 9; % Feature from datasets. Check datasets for more info.
selectedMinTVal = 5; % Start timepoint
selectedMaxTVal = 200; % End timepoint
shouldOriginalSignalUsed = 0; % 0 for differences, 1 for original signals.
if datasetToUse == 1
ReadMPIIDPEye;
load('./DifferenceMatrices/MPIIDPEyeDifference.mat', 'differenceMatrix');
elseif datasetToUse == 2
ReadMPIIPrivacEye;
load('./DifferenceMatrices/MPIIPrivacEyeDifference.mat', 'differenceMatrix');
end
startOfProcessing = 1;
r1Observations = [];
r2Observations = [];
r3Observations = [];
evaluatedRawMat = [];
numberOfRecordingTypes = 3;
if shouldOriginalSignalUsed == 1
evaluatedRawMat = pamiFeaturesAll;
else
evaluatedRawMat = differenceMatrix;
end
for idx = 1:size(recordingSizeArr, 1)
currentArrSize = recordingSizeArr(idx,1);
startOfCurrentBlock = startOfProcessing;
endOfCurrentBlock = startOfCurrentBlock + currentArrSize - 1;
currentBlock = evaluatedRawMat(startOfCurrentBlock:endOfCurrentBlock,:);
fetchedSignal = currentBlock(selectedMinTVal:selectedMaxTVal, selectedFeatureIdx);
if mod(idx,numberOfRecordingTypes) == 1
r1Observations = [r1Observations, fetchedSignal];
elseif mod(idx,numberOfRecordingTypes) == 2
r2Observations = [r2Observations, fetchedSignal];
else
r3Observations = [r3Observations, fetchedSignal];
end
startOfProcessing = startOfProcessing + currentArrSize;
end
totalObs = {r1Observations, r2Observations, r3Observations};
globalCorrCoefMat = [];
for rIdx = 1:numberOfRecordingTypes
evaluatedMat = totalObs{rIdx};
foundCorrCoefs = [];
for cIdx = 2:size(evaluatedMat,1)
corrCoeff = corrcoef(evaluatedMat(1,:), evaluatedMat(cIdx,:));
fetchedCoeff = corrCoeff(1,2);
foundCorrCoefs = [foundCorrCoefs; fetchedCoeff];
end
globalCorrCoefMat = [globalCorrCoefMat, foundCorrCoefs];
end
figure
plot(selectedMinTVal+1:selectedMaxTVal, globalCorrCoefMat(:,1), 'Color', '#fdae61', 'Marker', 'o', 'LineStyle', '-', 'MarkerSize',18, 'LineWidth', 3)
hold on
plot(selectedMinTVal+1:selectedMaxTVal, globalCorrCoefMat(:,2), 'Color', '#2b83ba', 'Marker', '+', 'LineStyle', '--', 'MarkerSize',18, 'LineWidth', 3)
hold on
plot(selectedMinTVal+1:selectedMaxTVal, globalCorrCoefMat(:,3), 'Color', '#7fc97f', 'Marker', '^', 'LineStyle', ':', 'MarkerSize',18, 'LineWidth', 3)
grid on
legend('Document Type-1','Document Type-2', 'Document Type-3', 'FontWeight', 'bold', 'Interpreter','latex',...
'Location', 'northeast','NumColumns', 3, 'FontSize',30)
set(gcf, 'Position', [5, 50, 1900, 500])
set(gca, 'FontWeight', 'bold', 'FontSize',40, 'TickLabelInterpreter', 'latex');
xlabel('$$\Delta{t}$$', 'Interpreter','latex')
ylabel('Correlation coefficients', 'Interpreter','latex', 'FontSize', 25)
xticks(0:20:200)
axis tight
xlim([0 selectedMaxTVal + selectedMinTVal])
if shouldOriginalSignalUsed == 0
ylim([-0.8 0.8])
yticks(-0.8:0.2:0.8)
else
ylim([0.2 1])
yticks(0.2:0.1:1)
end
ax = gca;
ax.GridAlpha = 0.3;
\ No newline at end of file
function calculateDifferencesAndStore(pamiFeaturesArg, recordingSizeArrArg, outputDiffPathArg)
differenceMatrix = [];
startOfProcessingId = 1;
recordingSizeArrLocal = recordingSizeArrArg;
pamiFeaturesAllLocal = pamiFeaturesArg;
for idx = 1:size(recordingSizeArrLocal, 1)
currentArrSize = recordingSizeArrLocal(idx,1);
startOfCurrentBlock = startOfProcessingId;
endOfCurrentBlock = startOfCurrentBlock + currentArrSize - 1;
currentBlock = pamiFeaturesAllLocal(startOfCurrentBlock:endOfCurrentBlock, :);
for i = 1:size(currentBlock,1)
if i == 1
zeroVect = zeros(1,size(currentBlock,2));
currentDiff = currentBlock(i,:) - zeroVect;
differenceMatrix = [differenceMatrix; currentDiff];
else
currentDiff = currentBlock(i,:) - currentBlock(i-1,:);
differenceMatrix = [differenceMatrix; currentDiff];
end
end
startOfProcessingId = startOfProcessingId + currentArrSize;
idx
end
save(outputDiffPathArg, 'differenceMatrix');
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment