function [ splitSignals, code ] = cutTrials( states, signal )
%cut Trials only, ignore resting phases

noSamplesPerTrial=15000;
% count how many recorded values belong to one trial
changeIndices=[find(diff(double(states.StimulusCode)));size(states.StimulusCode,1)];
codeCount=[diff(changeIndices); size(states.StimulusCode,1)-sum(diff(changeIndices))];

splitSignals=[];
code=[];

c=1;

for i=1:size(codeCount,1)
    if(codeCount(i)==noSamplesPerTrial)
        splitSignals=cat(3,splitSignals,signal(c:c+codeCount(i)-1,:));
        code=cat(1,code,states.StimulusCode(c));
    end
    c=c+codeCount(i);
end
end

