function [ splitSignals, code ] = cutAll( states, signal )
% cut all in same length by dropping the tail

changeIndices=[find(diff(double(states.StimulusCode)));size(states.StimulusCode,1)];
codeCount=[diff(changeIndices); size(states.StimulusCode,1)-sum(diff(changeIndices))];

splitSignals=[];
code =zeros(size(codeCount,1));
c=codeCount(1);

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