From 7946a50bfdb32eeaaefa10dc8f7a80e2b8547366 Mon Sep 17 00:00:00 2001 From: Anna Leites Date: Wed, 27 Mar 2019 04:34:18 +0300 Subject: [PATCH] add function description --- docs/source/create-network.rst | 20 ++++++++++++++++---- scona/make_graphs.py | 6 +++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/source/create-network.rst b/docs/source/create-network.rst index a04b87c..e08e6a9 100644 --- a/docs/source/create-network.rst +++ b/docs/source/create-network.rst @@ -8,8 +8,6 @@ Minimum Spanning Tree --------------------- - why a connected graph? -Thresholding ------------- The BrainNetwork Class @@ -19,10 +17,24 @@ This is a very lightweight subclass of the :class:`networkx.Graph` class. This m All :class:`scona.BrainNetwork` **methods** have a corresponding ``scona`` **function**. So while the :class:`scona.BrainNetwork` methods can only be applied to :class:`scona.BrainNetwork` objects, you can find the equivalent function in ``scona`` which can be used on a regular :class:`networkx.Graph` object. -For example, if ``G`` is a :class:`scona.BrainNetwork` object, you can threshold it by typing ``G.threshold(10)``. If ``nxG`` is a :class:`Networkx.Graph` you can use ``scona.threshold_graph(nxG, 10)`` to perform the same function. - A :class:`BrainNetwork` can be initialised from a :class:`networkx.Graph` or from a correlation matrix represented as a :class:`pandas.DataFrame` or :class:`numpy.array`. +Threshold +------------ +if ``G`` is a :class:`scona.BrainNetwork` object, you can threshold it by typing ``G.threshold(10)``. If ``nxG`` is a :class:`Networkx.Graph` you can use ``scona.threshold_graph(nxG, 10)`` to perform the same function. + +This function creates a binary graph by thresholding weighted graph ``G``. + +First creates a spanning forest that is a union of the spanning trees for each connected component of the graph. + +Then adds in edges according to their connection strength up to cost. + + +The GraphBundle Class +---------------------- + +This is is a subclass of :class:`dict` containing :class:`str`: :class:`BrainNetwork` pairs. + Resources --------- \ No newline at end of file diff --git a/scona/make_graphs.py b/scona/make_graphs.py index 077ee80..ee4de6c 100644 --- a/scona/make_graphs.py +++ b/scona/make_graphs.py @@ -258,12 +258,12 @@ def is_anatomical_match(G, def weighted_graph_from_matrix(M, create_using=None): ''' - Create a weighted graph from an correlation matrix. + Create a weighted graph from a correlation matrix. Parameters ---------- M : :class:`numpy.array` - an correlation matrix + a correlation matrix create_using : :class:`networkx.Graph`, optional Use specified graph for result. The default is Graph() @@ -369,7 +369,7 @@ def threshold_graph(G, cost, mst=True): germ.remove_edges_from(G.edges) if mst: - # Calculate minimum spanning tree + # Calculate minimum spanning trees germ.add_edges_from(nx.minimum_spanning_edges(H)) # Make a list of the germ graph's edges