Skip to main content

Easy whole-brain neural mass modeling

Project description

PyPI Code style: black

Neurolib

Easy whole-brain neural mass modeling 👩‍🔬💻🧠

Neurolib allows you to easily create your own state-of-the-art whole-brain models. The main implementation is a neural mass firing rate model of spiking adaptive exponential integrate-and-fire neurons (AdEx) called aln which consists of two populations of excitatory and a inhibitory neurons. An extensive analysis of the model can be found in the paper Biophysically grounded mean-field models of neural populations under electrical stimulation, Cakan et al. 2020 (ArXiv), and its associated github page.

Whole-brain modeling

In combination with structural brain data, for example from diffusion tensor imaging (DTI) tractography, and resting state BOLD data from magnetic resonance imaging (rs-fMRI), a network model of a whole brain can be created. Structural connectivity matrices from DTI tractography define 1) the connection strengths between areas, represented for example by the number of axonal fibers between each two brain areas and 2) the signal transmission delays measured from the length of the axonal fibers.

The resulting whole-brain model consists of interconnected brain areas, with each brain area having their internal neural dynamics. The neural activity is used to simulate BOLD activity using the Balloon-Windkessel model. The resulting simulated resting state functional connectivity can then be used to fit the model to empirical functional brain data.

Installation

The easiest way to get going is to install the pypi release of neurolib using

pip install neurolib

Alternatively, you can also clone this repository and install all dependencies with

git clone https://github.com/neurolib-dev/neurolib.git
cd neurolib/
pip install -r requirements.txt

Usage

Example iPython notebooks on how to use the library can be found in the ./examples/ directory. A basic overview is given here.

Single node

To create a single aln model with the default parameters, simply run

from neurolib.models.aln import ALNModel

aln = ALNModel()
aln.params['sigma_ou'] = 0.1 # add some noise

aln.run()

The results from this small simulation can be plotted easily:

import matplotlib.pyplot as plt
plt.plot(aln.t, aln.rates_exc.T)

Whole-brain network

To simulate a whole-brain network model, first we need to load a DTI and a resting-state fMRI dataset (an example dataset called gw is provided in the neurolib/data/datasets/ directory).

from neurolib.utils.loadData import Dataset

ds = Dataset("gw")

We can now initialise the model with the dataset:

aln = ALNModel(Cmat = ds.Cmat, Dmat = ds.Dmat, simulateBOLD=True)
aln.params['duration'] = 5*60*1000 # in ms, simulates for 5 minutes

aln.run()

This can take several minutes to compute, since we are simulating 90 nodes for 5 minutes realtime. Here, we have created a network model in which each brain area is an aln node. Note that we specified simulateBOLD=True, which simulates the BOLD model in parallel to the firing rate model.

The quality of the fit of this simulation to the functional empirical data can now be computed per subject or for the whole group on average:

scores = []
for i in range(len(ds.FCs)):
    fc_score = func.matrix_correlation(func.fc(alnModel.BOLD[:, 5:]), ds.FCs[i]) 
    scores.append(fc_score)
    print("Subject {}: {:.2f}". format(i, fc_score))
print("Mean simulated FC to empirical FC correlation: {:.2f}".format(np.mean(scores)))
Subject 0: 0.71
Subject 1: 0.70
Subject 2: 0.52
Subject 3: 0.56
Subject 4: 0.51
Subject 5: 0.60
Subject 6: 0.64
Subject 7: 0.65
Subject 8: 0.36
Subject 9: 0.54
Subject 10: 0.49
Mean simulated FC to empirical FC correlation: 0.57

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neurolib-0.2.tar.gz (4.9 MB view details)

Uploaded Source

Built Distribution

neurolib-0.2-py3-none-any.whl (4.9 MB view details)

Uploaded Python 3

File details

Details for the file neurolib-0.2.tar.gz.

File metadata

  • Download URL: neurolib-0.2.tar.gz
  • Upload date:
  • Size: 4.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.3

File hashes

Hashes for neurolib-0.2.tar.gz
Algorithm Hash digest
SHA256 fa5b080226e7cb4205a070d7a4496aef50d00e170a0d4d658ed3d3f7cb292756
MD5 8edee5f4fbfb9ccc887fbddf1b8c1473
BLAKE2b-256 c9da03175b3ef7542e19ff51d843597e769ff08e90ab42c127b8b510a0e38b3e

See more details on using hashes here.

Provenance

File details

Details for the file neurolib-0.2-py3-none-any.whl.

File metadata

  • Download URL: neurolib-0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.7.3

File hashes

Hashes for neurolib-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d1d45023b4b86cf56225d8a9075bec3215c7f4e4973799c45f60774cb553b34
MD5 6cc05e6f58c03c2117b25de27fb0ec7a
BLAKE2b-256 3e286263903dbe4f7b2b6d17d0c95ea2c84ffba56ffd1dc28f7cd9cfe13b0e2f

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page