function sector = medianGuided_angle_rectify(sector)
    tailLength = 10;
    Shift = [0,pi,-pi,2*pi,-2*pi];
    initialRegion = 20;
    for i = 1:size(sector,2)
        t = i - tailLength;
        if initialRegion < 0
            guideValue = median(sector(:,t:i),"all",'omitnan');
        else
            guideValue = -pi/2;
        end
        finiteValueFound = false;
        for r = 1:size(sector,1)
            if isfinite(sector(r,i))
                diff = inf;
                idx = 0;
                for k = 1:length(Shift)
                    currentDiff = abs(sector(r,i)+Shift(k) - guideValue);
                    if currentDiff < diff
                        diff = currentDiff;
                        idx = k;
                    end
                end
                sector(r,i) = sector(r,i) + Shift(idx);
                finiteValueFound = true;
            end
        end
        if finiteValueFound
            initialRegion = initialRegion - 1;
        end
    end
    rescaleGuide = median(sector,"omitnan");
    rescaleGuide = rescaleGuide(isfinite(rescaleGuide));
    rescaleGuide = medfilt1(rescaleGuide,20,'truncate');% remove bias due to one off values..
    currentMin = min(rescaleGuide);%minGuide;
    finalMin = -pi/2;
    sector = sector - (currentMin - finalMin);
end
