Skip to content

Sliding windows correlations

corr_slide(series, size, slide=None)

Run cofluctuation analysis for BOLD signal.

Parameters:

Name Type Description Default
series double

BOLD signal array for all parcels/voxels in the format [N, Tmax].

required
size int

Size of sliding window.

required
slide int

Shift between windows. The standard value is the window size. Non-overlapping.

None

Returns:

Name Type Description
double

Cofluctuation matrix for all parcels/voxels in the format [N, N, window].

References

.. [1] Hansen, E. C. A. et al. (2015) ‘Functional connectivity dynamics: Modeling the switching behavior of the resting state’, NeuroImage. The Authors, 105, pp. 525–535. doi: 10.1016/j.neuroimage.2014.11.001.

Source code in dynfc/corr_slide.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def corr_slide(series, size, slide = None):
    """Run cofluctuation analysis for BOLD signal.

    Args:
        series (double): BOLD signal array for all parcels/voxels in the format [N, Tmax].
        size (int): Size of sliding window.
        slide (int, optional): Shift between windows. The standard value is the window size.
            Non-overlapping.

    Returns:
        double: Cofluctuation matrix for all parcels/voxels in the format [N, N, window].

    References
    ----------

    .. [1] 
    Hansen, E. C. A. et al. (2015) ‘Functional connectivity dynamics: Modeling the switching 
    behavior of the resting state’, NeuroImage. The Authors, 105, pp. 525–535. 
    doi: 10.1016/j.neuroimage.2014.11.001.


    """
    if slide == None:
        slide = size

    idx = arange(0, series.shape[1], slide)
    corr_mats = zeros((series.shape[0], series.shape[0], idx.shape[0]))

    for w in range(idx.shape[0]):
        corr_mats[:, :, w] = corrcoef(series[:, 0 + idx[w]: size + idx[w]])

    return corr_mats, idx