Skip to content

Commit 8b6e509

Browse files
authored
Merge pull request #135 from neurolib-dev/documentation/mkdocs
πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€ Automatic documentation πŸš€πŸš€πŸš€πŸš€πŸš€πŸš€
2 parents 3edcaa2 + 98e048b commit 8b6e509

36 files changed

+1438
-145
lines changed

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: ci
52

63
on:
@@ -21,26 +18,26 @@ jobs:
2118

2219
steps:
2320
- uses: actions/checkout@v2
24-
- name: Set up Python ${{ matrix.python-version }}
21+
- name: Set up Python ${{ matrix.python-version }} 🚜
2522
uses: actions/setup-python@v2
2623
with:
2724
python-version: ${{ matrix.python-version }}
28-
- name: Install dependencies
25+
- name: Install dependencies πŸ› 
2926
run: |
3027
python -m pip install --upgrade pip
3128
pip install flake8 codecov pytest-cov wheel setuptools matplotlib seaborn mne
3229
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3330
pip install .
34-
- name: Lint with flake8
31+
- name: Lint with flake8 πŸŽ“
3532
run: |
3633
# stop the build if there are Python syntax errors or undefined names
3734
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3835
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3936
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
40-
- name: Test with pytest
37+
- name: Test with pytest πŸ§ͺ
4138
run: |
4239
PYTHONPATH=. pytest --durations=0 --cov-report=xml --cov=neurolib tests/
43-
- name: Upload coverage to Codecov
40+
- name: Upload coverage to Codecov πŸ“Š
4441
uses: codecov/codecov-action@v1
4542
with:
4643
file: ./coverage.xml
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: documentation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest]
15+
python-version: [3.7]
16+
17+
steps:
18+
- name: Copy Repository Contents ↩
19+
uses: actions/checkout@v2
20+
with:
21+
persist-credentials: false
22+
- name: Set up Python ${{ matrix.python-version }} 🚜
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies πŸ› 
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install mkdocs mkdocs-material mkdocstrings mknotebooks Pygments
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
pip install .
32+
- name: Build documentation πŸ‘·β€β™€οΈ
33+
run: |
34+
mkdocs build
35+
- name: Deploy πŸš€
36+
uses: JamesIves/github-pages-deploy-action@4.0.0
37+
with:
38+
folder: site
39+
token: ${{ secrets.DOC_ACCESS_TOKEN }}
40+
branch: master
41+
repository-name: neurolib-dev/neurolib-dev.github.io
42+

β€Ž.github/workflows/test-notebooks.ymlβ€Ž

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: notebooks
52

63
on:
@@ -18,16 +15,16 @@ jobs:
1815

1916
steps:
2017
- uses: actions/checkout@v2
21-
- name: Set up Python ${{ matrix.python-version }}
18+
- name: Set up Python ${{ matrix.python-version }} 🚜
2219
uses: actions/setup-python@v2
2320
with:
2421
python-version: ${{ matrix.python-version }}
25-
- name: Install dependencies
22+
- name: Install dependencies πŸ› 
2623
run: |
2724
python -m pip install --upgrade pip
2825
pip install treon wheel setuptools jupyterlab matplotlib seaborn
2926
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3027
pip install .
31-
- name: Test notebooks with treon
28+
- name: Test notebooks with treon πŸ§ͺ
3229
run: |
3330
treon examples/

β€ŽREADME.mdβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# What is neurolib?
2424

25-
Please read the [gentle introduction](https://caglorithm.github.io/notebooks/neurolib-intro/) to `neurolib` for an overview of the basic functionality and some background information on the science behind whole-brain simulations.
25+
Please read the [gentle introduction](https://caglorithm.github.io/notebooks/neurolib-intro/) to `neurolib` for an overview of the basic functionality and some background information on the science behind whole-brain simulations or read the [documentation](https://neurolib-dev.github.io/) for getting started.
2626

2727
`neurolib` allows you to build, simulate, and optimize your own state-of-the-art whole-brain models. To simulate the neural activity of each brain area, the main implementation provides an advanced neural mass mean-field model of spiking adaptive exponential integrate-and-fire neurons (AdEx) called `ALNModel`. Each brain area is represented by two populations of excitatory and inhibitory neurons. An extensive analysis and validation of the `ALNModel` model can be found in our [paper](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1007822) and its associated [github page](https://github.com/caglarcakan/stimulus_neural_populations).
2828

@@ -250,7 +250,7 @@ This will gives us a summary of the last generation and plots a distribution of
250250

251251
### Built With
252252

253-
`neurolib` is built on other amazing open source projects:
253+
`neurolib` is built using other amazing open source projects:
254254

255255
* [pypet](https://github.com/SmokinCaterpillar/pypet) - Python parameter exploration toolbox
256256
* [deap](https://github.com/DEAP/deap) - Distributed Evolutionary Algorithms in Python

β€Ždocs/examplesβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../examples
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# BoxSearch
2+
3+
::: neurolib.optimize.exploration.exploration.BoxSearch

β€Ždocs/index.mdβ€Ž

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<p align="center">
2+
<img alt="Header image of neurolib - A Python simulation framework foreasy whole-brain neural mass modeling." src="https://github.com/neurolib-dev/neurolib/raw/master/resources/readme_header.png" >
3+
</p>
4+
5+
## Getting started
6+
* To browse the source code of `neurolib` visit out [GitHub repository](https://github.com/neurolib-dev/neurolib).
7+
* Read the [gentle introduction](https://caglorithm.github.io/notebooks/neurolib-intro/) to `neurolib` for an overview of the basic functionality and some background information on the science behind whole-brain simulations.
8+
9+
## Installation
10+
The easiest way to get going is to install the pypi package using `pip`:
11+
12+
```
13+
pip install neurolib
14+
```
15+
Alternatively, you can also clone this repository and install all dependencies with
16+
17+
```
18+
git clone https://github.com/neurolib-dev/neurolib.git
19+
cd neurolib/
20+
pip install -r requirements.txt
21+
pip install .
22+
```
23+
24+
## Project layout
25+
26+
27+
neurolib/ # Main module
28+
models/ # Neural mass models
29+
model.py # Base model class
30+
/.../ # Implemented neural models
31+
optimize/ # Optimization submodule
32+
evolution/ # Evolutionary optimization
33+
evolution.py
34+
...
35+
exploration/ # Parameter exploration
36+
exploration.py
37+
...
38+
data/ # Empirical datasets (structural, functional)
39+
...
40+
utils/ # Utility belt
41+
atlases.py # Atlases (Region names, coordinates)
42+
collections.py # Custom data types
43+
functions.py # Useful functions
44+
loadData.py # Dataset loader
45+
parameterSpace.py # Parameter space
46+
saver.py # Save simulation outputs
47+
signal.py # Signal processing functions
48+
stimulus.py # Stimulus construction
49+
examples/ # Example Jupyter notebooks
50+
docs/ # Documentation
51+
## More information
52+
53+
### Built With
54+
55+
`neurolib` is built using other amazing open source projects:
56+
57+
* [pypet](https://github.com/SmokinCaterpillar/pypet) - Python parameter exploration toolbox
58+
* [deap](https://github.com/DEAP/deap) - Distributed Evolutionary Algorithms in Python
59+
* [numpy](https://github.com/numpy/numpy) - The fundamental package for scientific computing with Python
60+
* [numba](https://github.com/numba/numba) - NumPy aware dynamic Python compiler using LLVM
61+
* [Jupyter](https://github.com/jupyter/notebook) - Jupyter Interactive Notebook
62+
63+
### Get in touch
64+
65+
Caglar Cakan (cakan@ni.tu-berlin.de)
66+
Department of Software Engineering and Theoretical Computer Science, Technische UniversitΓ€t Berlin, Germany
67+
Bernstein Center for Computational Neuroscience Berlin, Germany
68+
69+
### Acknowledgments
70+
This work was supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) with the project number 327654276 (SFB 1315) and the Research Training Group GRK1589/2.

β€Ždocs/models/model.mdβ€Ž

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Models
2+
3+
Models are the core of `neurolib`. The `Model` superclass will help you to load, simulate, and analyse models. It also makes it very easy to implement your own neural mass model (see [Example 0.6 custom model](/examples/example-0.6-custom-model/)).
4+
5+
## Loading a model
6+
To load a model, we need to import the submodule of a model and instantiate it. This example shows how to load a single node of the `ALNModel`. See [Example 0 aln minimal](/examples/example-0-aln-minimal/) on how to simulate a whole-brain network using this model.
7+
8+
9+
```
10+
from neurolib.models.aln import ALNModel # Import the model
11+
model = ALNModel() # Create an instance
12+
model.run() # Run it
13+
```
14+
15+
## Model base class methods
16+
17+
::: neurolib.models.model.Model

β€Ždocs/models/parameters.mdβ€Ž

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Parameters
2+
3+
Model parameters in `neurolib` are stored as a dictionary-like object `params` as one of a model's attributes. Changing parameters is straightforward:
4+
5+
``` python
6+
from neurolib.models.aln import ALNModel # Import the model
7+
model = ALNModel() # Create an instance
8+
9+
model.params['duration'] = 10 * 1000 # in ms
10+
model.run() # Run it
11+
```
12+
13+
Parameters are `dotdict` objects that can also be accessed using the more simple syntax `model.params.parameter_name = 123` (see [Collections](/utils/collections/)).
14+
15+
## Default parameters
16+
17+
The default parameters of a model are stored in the `loadDefaultParams.py` within each model's directory. This function is called by the `model.py` file upon initialisation and returns all necessary parameters of the model.
18+
19+
Below is an example function that prepares the structural connectivity matrices `Cmat` and `Dmat`, all parameters of the model, and its initial values.
20+
21+
``` python
22+
def loadDefaultParams(Cmat=None, Dmat=None, seed=None):
23+
"""Load default parameters for a model
24+
25+
:param Cmat: Structural connectivity matrix (adjacency matrix) of coupling strengths, will be normalized to 1. If not given, then a single node simulation will be assumed, defaults to None
26+
:type Cmat: numpy.ndarray, optional
27+
:param Dmat: Fiber length matrix, will be used for computing the delay matrix together with the signal transmission speed parameter `signalV`, defaults to None
28+
:type Dmat: numpy.ndarray, optional
29+
:param seed: Seed for the random number generator, defaults to None
30+
:type seed: int, optional
31+
32+
:return: A dictionary with the default parameters of the model
33+
:rtype: dict
34+
"""
35+
36+
params = dotdict({})
37+
38+
### runtime parameters
39+
params.dt = 0.1 # ms 0.1ms is reasonable
40+
params.duration = 2000 # Simulation duration (ms)
41+
np.random.seed(seed) # seed for RNG of noise and ICs
42+
# set seed to 0 if None, pypet will complain otherwise
43+
params.seed = seed or 0
44+
45+
# make sure that seed=0 remains None
46+
if seed == 0:
47+
seed = None
48+
49+
# ------------------------------------------------------------------------
50+
# global whole-brain network parameters
51+
# ------------------------------------------------------------------------
52+
53+
# the coupling parameter determines how nodes are coupled.
54+
# "diffusive" for diffusive coupling, "additive" for additive coupling
55+
params.coupling = "diffusive"
56+
57+
params.signalV = 20.0
58+
params.K_gl = 0.6 # global coupling strength
59+
60+
if Cmat is None:
61+
params.N = 1
62+
params.Cmat = np.zeros((1, 1))
63+
params.lengthMat = np.zeros((1, 1))
64+
65+
else:
66+
params.Cmat = Cmat.copy() # coupling matrix
67+
np.fill_diagonal(params.Cmat, 0) # no self connections
68+
params.N = len(params.Cmat) # number of nodes
69+
params.lengthMat = Dmat
70+
71+
# ------------------------------------------------------------------------
72+
# local node parameters
73+
# ------------------------------------------------------------------------
74+
75+
# external input parameters:
76+
params.tau_ou = 5.0 # ms Timescale of the Ornstein-Uhlenbeck noise process
77+
params.sigma_ou = 0.0 # mV/ms/sqrt(ms) noise intensity
78+
params.x_ou_mean = 0.0 # mV/ms (OU process) [0-5]
79+
params.y_ou_mean = 0.0 # mV/ms (OU process) [0-5]
80+
81+
# neural mass model parameters
82+
params.a = 0.25 # Hopf bifurcation parameter
83+
params.w = 0.2 # Oscillator frequency, 32 Hz at w = 0.2
84+
85+
# ------------------------------------------------------------------------
86+
87+
# initial values of the state variables
88+
params.xs_init = 0.5 * np.random.uniform(-1, 1, (params.N, 1))
89+
params.ys_init = 0.5 * np.random.uniform(-1, 1, (params.N, 1))
90+
91+
# Ornstein-Uhlenbeck noise state variables
92+
params.x_ou = np.zeros((params.N,))
93+
params.y_ou = np.zeros((params.N,))
94+
95+
# values of the external inputs
96+
params.x_ext = np.zeros((params.N,))
97+
params.y_ext = np.zeros((params.N,))
98+
99+
return params
100+
101+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Evolution
2+
3+
::: neurolib.optimize.evolution.evolution.Evolution

0 commit comments

Comments
Β (0)