function out=legTrackerCleanData(data)
%legTrackerCleanData takes raw instrument data from the Leg Tracker,
%applies a 3 frame median filter and interpolates the frames to even 10ms
%intervals
%Usage:
%out=legTrackerCleanData(data)
%data = raw data from instrument, imported into N x 29 array.


medFilterSize=3;

% index the timestamp on each frame so that 0 is the start of data
% collection
data2=data;
data2(:,2)=data2(:,2)-data2(1,2);

% median filter each the vectors
data2(:,3:end)=medfilt1(data2(:,3:end),medFilterSize);

% interpolate to even 10ms frames, discard frame number
data3=interp1(data2(:,2),data2(:,2:end),0:10:data2(end,2));


out=data3;