Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function description #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions docs/source/create-network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Minimum Spanning Tree
---------------------
- why a connected graph?

Thresholding
------------


The BrainNetwork Class
Expand All @@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to leave this line where it is to illustrate the line above. This example is more about showing that class methods and functions come in pairs, rather than explaining the threshold 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
leytes marked this conversation as resolved.
Show resolved Hide resolved
------------
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
leytes marked this conversation as resolved.
Show resolved Hide resolved
----------------------

This is is a subclass of :class:`dict` containing :class:`str`: :class:`BrainNetwork` pairs.


Resources
---------
6 changes: 3 additions & 3 deletions scona/make_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
leytes marked this conversation as resolved.
Show resolved Hide resolved

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()

Expand Down Expand Up @@ -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
Expand Down