-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi,
When using any method that requires a sliding window, I noticed that pydfc does not allow the user to specfy the standard deviation of the Gaussian. Rather, this is chosen automatically depending of the size of the window. In sliding_window.py:
window_taper = signal.windows.gaussian(W, std=3*W/22)
This is then used to create a Gaussian that is wider than the chosen window size:
window = signal.convolve(window, window_taper, mode='same') / sum(window_taper)
This is then accounted for by using wider windows:
np.multiply(time_series, window)[:,max(int(l-W/2),0):min(int(l+3*W/2),L)]
Is there a specific reason why this is implemented that way? For connectivity estimates, I would intuitively expect the window size to correspond the total included samples.
However, the main concern I have is that the same extended window is used for rectangular windows. As far as I can see, the resulting zero padding is not accounted for when calculating FC, leading to erroneous estimates.
Possible solutions could be:
- Use the fixed size for both windows (rectangular and tapered)
np.multiply(time_series, window)[:,l:l+W] - Handle the window shapes separately
Generally, I think the Pearson correlation estimation would also benefit from being vectorized instead of using nested loops as this would increase performance drastically.
I'm happy to discuss this further and can also provide a PR if that would be welcome.