Example #1
0
def test_indexes_connectivity(epochs):
    """
    Test index intra- and inter-brains
    """
    electrodes = analyses.indices_connectivity_intrabrain(epochs.epo1)
    length = len(epochs.epo1.info['ch_names'])
    L = []
    for i in range(1, length):
        L.append(length - i)
    tot = sum(L)
    assert len(electrodes) == tot
    electrodes_hyper = analyses.indices_connectivity_interbrain(
        epochs.epoch_merge)
    assert len(electrodes_hyper) == length * length
Example #2
0
def test_metaconn_matrix_2brains(epochs):
    """
    Test metaconn_matrix_2brains
    """
    # taking random freq-of-interest to test metaconn_freq
    freq = [11, 12, 13]
    # computing ch_con and sensors pairs for metaconn calculation
    con_matrixTuple = stats.con_matrix(epochs.epo1, freq, draw=False)
    ch_con_freq = con_matrixTuple.ch_con_freq
    sensor_pairs = analyses.indices_connectivity_interbrain(epochs.epoch_merge)

    # computing metaconn_freq and test it
    metaconn_matrix_2brainsTuple = stats.metaconn_matrix_2brains(
        sensor_pairs, con_matrixTuple.ch_con, freq)
    metaconn_freq = metaconn_matrix_2brainsTuple.metaconn_freq
    # take a random ch_name:
    random.seed(20)  # Init the random number generator for reproducibility
    # n = random.randrange(0, 63)
    # for our data taske into account EOG ch!!!
    n = random.randrange(0, len(epochs.epo1.info['ch_names']))
    tot = len(epochs.epo1.info['ch_names'])
    p = random.randrange(len(epochs.epo1.info['ch_names']),
                         len(epochs.epoch_merge.info['ch_names']) + 1)
    # checking for each pair in which ch_name is,
    # whether ch_name linked himself
    # (in neighbouring frequencies also)
    assert metaconn_freq[n + tot, p] == metaconn_freq[n, p]
    assert metaconn_freq[n - tot, p] == metaconn_freq[n, p]
    assert metaconn_freq[n + tot, p + tot] == metaconn_freq[n, p]
    assert metaconn_freq[n - tot, p - tot] == metaconn_freq[n, p]
    assert metaconn_freq[n, p + tot] == metaconn_freq[n, p]
    assert metaconn_freq[n, p - tot] == metaconn_freq[n, p]
    # and not in the other frequencies
    if metaconn_freq[n, p] == 1:
        for i in range(1, len(freq)):
            assert metaconn_freq[n + tot * (i + 1), p] != metaconn_freq[n, p]
            assert metaconn_freq[n - tot * (i + 1), p] != metaconn_freq[n, p]
            assert metaconn_freq[n + tot * (i + 1), p + tot *
                                 (i + 1)] != metaconn_freq[n, p]
            assert metaconn_freq[n - tot * (i + 1), p - tot *
                                 (i + 1)] != metaconn_freq[n, p]
            assert metaconn_freq[n, p + tot * (i + 1)] != metaconn_freq[n, p]
            assert metaconn_freq[n, p - tot * (i + 1)] != metaconn_freq[n, p]
            # check for each f if connects to the good other ch and not to more
            assert metaconn_freq[n + tot * i,
                                 p + tot * i] == ch_con_freq[n, p - tot]