コード例 #1
0
FONT_SIZE = 20
D_BINS = np.linspace(0, 12, 30)
L = 0.725

TEMP_FILE_NAME = 'reciprocity_temp.npy'
RECIPROCITY_FILE_NAME = 'reciprocity.npy'

###############################################
if not os.path.isfile(TEMP_FILE_NAME):
    # load brain graph
    print('Loading brain graph...')
    g_brain, a_brain, labels = brain_graph.binary_directed()
    brain_in_deg = g_brain.in_degree().values()
    brain_out_deg = g_brain.out_degree().values()
    # load distance matrix
    d_brain = load_brain_dist_matrix(labels, in_mm=True)

    # make two SG graphs and two TA graphs (each one with either L=0.725 or 0)
    print('Making example models...')
    g_sg_l_inf, a_sg_l_inf, d_sg_l_inf = source_growth(
        N=bc.num_brain_nodes,
        N_edges=bc.num_brain_edges_directed,
        L=np.inf,
        gamma=1,
        brain_size=BRAIN_SIZE)
    g_sg_l_0725, a_sg_l_0725, d_sg_l_0725 = source_growth(
        N=bc.num_brain_nodes,
        N_edges=bc.num_brain_edges_directed,
        L=L,
        gamma=1,
        brain_size=BRAIN_SIZE)
コード例 #2
0
ticksize = 10
legendsize = 8


def dist(x, y):
    return np.sqrt(np.sum((x - y)**2))


if __name__ == "__main__":
    # this isn't right... the third return object is a distance matrix

    # Get the connectome
    G, _, labels = binary_directed()
    nodes = G.nodes()
    new_labels = {nodes[i]: labels[i] for i in range(len(nodes))}
    distance_matrix = aux.load_brain_dist_matrix(new_labels)

    mds = manifold.MDS(n_components=3,
                       max_iter=1000,
                       eps=1e-10,
                       dissimilarity='precomputed')
    centroids = mds.fit_transform(distance_matrix)

    inter_node_distances = [
        dist(edge1, edge2) for edge1 in centroids for edge2 in centroids
        if not all(edge1 == edge2)
    ]

    G_sgpa, _, model_centroids = sgpa()
    model_distances = [
        model_centroids[edge1][edge2] for edge1 in G_sgpa.nodes()
コード例 #3
0
ファイル: fig5fs4.py プロジェクト: neofunkatron/neofunkatron
ticksize = 10
legendsize = 8


def dist(x, y):
    return np.sqrt(np.sum((x - y) ** 2))


if __name__ == "__main__":
    # this isn't right... the third return object is a distance matrix

    # Get the connectome
    G, _, labels = binary_directed()
    nodes = G.nodes()
    new_labels = {nodes[i]: labels[i] for i in range(len(nodes))}
    distance_matrix = aux.load_brain_dist_matrix(new_labels)

    mds = manifold.MDS(n_components=3, max_iter=1000, eps=1e-10, dissimilarity="precomputed")
    centroids = mds.fit_transform(distance_matrix)

    inter_node_distances = [dist(edge1, edge2) for edge1 in centroids for edge2 in centroids if not all(edge1 == edge2)]

    G_sgpa, _, model_centroids = sgpa()
    model_distances = [
        model_centroids[edge1][edge2] for edge1 in G_sgpa.nodes() for edge2 in G_sgpa.nodes() if edge1 != edge2
    ]

    fig, axs = plt.subplots(1, facecolor="white", figsize=(4, 2.8))
    fig.subplots_adjust(bottom=0.15, left=0.15)

    bins = np.linspace(0, 13, 51)
コード例 #4
0
ファイル: fig5_cde.py プロジェクト: neofunkatron/neofunkatron
D_BINS = np.linspace(0, 12, 30)
L = 0.725


TEMP_FILE_NAME = 'reciprocity_temp.npy'
RECIPROCITY_FILE_NAME = 'reciprocity.npy'

###############################################
if not os.path.isfile(TEMP_FILE_NAME):
    # load brain graph
    print('Loading brain graph...')
    g_brain, a_brain, labels = brain_graph.binary_directed()
    brain_in_deg = g_brain.in_degree().values()
    brain_out_deg = g_brain.out_degree().values()
    # load distance matrix
    d_brain = load_brain_dist_matrix(labels, in_mm=True)

    # make two SG graphs and two TA graphs (each one with either L=0.725 or 0)
    print('Making example models...')
    g_sg_l_inf, a_sg_l_inf, d_sg_l_inf = source_growth(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=np.inf,
        gamma=1, brain_size=BRAIN_SIZE)
    g_sg_l_0725, a_sg_l_0725, d_sg_l_0725 = source_growth(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=L,
        gamma=1, brain_size=BRAIN_SIZE)
    g_ta_l_inf, a_ta_l_inf, d_ta_l_inf = target_attraction(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=np.inf,
        gamma=1, brain_size=BRAIN_SIZE)
    g_ta_l_0725, a_ta_l_0725, d_ta_l_0725 = target_attraction(
        N=bc.num_brain_nodes, N_edges=bc.num_brain_edges_directed, L=L,
        gamma=1, brain_size=BRAIN_SIZE)