function outmat = maxfilt1(inmat, len)
outmat = inmat;
for i = find(sum(inmat)>0)
    indi = max(1,i-len):min(size(inmat,2),i+len-1);
    temp = inmat(indi,:);
    outmat(i,:) = max(temp,[],1);
end

