Savitzky-Golay Filter parameters for visualizing corresponding velocity profile

73 Views Asked by At

I have some Gaze position data(in pixels) that I have smoothened using a Savitzky-Golay filter with a first difference method. I intend to visualize the velocity of this eye data in order for further saccadic analysis of the eye data. Here's my code for the following :


x_smooth = savgol_filter(y2_int, window_length=251, polyorder=5, mode='nearest',deriv=1,delta=x_int[1] - x_int[0])
difference_x_gaze_internal = abs(np.diff(y2_int_smooth))

velocity_x_gaze_internal = difference_x_gaze_internal * 100
x_int_smooth = np.linspace(start_int, stop_int, 1953)

plt.subplot(2,1,1)
plt.plot(x_int, velocity_x_gaze_internal)
plt.title('Velocity_X_Gaze_Internal')
plt.subplot(2,1,2)
plt.plot(x_int_smooth, y2_int_smooth, linewidth=3)
plt.xlabel('Time(mS)')
plt.ylabel('Velocity(mm/s)')
plt.title("Position_data")

I have a large amount of eye data with a 100 Hz sampling rate, on plotting the corresponding velocity of the position data, I am getting a plot like this : Velocity+Postion plot

I don't think this is correct, because there are way too many peaks and changes in the velocity plot, even though it is supposed to me constant in certain fixation positions...is there something I should change in the filtering parameters? What should be the window length and polynomial order that I should consider taking?

0

There are 0 best solutions below