function [X]=Xfill(X)
  
%linear interpolation from single point on LHS to RHS [(n-j)*LHS+j*RHS]/n
%trim off end NaNs
%assume only NaN fails (x>-1000)
   
  t=find(X(:,1)>-1000);  %list found frames
  if size(t,1)>0
    X=X(t(1):t(end),:);  %trim to: [first:last] found frames 
    t=t-t(1)+1;
    f=setdiff([1:t(end)]',t);%missed frames
      
    if size(f,1)==1 
     X(f,:)=(X(f-1,:)+X(f+1,:))/2; %plug single hole
    else
     g=find(diff(f)>1);  %find start of missed sections (holes)	
     fg=[f(g);f(end)];   %fin holes
     f1=[f(1);f(g+1)];   %start holes
     ng=fg-f1+1;         %size holes	
     
     for k=1:size(fg,1)  %for each hole
       m=ng(k);
       s1=X(f1(k)-1,:);  %LHS hole 
       s2=X(fg(k)+1,:)-s1;%RHS hole=s1+s2
       for j=1:m          %for each frame in the hole
	X(f1(k)+j-1,:)=j*s2/(m+1)+s1;%linear interpolation across hole k
       end
     end     
    end
    
  else
    %empty video unchanged
  end
  
    
     
     
