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.3.tar.gz (4.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: neurolib-0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 fc0d542941181c64f8aee9fc38db833f6cb4b1176868d6e7d00f67e69cad28dc
MD5 421a7db47c093998dae277664983e1b9
BLAKE2b-256 4aca404c0ec5e0a31cfab2d5978c159b11fe70b17c37e99ae60cd3953b13698c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neurolib-0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 13e73084bc2ea51335f38c1265929684f65c32c7a48e5134276bc232b69932f1
MD5 54c2933446411196725a5b1dd4d7ad72
BLAKE2b-256 822de05d6530b302c8d923b4d7d60c910adc40a9b24ebee485f04c777f453337

See more details on using hashes here.

Supported by

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