Skip to content

Binder

The Wilson-Cowan model

In this notebook, the basic use of the implementation of the Wilson-Cowan (wc) model is presented.

In the wc model, the activity of a particular brain region is defined by a coupled system of excitatory (E) and inhibitory (I) neuronal populations with the mean firing rates of the E and I pools being the dynamic variables, as first described by Wilson and Cowan in 1972 ( H.R. Wilson and J.D. Cowan. Excitatory and inhibitory interactions in localized populations of model neurons. Biophys. J., 12:1–24 (1972))

# change to the root directory of the project
import os
if os.getcwd().split("/")[-1] == "examples":
    os.chdir('..')
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import numpy as np
import glob

from neurolib.models.wc import WCModel

import neurolib.utils.loadData as ld
import neurolib.utils.functions as func

# a nice color map
plt.rcParams['image.cmap'] = 'plasma'

Bifurcation diagram

model = WCModel()
model.params['duration'] = 2.0*1000

Let's draw a simple one-dimensional bifurcation diagram of this model to orient ourselves in the parameter space

max_exc = []
min_exc = []
# these are the different input values that we want to scan
exc_inputs = np.linspace(0, 3.5, 50)
for exc_ext in exc_inputs:
    # Note: this has to be a vector since it is input for all nodes
    # (but we have only one node in this example)
    model.params['exc_ext'] = exc_ext
    model.run()
    # we add the maximum and the minimum of the last second of the 
    # simulation to a list
    max_exc.append(np.max(model.exc[0, -int(1000/model.params['dt']):]))
    min_exc.append(np.min(model.exc[0, -int(1000/model.params['dt']):]))
plt.plot(exc_inputs, max_exc, c='k', lw = 2)
plt.plot(exc_inputs, min_exc, c='k', lw = 2)
plt.title("Bifurcation diagram of the Wilson-Cowan model")
plt.xlabel("Input to exc")
plt.ylabel("Min / max exc")
Text(0,0.5,'Min / max exc')

Single node simulation

model = WCModel()
model.params['duration'] = 1.0*1000
model.params['sigma_ou'] = 0.01

model.run()
plt.plot(model.t, model.exc.T, c='k', lw = 2)
plt.xlabel("t [ms]")
plt.ylabel("Activity")
Text(0,0.5,'Activity')

Brain network

from neurolib.utils.loadData import Dataset

ds = Dataset("hcp")
model = WCModel(Cmat = ds.Cmat, Dmat = ds.Dmat)
model.params['exc_ext'] = 0.65

model.params['signalV'] = 0
model.params['duration'] = 20 * 1000 
model.params['sigma_ou'] = 0.14
model.params['K_gl'] = 3.15


model.run(chunkwise=True)
fig, axs = plt.subplots(1, 2, figsize=(10, 3))
axs[0].imshow(func.fc(model.exc[:, -10000:]))
axs[1].plot(model.t, model.exc[::5, :].T, alpha=0.8);
axs[1].set_xlim(0, 200)
(0, 200)
scores = [func.matrix_correlation(func.fc(model.exc[:, -int(5000/model.params['dt']):]), fcemp) for fcemp in ds.FCs]
print("Correlation per subject:", [f"{s:.2}" for s in scores])
print("Mean FC/FC correlation: {:.2f}".format(np.mean(scores)))
Correlation per subject: ['0.13', '0.14', '0.13', '0.12', '0.11', '0.12', '0.12']
Mean FC/FC correlation: 0.13