Code Monkey home page Code Monkey logo

network_tda_tutorial's Introduction

Notebook for Network and Topological Analysis in Neuroscience

Project Status: Active – The project has reached a stable, usable state and is being actively developed. GLP-3.0 License Python 3.7+

Stars Watchers

DOI

Authors: Eduarda Centeno & Fernando Santos

Contact information: [email protected] or [email protected]


Table of contents

  1. General information
  2. Requirements
  3. How to install
  4. Notes
  5. Acknowledgements

General information:

The primary purpose of this project is to facilitate the computation of Network Neuroscience metrics using Graph Theory and Topological Data Analysis.


This repository is a supplement to the preprint A hands-on tutorial on network and topological neuroscience and the final version published at Brain Structure and Function. It was also published as a book chapter at the International Conference on Geometric Science of Information.

In 2023, this work received two awards: an award under the Open Educational Resources category at the OSCAwards ceremony, and it was ranked first for the Best Paper Award given by Brain Structure and Function. Moreover, it was part of the application for a third award: the Neuro – Irv and Helga Cooper Foundation Open Science Trainee Prize.


We divided this notebook into two parts:

  1. The first part contains the standard computations of network and TDA metrics and visualizations.
  2. The second part is dedicated to the 3D visualizations developed by our group.
                  A video created with our 3D brain plots!


Requirements:

Here we will describe the core packages that will be necessary, but due to dependency compatibilities, we have provided a requirements.txt with all packages needed to be installed in a new Anaconda environment.

- Python: 3.x
- Numpy: 1.18.5
- Matplotlib: 3.3.2
- Meshio: 4.0.16 --- https://pypi.org/project/meshio/
- Seaborn: 0.11.0
- Pandas: 1.1.3
- Networkx: 2.4
- Nxviz: 0.6.2  --- For CircosPlot to work fully, we recommend installing through https://github.com/eduardacenteno/nxviz/
- Community (python-louvain): 0.13 --- https://python-louvain.readthedocs.io/en/latest/api.html
- Gudhi: 3.4.1 --- http://gudhi.gforge.inria.fr/
- Plotly: 4.6.0
- Scikit-learn: 0.24.1
- Scipy: 1.5.0
- JupyterLab: 1.2.0 --- This is very important; otherwise, plotly will not work as we intended. (https://plotly.com/python/getting-started/)

How to install:

We recommend creating a new environment in Anaconda dedicated for the use of these notebooks (Primarly tested on Windows/Linux).

  1. Create a new Anaconda environment with the correct python version (in Anaconda prompt or navigator)

  2. Activate the new environment in the command line (Anaconda prompt)

conda activate envname
  1. Change to the notebook's directory
cd path\to\notebookfolder
  1. Install packages using pip in Anaconda prompt

** with environment-specific python.exe (Windows)

path\to\anaconda3\envs\envname\python.exe -m pip install -r requirements.txt

** MacOS users do not need to give the path to the environment's python.exe

pip install -r requirements.txt
  1. Add jupyter-plotly labextension (key for 3D visualization)
jupyter labextension install jupyterlab-plotly 

Troubleshooting:

  1. Permission error and suggestion to use --user (possibly because the user did not use environment-specific python.exe)

    Try opening the prompt command as admin.

    Using pip install anaconda before installing packages will potentially solve the issue.

  2. Jupyter Lab is asking for Node.js 5+.

    Using conda install nodejs will potentially solve the issue.


Web-based options:

Nbviewer Jupyter Notebook Jupyter Lab* HTML
1-network_analysis.ipynb Binder Binder HTML
2-visualization_3d.ipynb Binder Binder HTML

* Binder is not building correctly plotly extensions in Jupyter Lab; therefore, 3D visualizations in the second notebook can only be seen using the jupyter notebook option!


Notes:

The jupyter notebooks can throw some warnings due to package updates and resulting deprecations. It is possible to use the following code lines to ignore these warnings:

import warnings

warnings.filterwarnings('ignore') 

Acknowledgements:

The 1000_Functional_Connectomes dataset was downloaded from the The UCLA multimodal connectivity database.

Brown JA, Rudie JD, Bandrowski A, Van Horn JD, Bookheimer SY. The UCLA multimodal connectivity database: a web-based platform for brain connectivity matrix sharing and analysis. Frontiers in neuroinformatics. 2012 Nov 28;6:28. (http://dx.doi.org/10.3389/fninf.2012.00028)

Biswal BB, Mennes M, Zuo XN, Gohel S, Kelly C, Smith SM, Beckmann CF, Adelstein JS, Buckner RL, Colcombe S, Dogonowski AM. Toward discovery science of human brain function. Proceedings of the National Academy of Sciences. 2010 Mar 9;107(10):4734-9. Freely available dataset

Rule A, Birmingham A, Zuniga C, Altintas I, Huang SC, Knight R, Moshiri N, Nguyen MH, Rosenthal SB, Pérez F, Rose PW. Ten simple rules for writing and sharing computational analyses in Jupyter Notebooks. https://github.com/jupyter-guide/ten-rules-jupyter

network_tda_tutorial's People

Contributors

eduardacenteno avatar fnobregasantos avatar multinetlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

network_tda_tutorial's Issues

Error while running HCP_Data_Vis.py of 2-visualization-3d Jupyter notebook

I got the following error while running HCP_Data_Vis.py of 2-visualization-3d Jupyter notebook, on my macbook with macOS High Sierra 10.13.6

  1. Creating 3D visualisations with Plotly
    First, we need to import the necessary backup script. Then, it is possible to use a list of values for most of the nodal metrics, e.g., centralities, etc.
     
    %run "/Users/oswaldoartiles/networkTDA/network_TDA_tutorial/Background Scripts/HCP_Data_Vis.py"

ValueError Traceback (most recent call last)
~/networkTDA/network_TDA_tutorial/Background Scripts/HCP_Data_Vis.py in
1397
1398 ## Create gray shell
-> 1399 brain_mesh = meshio.read(path_brainobj) # Reading a brain.obj file
1400 brain_trace = shell_brain(brain_mesh)
1401 trace1, _, _, _ = dictpos(areas, path_pos) # Transparent shell

~/anaconda3/lib/python3.7/site-packages/meshio/_helpers.py in read(filename, file_format)
67 raise ReadError(msg)
68
---> 69 return reader_mapfile_format
70
71

~/anaconda3/lib/python3.7/site-packages/meshio/obj/_obj.py in read(filename)
17 def read(filename):
18 with open_file(filename, "r") as f:
---> 19 mesh = read_buffer(f)
20 return mesh
21

~/anaconda3/lib/python3.7/site-packages/meshio/obj/_obj.py in read_buffer(f)
91 )
92
---> 93 return Mesh(points, cells, point_data=point_data)
94
95

~/anaconda3/lib/python3.7/site-packages/meshio/_mesh.py in init(self, points, cells, point_data, cell_data, field_data, point_sets, cell_sets, gmsh_periodic, info)
60 if len(self.point_data[key]) != len(self.points):
61 raise ValueError(
---> 62 f"len(points) = {len(points)}, "
63 f'but len(point_data["{key}"]) = {len(point_data[key])}'
64 )

ValueError: len(points) = 54284, but len(point_data["obj:vn"]) = 48585

installation issues

Describe the bug
Use the requirements.txt from the GitHub, inside the anaconda environment with python version 3.10.9, during the installation, encountered many "subprocess-exited-with-error" during pip install -r requirements.txt.

So I created a new requirements.txt file only use the libraries list in the suggested requirements inside the README file as below.
But still encountered the same installation errors.
numpy==1.18.5
matplotlib==3.3.2
meshio==4.0.16
seaborn==0.11.0
pandas==1.1.3
networkx==2.4
nxviz==0.6.2
community==0.13
gudhi==3.4.1
plotly==4.6.0
scikit-learn==0.24.1
scipy==1.5.0
jupyterlab==1.2.0

Screenshots
image

Desktop (please complete the following information):
system:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

Please help me on the installation issues and looking forward to your reply. Thank you very much.

Xin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.