# Applying sgolay filter (derivatives) on data with variable Fs

조회 수: 14(최근 30일)
Francisco Dias 23 May 2020
댓글: Natalie St. John 16 Jun 2020 15:25
I have some x and y (pixel) coordinates recorded by an eye-tracking device that were collected using a sensor that as not a steady Fs (sample rate) and want to apply a SGOLAY filter to my signal to remove noise and compute the velocity and acceleration of the movement.
I'm following the example in the Mathworks help secction regarding Savitzky-Golay Differentiation. But they use a predetermined fixed Fs can someone help me and explain how can I apply the filter for an variable Fs (I have the time of aquisition of each coordinate in seconds).
"In principle, this filter finds the polynomial function that best describes the raw data and differentiates the polynomial analytically to avoid adding noise. It then resamples the differentiated polynomial to the original sampling fre- quency. Applying the sgolay function in MATLAB, we can f ind a set of SG differentiation f ilters, which, given the raw gaze coordinates (xi, yi), output smoothed ve- locity (xi, yi) and acceleration (xi, yi) data for the x- and y-dimensions separately. Then the total angular velocity and acceleration are calculated as the Euclidean distance of the x- and y-components: where PHI denotes a factor for converting from pixels to visual degrees. Velocity and acceleration data were ap- propriately adjusted to compensate for the time shift in- troduced by the filters."
I'm trying to apply this, algorythm.. but I'm dueling to understand what they are actually doing.. it looks like they are passing coordinates to the sgolay and they are given an output of component velocity/acceleration.

#### 댓글 수: 1

Natalie St. John 16 Jun 2020 15:25
Hi! I unfortunately can't help you with your question regarding variable frequencies. However, I'm also using the methods in the Nystrom & Holmqvist 2010 paper to classify saccades and fixations from gaze coordinates. I have one note: in the second function you posted (for acceleration), shouldn't you multiply by the frequency squared, since it is the 2nd derivative?

### 채택된 답변

Star Strider 24 May 2020
Every signal processing technique that I am aware of (except the newly-introduced nufft function) requires uniformly-sampled signals. Since you have the Signal Processing Toolbox, use the techniques described in: Interpolate/Adjust to new Sampling Rate to create a uniform sampling interval. Then proceed with sgolay as described in the documentation to get the derivatives.
I have no experience with sgolay in that respect, only sgolayfilt, so my ability to help you with it is limited to the documentation that you have already discovered. I generally calculate numeric derivatives using the gradient function on signals that have already been smoothed, since taking the derivative amplifies any noise that might be present.
.