|
4 | 4 | import numpy as np |
5 | 5 | from numpy import pi |
6 | 6 | import scipy.interpolate as interpolate |
7 | | -from scipy.signal import convolve, gaussian |
| 7 | +from scipy.signal import convolve, windows |
8 | 8 | from scipy.linalg import hankel |
9 | 9 | import matplotlib.pyplot as plt |
10 | 10 | from matplotlib.collections import LineCollection |
@@ -114,7 +114,7 @@ def velocity_smoothed(pos, freq, smooth_size=0.03): |
114 | 114 | std_samps = np.round(smooth_size * freq) # Standard deviation relative to sampling frequency |
115 | 115 | N = std_samps * 6 # Number of points in the Gaussian covering +/-3 standard deviations |
116 | 116 | gauss_std = (N - 1) / 6 |
117 | | - win = gaussian(N, gauss_std) |
| 117 | + win = windows.gaussian(N, gauss_std) |
118 | 118 | win = win / win.sum() # Normalize amplitude |
119 | 119 |
|
120 | 120 | # Convolve and multiply by sampling frequency to restore original units |
@@ -274,7 +274,7 @@ def movements(t, pos, freq=1000, pos_thresh=8, t_thresh=.2, min_gap=.1, pos_thre |
274 | 274 | peak_amps = np.fromiter(peaks, dtype=float, count=onsets.size) |
275 | 275 | N = 10 # Number of points in the Gaussian |
276 | 276 | STDEV = 1.8 # Equivalent to a width factor (alpha value) of 2.5 |
277 | | - gauss = gaussian(N, STDEV) # A 10-point Gaussian window of a given s.d. |
| 277 | + gauss = windows.gaussian(N, STDEV) # A 10-point Gaussian window of a given s.d. |
278 | 278 | vel = convolve(np.diff(np.insert(pos, 0, 0)), gauss, mode='same') |
279 | 279 | # For each movement period, find the timestamp where the absolute velocity was greatest |
280 | 280 | peaks = (t[m + np.abs(vel[m:n]).argmax()] for m, n in zip(onset_samps, offset_samps)) |
|
0 commit comments