%%% Making data
clear trials classes parameterSets;

load_eegdata;

subject = 1
tasks = [1 2 3 4 5]
%tasks = [2 3]
trials = 1:5
trials = squeeze(eegdata(subject,tasks,trials));
% Remove EOG channel
[nr,nc] = size(trials);
for r = 1:nr
  for c = 1:nc
    trials{r,c} = trials{r,c}(1:6,:);
  end
end

classes = repmat((1:length(tasks))',1,length(trials));

%%% Setting up matrix of parameter values
lags = 0:4;
nchannels = 6;
winShift = 32;
k = 0;
for winSize = [62 125]
  for nl = lags
    for nModes = 1:nchannels*(nl+1)
      for firstMode = 1:(nchannels*(nl+1))-nModes+1
	k = k + 1;
	parameterSets(k).nlags = nl;
	parameterSets(k).winSize = winSize;
	parameterSets(k).winShift = winShift;
	parameterSets(k).firstMode = firstMode;
	parameterSets(k).nModes = nModes;
      end
    end
  end
end

%%% Run all experiments
valreps = 5;
CV = general(trials,classes,parameterSets,0.2,valreps,...
    @makeMSFModes,@LDA,@selectModes);
  
%%% Display results

summarizeTestResults(CV);
