Skip to content

Sliding window issues #31

@mibur1

Description

@mibur1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions