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 enhancements to the scona #151

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ env:
secure: QvKbq/nKWPcVk5RrOD5rLUUioaM0iZ9PblW/ucd3zjPWdeJTKSG4BqFf+fWkLN+3aE9k+EeFsQ0voyKriKrSOHHOoHGIbROOdjM8+Uc06N8h1noJ/LLW1BBDbICtCMma70//QWYG+eqIGSBozp3tZ5QGbDZB5Nt5fNDSbO6rYJzfBF26jWAWjurB6E/6v+Dp3nbFRZ2Eju2/RG059w9Y5IK87n/GKUmiS3kRgLJaeSwvji8f6/29xVYsKhorw2GlQA0Es/rnXFHBF5tMqX1CrCjWGN2XH/MIRtrI7FxUz691LBXkGivOl8E6zjyKN/aTvjKe+PZHdF+VPCzjWMUklT2L5p4W6qbjxR+Uw/7ecfBeiTMkubzFig4kqpkz9skhfOiYCeEld+4dzl5mGFhpxwSXKLTQtVvwh7PGuuc22LWK4O5LyESv3jHHPyxEhB48GDc5illzalMqYw7+m/H1A8i4RSPx5xloNSMHmS1naNXq851kZmdLspqd67ECBNnLRN/AMfQIqltTlheFTYZk2hbD9g+fntjr1aboYIxyB1f33WSAJuyTBFagM/la/tVDUGM57WiV7dvLRXF1gXr4U7DzD7mUpflXmn75wCiuyNB4rWDv7LxEpgBR0iXJultzP0ewVPgAU31k8/rMapzfWwTX4z+kXgVNYJqe9XhBudY=
install:
- pip install -q networkx==$NETWORKX_VERSION
- pip install .
- pip install -q -r requirements.txt
- pip install sphinx sphinx sphinxcontrib-napoleon sphinx_rtd_theme
script:
- python3 -m pytest -v --ignore=tests/regression_test.py
# temporarily ignore regression tests while we investigate why they are failing
- python3 -m pytest --nbval-lax tutorials/
- cd docs
- make html
- touch .nojekyll
Expand Down
2 changes: 1 addition & 1 deletion docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Installing scona

You can install scona directly from the GitHub repository::

pip install git+https://github.com/WhitakerLab/scona.git
pip install -e git+https://github.com/WhitakerLab/scona.git#egg=scona

If you want to edit scona it's recommended that you pass the ``-e`` flag to ``pip`` to install the package editably.

Expand Down
33 changes: 31 additions & 2 deletions docs/source/plotting.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
Plotting Brain Networks
=======================

With nilearn
------------
A good visualisation is worth millions of words.
That's why our community put an emphasis on ensuring that the produced figures are informative and communicate the results clearly.

The :class:`scona` package has a great visualisation module, which enables you to produce publication-ready plots based on the results of the performed brain network analysis.
You are also able to export created figures (save as a file) to include in a research paper or in a publication.

As it says the best explanation is through demonstration. That's why we have created `tutorials <https://github.com/WhitakerLab/scona/tree/master/tutorials>`_ which are jupyter notebooks that include visualisation examples of the data.
In a clear and easy way, these tutorials explain how different visualisation functions can be used to produce different plots and for better data understanding.

1. Global Network Measures visualisation `tutorial <https://github.com/WhitakerLab/scona/blob/master/tutorials/global_measures_viz.ipynb>`_ describes how to use the following functions:
- plot_degree_dist() - tool for plotting the degree distribution
- plot_network_measures() - tool for plotting network measures values
- plot_rich_club() - tool for plotting the rich club values per degree

With the help of these functions, you can report measures relating to the whole network.

2. Interactive visualisation `tutorial <https://github.com/WhitakerLab/scona/blob/master/tutorials/interactive_viz_tutorial.ipynb>`_ provides examples on how to use functions like:
- view_nodes_3d() - view the nodes on a 3d plot
- view_connectome_3d() - view the edges - the connections - of the network on a 3d plot

These tools rely on the excellent `nilearn.plotting library <http://nilearn.github.io/plotting/index.html>`_.

3. Anatomical visualisation `tutorial <https://github.com/WhitakerLab/scona/blob/master/tutorials/anatomical_viz_tutorial.ipynb>`_ shows the usage of the following functions:
- plot_anatomical_network() - make plots of nodes and edges based on the given anatomical layout
- plot_connectome () - plot connectome on top of the brain glass schematics

These are static visualisions that you could use to report your findings in a published paper.


With proper visualization, a researcher can reveal findings easier, understand complex data relationships and describe obtained insights from analyzed data.

2 changes: 2 additions & 0 deletions docs/source/scona.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Subpackages
scona.wrappers
scona.datasets

**Note**: These subpackages (scona.wrappers, scona.scripts, scona.datasets) are represented as a set of features that will be incorporated into scona package. You **should not** open or/and use the code inside these packages, because the code inside **is not supported** and this part is in the alpha development phase.

Module contents
---------------

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ scikit-learn
networkx>=2.2
forceatlas2
nilearn==0.5.2
nbval
170 changes: 0 additions & 170 deletions scona/nilearn_plotting.py

This file was deleted.

46 changes: 46 additions & 0 deletions scona/visualisations_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,49 @@ def graph_to_nilearn_array(
"with the centroids.")

return adjacency_matrix, node_coords


def get_anatomical_layouts(G):
"""
This function extracts the required coordinates of a node based on the given
anatomical layout.

Parameters
----------

G : :class:`networkx.Graph`
G should have nodal locations in MNI space indexed by nodal
attribute "centroids".

Returns
-------
axial_dict, sagittal_dict, coronal_dict dictionaries
Returns three dictionaries containing appropriate pairs of coordinates
for axial, sagittal and coronal slices.
"""

# create empty dictionaries to store corresponding coordinates
axial_dict = {}
sagittal_dict = {}
coronal_dict = {}

# check if graph has centroids
if G.graph["centroids"] == False:
raise ValueError("The given BrainNetwork Graph does not have centroids")

for node in G.nodes:
# get x coordinate
x_coord = G.node[node]["x"]

# get y coordinate
y_coord = G.node[node]["y"]

# get z coordinate
z_coord = G.node[node]["z"]

# store appropriate pairs of coordinates for sagittal, coronal and axial
axial_dict[node] = axial_layout(x_coord, y_coord, z_coord)
sagittal_dict[node] = sagittal_layout(x_coord, y_coord, z_coord)
coronal_dict[node] = coronal_layout(x_coord, y_coord, z_coord)

return axial_dict, sagittal_dict, coronal_dict
6 changes: 3 additions & 3 deletions tutorials/global_measures_viz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:kwPython3]",
"display_name": "Python 3",
"language": "python",
"name": "conda-env-kwPython3-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1498,7 +1498,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
Loading