function [recomp]=recompress(ray)
recomp=[];
unique_NaN=find(isnan(ray));
if length(unique_NaN)==0
    recomp=ray;
elseif length(unique_NaN)~=0
    if length(unique_NaN)>1
        diff=unique_NaN(2:length(unique_NaN))-unique_NaN(1:length(unique_NaN)-1);
        u_temp=find(diff~=1);
        if length(u_temp)~=0
            for i=1:length(u_temp)
                if unique_NaN(u_temp(i)) ~=1 & unique_NaN(u_temp(i))~=length(ray)
                    if ~isnan(ray(unique_NaN(u_temp(i))+1)) & ~isnan(ray(unique_NaN(u_temp(i))-1))
                        ray(unique_NaN(u_temp(i)))=-328.68;
                    end
                elseif unique_NaN(u_temp(i)) ==1 & unique_NaN(u_temp(i))~=length(ray)
                    ray(unique_NaN(u_temp(i)))=-328.68;
                elseif unique_NaN(u_temp(i)) ~=1 & unique_NaN(u_temp(i))==length(ray)
                    ray(unique_NaN(u_temp(i)))=-328.68;
                end
            end
            if unique_NaN(length(unique_NaN))~=length(ray)
              
                if ~isnan(ray(unique_NaN(length(unique_NaN))-1)) & ~isnan(ray(unique_NaN(length(unique_NaN))+1))
                    
                    ray(unique_NaN(length(unique_NaN)))=-327.68;
                end
            else
                if ~isnan(ray(unique_NaN(length(unique_NaN))-1))
                    ray(unique_NaN(length(unique_NaN)))=-327.68;
                end
            end
        end
    else
        ray(unique_NaN(u_temp(1)))=-328.68;
    end
end


u_NaN=find(isnan(ray));
if length(u_NaN)~=0
    if length(u_NaN)>1
        diff=u_NaN(2:length(u_NaN))-u_NaN(1:length(u_NaN)-1);
        u_temp=find(diff~=1);
        if length(u_temp)~=0
            for i=1:length(u_temp)-1
                miss=u_NaN(u_temp(i)+1):u_NaN(u_temp(i+1));
                L=length(miss);
                l=L-2;
                recomp=[recomp;L/100;-327.56;ray(u_NaN(u_temp(i+1))+1:u_NaN(u_temp(i+1)+1)-1)];
                
            end
            miss=u_NaN(1):u_NaN(u_temp(1));
            L=length(miss);
            recomp=[ray(1:u_NaN(1)-1);L/100;-327.56;ray(u_NaN(u_temp(1))+1:u_NaN(u_temp(1)+1)-1);recomp];
            
            miss=u_NaN(u_temp(length(u_temp))+1):u_NaN(length(u_NaN));
            L=length(miss);
            recomp=[recomp;L/100;-327.56;ray(u_NaN(length(u_NaN))+1:length(ray))];
        else
            L=length(u_NaN);
            recomp=ray;
            recomp(u_NaN(1))=L/100;
            recomp(u_NaN(2))=-327.56;
            if length(u_NaN)>3
                recomp(u_NaN(3:L))=[];
            end
        end
        
    end
else
    recomp=ray;
end

 if recomp(length(recomp))==-327.56
     recomp=recomp(1:length(recomp)-1);
 end
 if recomp(length(recomp))==-327.68
     recomp(length(recomp))=0.01;
 end
recomp=[recomp;0.01];
% if length(recomp)==3 & recomp(3)==-327.56
%     recomp=[length(ray);0.01];
% end
 if rem(length(recomp),2)~=0
     recomp=[recomp;25.00];
 end

recomp=100*recomp;