%% file to simulate the challenge process

% load data
clear all;
close all;
clc

data_dir = '~/Documents/Research/CinCChallenge2017/CinC2017/training2017/';

%% Load the list of records in the validation set.
fid = fopen([data_dir 'RECORDS'],'r');
if(fid ~= -1)
    RECLIST = textscan(fid,'%s');
else
    error(['Could not open ' data_dir 'RECORDS for scoring. Exiting...'])
end
fclose(fid);
RECORDS = RECLIST{1};

%% load reference file
reffile = ['~/Documents/Research/CinCChallenge2017/CinC2017/training2017' filesep 'REFERENCE.csv'];

fid = fopen(reffile, 'r');
if(fid ~= -1)
    Ref = textscan(fid,'%s %s','Delimiter',',');
else
    error(['Could not open ' reffile ' for scoring. Exiting...'])
end
fclose(fid);

RECORDS = Ref{1};
target  = Ref{2};
N       = length(RECORDS);

%% Go through all records
P=[]; %predictions
for i = 1:N
    fname = RECORDS{i};
    prediction=challenge(['~/Documents/Research/CinCChallenge2017/CinC2017/training2017' filesep  fname]);
    P=[P prediction];
end
[P' target]