Skip to content

KOP LEiDA

run_multiPatLEiDA(RSsig, delt, flp, fhi, k)

Run LEiDA Routine for BOLD signal.

Parameters:

Name Type Description Default
RSsig ndarray

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

required
delt

TR sample.

required
flp

low threshold frequency of filter

required
fhi

high threshold frequency of filter

required
k

filter order

required

Returns:

Name Type Description
tuple

phase: Phases array for all parcels/voxels in the format, syncConn: Synchronicity matrix for all parcels/voxels in the format, leidaArray: Leading eigenvector of synchornicity matrix

References

.. [1] Cabral, J. et al. (2017) ‘Cognitive performance in healthy older adults relates to spontaneous switching between states of functional connectivity during rest’, Scientific Reports. Nature Publishing Group, 7(1), p. 5135. doi: 10.1038/s41598-017-05425-7.

.. [2] Lord et al,. (2019). Dynamical exploration of the repertoire of brain networks at rest is modulated by psilocybin. NeuroImage, 199(April), 127–142. https://doi.org/10.1016/j.neuroimage.2019.05.060

Source code in dynfc/run_multiPatLEiDA.py
 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def run_multiPatLEiDA(RSsig, delt, flp, fhi, k):
    """Run LEiDA Routine for BOLD signal.

    Args:
        RSsig (ndarray): BOLD signal array for all parcels/voxels in the format [N, Tmax, Subs].
        delt: TR sample.
        flp: low threshold frequency of filter
        fhi: high threshold frequency of filter
        k: filter order

    Returns:
        tuple:
            phase: Phases array for all parcels/voxels in the format,
            syncConn: Synchronicity matrix for all parcels/voxels in the format,
            leidaArray: Leading eigenvector of synchornicity matrix

    References
    ----------

    .. [1]
    Cabral, J. et al. (2017) ‘Cognitive performance in healthy
    older adults relates to spontaneous switching between states
    of functional connectivity during rest’, Scientific Reports.
    Nature Publishing Group, 7(1), p. 5135.
    doi: 10.1038/s41598-017-05425-7.

    .. [2]
    Lord et al,. (2019). Dynamical exploration of the
    repertoire of brain networks at rest is
    modulated by psilocybin. NeuroImage, 199(April), 127–142.
    https://doi.org/10.1016/j.neuroimage.2019.05.060


    """

    Tmax = RSsig.shape[0]
    N = RSsig.shape[1]
    nSub = RSsig.shape[2]

    leidaArray = zeros([Tmax - 20, N, nSub])
    syncConn = zeros([N, N, Tmax - 20, nSub])
    phases = zeros([N, Tmax, nSub])

    #flp = .04              # lowpass frequency of filter
    #fhi = .07              # highpass
    npts = Tmax            # total nb of points
    #delt = 0.392               # sampling interval
    #k = 2                  # 2nd order butterworth filter

    for pat in range(nSub):

        timeserie = zeros([N, Tmax])
        signal = RSsig[:, :, pat].transpose()

        for seed in range(N):
            timeserie[seed, :] = butter_bandpass_filter(signal[seed, :],
                                                    flp, fhi, delt, k)
        print('Signal filtered.')
        phases[:, :, pat] = doHilbert(N, Tmax, timeserie)

        print('Phases obtained.')
        syncConnAux, leidaArrayAux = dPL(N, Tmax, phases[:, :, pat])
        syncConn[:, :, :, pat] = syncConnAux
        leidaArray[:, :, pat] = leidaArrayAux

        print('Matrices obtained.')
        print('Routine finished for patient no. ' + str(pat + 1) + '.')

    return phases, syncConn, leidaArray