def create_graph(connectome, labels):
""" Create a graph structure from the connectome matrix.
Parameters
----------
connectome: array (N, N)
a matrix representing the structural connections.
labels: list of str (N,)
the labels used to create the connectome matrix.
Returns
-------
graph: Graph
a graph structure.
"""
graph = nx.from_numpy_matrix(connectome)
for index, name in enumerate(labels):
name = name.rstrip("\n")
graph.node[index] = {"label": name}
return graph
评论列表
文章目录