Skip to content

Commit

Permalink
updated all files for a small repo
Browse files Browse the repository at this point in the history
  • Loading branch information
parulv1 committed Aug 21, 2021
1 parent 79165a5 commit ad2d151
Show file tree
Hide file tree
Showing 36 changed files with 2,429 additions and 19 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.DS_Store
#ignore caches
__pycache__
.ipynb_checkpoints
*.pyc
.vscode

#ignore figures
**/*.jpg
**/*.svg
**/*.pdf
**/*.tiff
**/*.png

*.key

51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Contributing to spectrome-revisited
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.

## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
4. Ensure the test suite passes.
5. Make sure your code lints.
6. Issue that pull request!

## Any contributions you make will be under the MIT Software License
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.

## Report bugs using Github's [issues](https://github.com/briandk/transcriptase-atom/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](); it's that easy!

## Write bug reports with detail, background, and sample code
[This is an example](http://stackoverflow.com/q/12488905/180626) of a bug report I wrote, and I think it's not a bad model. Here's [another example from Craig Hockenberry](http://www.openradar.me/11905408), an app developer whom I greatly respect.

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can. [My stackoverflow question](http://stackoverflow.com/q/12488905/180626) includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

People *love* thorough bug reports. I'm not even kidding.

## Use a Consistent Coding Style
Use [`black`](https://pypi.org/project/black/).

## License
By contributing, you agree that your contributions will be licensed under its MIT License.

## References
This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/a9316a723f9e918afde44dea68b5f9f39b7d9b00/CONTRIBUTING.md)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Brain Networks Laboratory

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 9 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
# spectrome-revisited

[Xihe Xie](https://github.com/axiezai), [Megan J. Stanley](https://github.com/megstanley), & [Pablo F. Damasceno](https://github.com/pfdamasceno)

[![DOI](https://zenodo.org/badge/217634383.svg)](https://zenodo.org/badge/latestdoi/217634383)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Raj-Lab-UCSF/spectrome/master)

`Spectrome` is a combination of the words "spectrum" and "connectome". This package is the collection of codes that constructed the analysis for the publication ["Spectral graph theory of brain oscillations"](https://www.biorxiv.org/content/10.1101/589176v3).
`Spectrome` is a combination of the words "spectrum" and "connectome". This package is the collection of codes that constructed the analysis for the preprint ["Spectral graph theory of brain oscillations - revisited"](insert link). This repository is developed based on the original model's [repository](https://github.com/Raj-Lab-UCSF/spectrome).

The spectral graph model (SGM) is a brain structure-function model that simulates brain activity power spectrum given a structural connectome. The model is linear, low-dimensional, and provides an analytical relationship between the brain's structural and functional patterns.

## Citation:
The code in this repository is used for the analysis as shown in: Raj, Ashish, Chang Cai, Xihe Xie, Eva Palacios, Julia Owen, Pratik Mukherjee, and Srikantan Nagarajan. “Spectral Graph Theory of Brain Oscillations.” Human Brain Mappin. https://doi.org/10.1002/hbm.24991.


Code citation: Xihe Xie, Megan J. Stanley, & Pablo F. Damasceno. (2019, November 7). Raj-Lab-UCSF/spectrome: Spectral Graph Model of Connectomes (Version 0.15). Zenodo. http://doi.org/10.5281/zenodo.3532497
The code in this repository is used for the analysis as shown in: Parul Verma, Srikantan Nagarajan, and Ashish Raj. “Spectral Graph Theory of Brain Oscillations - revisited” (insert link).

## Abstract:
The relationship between the brain’s structural wiring and the functional patterns of neural activity is of fundamental interest in computational neuroscience. We examine a hierarchical, linear graph spectral model of brain activity at mesoscopic and macroscopic scales. The model formulation yields an elegant closed-form solution for the structure-function problem, specified by the graph spectrum of the structural connectome’s Laplacian, with simple, universal rules of dynamics specified by a minimal set of global parameters. The resulting parsimonious and analytical solution stands in contrast to complex numerical simulations of high dimensional coupled non-linear neural field models. This spectral graph model accurately predicts spatial and spectral features of neural oscillatory activity across the brain and was successful in simultaneously reproducing empirically observed spatial and spectral patterns of alpha-band (8-12 Hz) and beta-band (15-30Hz) activity estimated from source localized scalp magneto-encephalography (MEG). This spectral graph model demonstrates that certain brain oscillations are emergent properties of the graph structure of the structural connectome and provides important insights towards understanding the fundamental relationship between network topology and macroscopic whole-brain dynamics.
Mathematical modeling of the relationship between the functional activity and the structural wiring of the brain has largely been undertaken using non-linear and biophysically detailed mathematical models with regionally varying parameters. While this approach provides us a rich repertoire of multistable dynamics that can be displayed by the brain, it is computationally demanding. Moreover, although neuronal dynamics at the microscopic level are nonlinear and chaotic, it is unclear if such detailed nonlinear models are required to capture the emergent meso- (regional population ensemble) and macro-scale (whole brain) behavior, which is largely deterministic and reproducible across individuals. Indeed, recent modeling effort based on spectral graph theory has shown that an analytical model without regionally varying parameters can capture the empirical magnetoencephalography frequency spectra and the spatial patterns of the alpha and beta frequency bands accurately.

## Set-up:
In this work, we demonstrate an improved hierarchical, linearized, and analytic spectral graph theory-based model that can capture the frequency spectra obtained from magnetoencephalography recordings of resting healthy subjects. We reformulated the spectral graph theory model in line with classical neural mass models, therefore providing more biologically interpretable parameters, especially at the local scale. We demonstrated that this model performs better than the original model when comparing the spectral correlation of modeled frequency spectra and that obtained from the magnetoencephalography recordings. This model also performs equally well in predicting the spatial patterns of the empirical alpha and beta frequency bands.

To avoid going through the hustles of setting up a `conda` environment, you can simply click on the `Binder` badge above and run the Jupyter notebooks through a docker image on the cloud.
## Set-up:

---
First clone the environment to your computer, either download this repo as a `.zip` file or `git clone https://github.com/Raj-Lab-UCSF/spectrome.git`.

Set up a [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html) if you do not have all the packages/compatible versions. The list of dependencies is listed in `environment.yml`.
Expand All @@ -40,11 +31,10 @@ If you want to be able to run `spectrome` from anywhere, just add it's path to y
After completing the set-up for conda environment and `spectrome` path, you may go to the `spectrome` folder and type `jupyter notebook` or `jupyter lab` in your terminal to run the Jupyter notebooks.

## Files:
- `../spectrome/notebooks`: contains three jupyter notebooks, `run_model_example.ipynb` is the basic simulation of frequency spectrums with default parameters for the HCP template connectome. `SGM_frequency_responses` looks at the eigenvalues and their frequency responses, and `reproduce_MEG_spectra.ipynb` shows an example of the spectral graph model recapitulating empirical MEG spectra with optimized parameters.
- `../spectrome/notebooks`: contains three jupyter notebooks, `run_model_example.ipynb` is the basic simulation of frequency spectrums with default parameters for the HCP template connectome. `spatialcorrelation.ipynb` looks at the spatial correlations between the eigenmodes and the empirical spectra, and `reproduce_MEG_modeled_spectra.ipynb` compares optimized modeled spectra with the MEG spectra.

- `../spectrome/data`: contains intermediate data.
- `mean80_fibercount/length.csv`: HCP template connectome and distance matrix.
- The following `.mat` files come from Matlab structs, `..['output']['param']` are the fields for the optimized parameters, other fields are other outputs from the optimization algorith.
- `SCFC_opparam_individual.mat`: individual subject's connectivity matrices (N = 36).
- `SCFC_opparam_HCP.mat`: optimized model parameters for the HCP connectome.
- `freqMEGdata_8002-101.h5`: one example source localized MEG spectrum. Dictionary with region names attached to each column (keys).
- `individual_connectomes_reordered.nc`: individual subject's connectivity matrices (N = 36).
- `individual_psd_reordered_matlab.nc`: individual subject's MEG spectra (N = 36).
- `MSGM_Reordered_matlab_500iter.csv`: optimized model parameters for the 36 subjects.
20 changes: 20 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: spectrome
channels:
- conda-forge
dependencies:
- python=3 #or any python 3 should work
- pip
- matplotlib
- numpy
- scipy
- pandas
- xarray
- seaborn
- netCDF4
- pip:
- deepdish
- nitime
- python-csv
- sklearn
- tqdm==4.30.0
- jupyter
Binary file added spectrome/atlases/HCP_list.h5
Binary file not shown.
68 changes: 68 additions & 0 deletions spectrome/atlases/OrderingAlphabetical_68ROIs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
lh.bankssts
lh.caudalanteriorcingulate
lh.caudalmiddlefrontal
lh.cuneus
lh.entorhinal
lh.frontalpole
lh.fusiform
lh.inferiorparietal
lh.inferiortemporal
lh.insula
lh.isthmuscingulate
lh.lateraloccipital
lh.lateralorbitofrontal
lh.lingual
lh.medialorbitofrontal
lh.middletemporal
lh.paracentral
lh.parahippocampal
lh.parsopercularis
lh.parsorbitalis
lh.parstriangularis
lh.pericalcarine
lh.postcentral
lh.posteriorcingulate
lh.precentral
lh.precuneus
lh.rostralanteriorcingulate
lh.rostralmiddlefrontal
lh.superiorfrontal
lh.superiorparietal
lh.superiortemporal
lh.supramarginal
lh.temporalpole
lh.transversetemporal
rh.bankssts
rh.caudalanteriorcingulate
rh.caudalmiddlefrontal
rh.cuneus
rh.entorhinal
rh.frontalpole
rh.fusiform
rh.inferiorparietal
rh.inferiortemporal
rh.insula
rh.isthmuscingulate
rh.lateraloccipital
rh.lateralorbitofrontal
rh.lingual
rh.medialorbitofrontal
rh.middletemporal
rh.paracentral
rh.parahippocampal
rh.parsopercularis
rh.parsorbitalis
rh.parstriangularis
rh.pericalcarine
rh.postcentral
rh.posteriorcingulate
rh.precentral
rh.precuneus
rh.rostralanteriorcingulate
rh.rostralmiddlefrontal
rh.superiorfrontal
rh.superiorparietal
rh.superiortemporal
rh.supramarginal
rh.temporalpole
rh.transversetemporal
83 changes: 83 additions & 0 deletions spectrome/atlases/OrderingAlphabetical_86ROIs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
lh.bankssts
lh.caudalanteriorcingulate
lh.caudalmiddlefrontal
lh.cuneus
lh.entorhinal
lh.frontalpole
lh.fusiform
lh.inferiorparietal
lh.inferiortemporal
lh.insula
lh.isthmuscingulate
lh.lateraloccipital
lh.lateralorbitofrontal
lh.lingual
lh.medialorbitofrontal
lh.middletemporal
lh.paracentral
lh.parahippocampal
lh.parsopercularis
lh.parsorbitalis
lh.parstriangularis
lh.pericalcarine
lh.postcentral
lh.posteriorcingulate
lh.precentral
lh.precuneus
lh.rostralanteriorcingulate
lh.rostralmiddlefrontal
lh.superiorfrontal
lh.superiorparietal
lh.superiortemporal
lh.supramarginal
lh.temporalpole
lh.transversetemporal
lh_acumbens
lh_amygdala
lh_caudate
lh_hippocampus
lh_pallidum
lh_putamen
lh_thalamus

rh.bankssts
rh.caudalanteriorcingulate
rh.caudalmiddlefrontal
rh.cuneus
rh.entorhinal
rh.frontalpole
rh.fusiform
rh.inferiorparietal
rh.inferiortemporal
rh.insula
rh.isthmuscingulate
rh.lateraloccipital
rh.lateralorbitofrontal
rh.lingual
rh.medialorbitofrontal
rh.middletemporal
rh.paracentral
rh.parahippocampal
rh.parsopercularis
rh.parsorbitalis
rh.parstriangularis
rh.pericalcarine
rh.postcentral
rh.posteriorcingulate
rh.precentral
rh.precuneus
rh.rostralanteriorcingulate
rh.rostralmiddlefrontal
rh.superiorfrontal
rh.superiorparietal
rh.superiortemporal
rh.supramarginal
rh.temporalpole
rh.transversetemporal
rh_acumbens
rh_amygdala
rh_caudate
rh_hippocampus
rh_pallidum
rh_putamen
rh_thalamus
Empty file added spectrome/atlases/__init__.py
Empty file.
69 changes: 69 additions & 0 deletions spectrome/atlases/desikan_atlas_68.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Desikan_Freesurfer_v5.1,BrainMesh_ICBM152.nv,,,,,
lSF,superiorfrontal,-12.6,22.9,42.4,left,.
lFP,frontalpole,-8.6,61.7,-8.7,left,.
lRMF,rostralmiddlefrontal,-31.3,41.2,16.5,left,.
lCMF,caudalmiddlefrontal,-34.6,10.2,42.8,left,.
lPOB,parsorbitalis,-41,38.8,-11.1,left,.
lLOF,lateralorbitofrontal,-24,28.6,-14.4,left,.
lPT,parstriangularis,-42.4,30.6,2.3,left,.
lPOP,parsopercularis,-44.6,14.6,13.1,left,.
lMOF,medialorbitofrontal,-8,34.9,-14.9,left,.
lRAC,rostralanteriorcingulate,-6.8,33.9,1.6,left,.
lCAC,caudalanteriorcingulate,-6.6,18,26.1,left,.
lINS,insula,-34.2,-4.3,2.2,left,.
lPRC,precentral,-37.8,-10.7,42.1,left,.
lPOC,postcentral,-42.3,-23.8,43.6,left,.
lSUPRA,supramarginal,-50.4,-38.8,31,left,.
lSP,superiorparietal,-22.8,-60.9,46.3,left,.
lIP,inferiorparietal,-40,-66.4,27.3,left,.
lPARA,paracentral,-10,-28.7,56.1,left,.
lPCG,posteriorcingulate,-7.3,-17.4,35.7,left,.
rIST,isthmuscingulate,9.8,-44.8,16.9,left,.
lPREC,precuneus,-11.6,-57.5,36.7,left,.
lCUN,cuneus,-8.7,-79.6,18,left,.
lPERI,pericalcarine,-13.9,-80.6,6,left,.
lLIN,lingual,-16.5,-66.8,-4.3,left,.
lLO,lateraloccipital,-29.7,-86.9,-1,left,.
lTRANS,transversetemporal,-44,-24.2,6,left,.
lBKS,bankssts,-52.7,-44.5,4.6,left,.
lST,superiortemporal,-52.1,-17.8,-4.4,left,.
lMT,middletemporal,-55.6,-31.1,-12.9,left,.
lIT,inferiortemporal,-48.9,-34.4,-22.2,left,.
lTP,temporalpole,-32.8,8.4,-34.8,left,.
lENT,entorhinal,-25.8,-7.6,-31.6,left,.
lPHIP,parahippocampal,-24.7,-31.2,-17.4,left,.
lFUS,fusiform,-35.7,-43.3,-19.7,right,.
rSF,superiorfrontal,13.4,24.7,42,right,.
rFP,frontalpole,10.3,61.1,-10,right,.
rCAC,caudalanteriorcingulate,7.3,18.7,26.3,right,.
rCMF,caudalmiddlefrontal,34.9,11.8,43,right,.
rPOB,parsorbitalis,42.1,39.2,-10,right,.
rLOF,lateralorbitofrontal,23.6,28.5,-15.2,right,.
rPT,parstriangularis,45,29.7,4.5,right,.
rPOP,parsopercularis,44.9,14.4,14.2,right,.
rMOF,medialorbitofrontal,8.8,35.7,-14.8,right,.
rRMF,rostralmiddlefrontal,32.3,40.9,17.3,right,.
rRAC,rostralanteriorcingulate,8,33.5,2.1,right,.
rINS,insula,35.1,-3.9,2.4,right,.
rPRC,precentral,36.8,-9.9,43.5,right,.
rPOC,postcentral,41.6,-22.4,43.8,right,.
rSUPRA,supramarginal,50.6,-33.3,30.7,right,.
rSP,superiorparietal,22.6,-59.5,48.1,right,.
rIP,inferiorparietal,42.8,-60.9,28.1,right,.
rPARAC,paracentral,9.9,-27.4,55.6,right,.
rPCG,posteriorcingulate,7.6,-17.1,36.2,right,.
lIST,isthmuscingulate,-8.9,-45.4,17.6,right,.
rPREC,precuneus,11.7,-56.5,37.7,right,.
rCUN,cuneus,8.7,-80.1,19,right,.
rPERI,pericalcarine,14,-79.7,6.7,right,.
rLIN,lingual,16.8,-66.3,-3.6,right,.
rLO,lateraloccipital,30.3,-86.3,0.5,right,.
rTRANS,transversetemporal,44.8,-22.4,6.5,right,.
rBKS,bankssts,51.9,-40.6,5.6,right,.
rST,superiortemporal,53,-14,-5.5,right,.
rMT,middletemporal,55.9,-29.5,-12.9,right,.
rIT,inferiortemporal,49.3,-31.7,-23,right,.
rTP,temporalpole,34,8.4,-33.1,right,.
rENT,entorhinal,26.2,-6.8,-31.9,right,.
rPHIP,parahippocampal,26.1,-31.3,-16.2,right,.
rFUS,fusiform,35.9,-43,-19.2,right,.
Binary file added spectrome/atlases/desikan_atlas_68.xlsx
Binary file not shown.
Loading

0 comments on commit ad2d151

Please sign in to comment.