function [ splitSignals, code ] = cutWindows( stimulusCodes, signal, params, t )
    changeIndices=cat(1,0,find(diff(double(stimulusCodes))));
    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+interval-1,:));
            code=cat(1,code,double(stimulusCodes(c+tempc)));
            tempc=tempc+interval;
        end
        c=c+codeCount(i);
    end
end

