function output=replace_zeros(input)
%replaces zeros first by looking forward, if nothing forward is available by looking backward
%called from analyze_across_sd_stdp_expts to remove zeros before cp analysis

output=input;
for indx=1:length(input)
    if output(indx)==0
        goodunsforward=find(input((indx+1):end));
        if ~isempty(goodunsforward)
            output(indx)=input(goodunsforward(1)+indx);
        else
            goodunsback=find(input(1:(indx-1)));
            output(indx)=input(goodunsback(end));
        end
    end
end                        