function [ splitSignals, code ] = cutWindows( states, signal, params, t )
    changeIndices=cat(1,0,find(diff(double(states.StimulusCode))));
    codeCount=diff(changeIndices);
    interval=t*params.SamplingRate.NumericValue;

    splitSignals=[];
    code=[];

    c=codeCount(1)+1;
    %cut windows of 1s
    for i=2:(size(codeCount,1)) %exclude beginning and end (stimulus 0)
        tempc=0;
        while codeCount(i)-tempc >= interval
            splitSignals=cat(3,splitSignals,signal(c+tempc:c+tempc+2499,:));
            code=cat(1,code,double(states.StimulusCode(c+tempc)));
            tempc=tempc+interval;
        end
        c=c+codeCount(i);
    end
end

