You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/getting_started.md
+50-8
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,37 @@
2
2
3
3
This tutorial will introduce you to simulating brain dynamics using Neuroblox.
4
4
5
-
## Example 1 : Building an oscillating circuit from two Wilson-Cowan Neural Mass Models
5
+
## Example 1: Creating a Simple Neural Circuit
6
+
7
+
In this example, we'll create a simple oscillating circuit using two Wilson-Cowan neural mass models [1]. The Wilson-Cowan model is one of the most influential models in computational neuroscience [2], describing the dynamics of interactions between populations of excitatory and inhibitory neurons.
8
+
9
+
### The Wilson-Cowan Model
10
+
11
+
Each Wilson-Cowan neural mass is described by the following equations:
6
12
7
-
The Wilson–Cowan model describes the dynamics of interactions between populations of excitatory and inhibitory neurons. Each Wilson-Cowan Blox is described by the follwoing equations:
Our first example is to simply combine two Wilson-Cowan Blox to build an oscillatory circuit
23
+
where $E$ and $I$ denote the activity levels of the excitatory and inhibitory populations, respectively. The terms $\frac{dE}{dt}$ and $\frac{dI}{dt}$ describe the rate of change of these activity levels over time. The parameters $\tau_E$ and $\tau_I$ are time constants analogous to membrane time constants in single neuron models, determining how quickly the excitatory and inhibitory populations respond to changes. The coefficients $c_{EE}$ and $c_{II}$ represent self-interaction (or feedback) within excitatory and inhibitory populations, while $c_{IE}$ and $c_{EI}$ represent the cross-interactions between the two populations. The term $\eta\sum{jcn}$ represents external input to the excitatory population from other brain regions or external stimuli, with $\eta$ acting as a scaling factor. While $S_E$ and $S_I$ are sigmoid functions that represent the responses of neuronal populations to input stimuli, defined as:
24
+
25
+
26
+
```math
27
+
S_k(x) = \frac{1}{1 + exp(-a_kx - \theta_k)}
28
+
```
29
+
30
+
where $a_k$ and $\theta_k$ determine the steepness and threshold of the response, respectively.
31
+
32
+
### Building the Circuit
33
+
34
+
Let's create an oscillating circuit by connecting two Wilson-Cowan neural masses:
35
+
15
36
16
37
```@example Wilson-Cowan
17
38
using Neuroblox
@@ -20,34 +41,55 @@ using Graphs
20
41
using MetaGraphs
21
42
using Plots
22
43
44
+
# Create two Wilson-Cowan blox
23
45
@named WC1 = WilsonCowan()
24
46
@named WC2 = WilsonCowan()
25
47
48
+
# Create a graph to represent our circuit
26
49
g = MetaDiGraph()
27
50
add_blox!.(Ref(g), [WC1, WC2])
28
51
52
+
# Define the connectivity between the neural masses
29
53
adj = [-1 6; 6 -1]
30
54
create_adjacency_edges!(g, adj)
31
55
32
56
```
33
57
34
-
First, we create the two Wilson-Cowan Blox: WC1 and WC2. Next, we add the two Blox into a directed graph as nodes and then we are creating weighted edges between the two nodes using an adjacency matrix.
58
+
Here, we've created two Wilson-Cowan Bloxand connected them as nodes in a directed graph. The `adj` matrix defines the weighted edges between these nodes. Each entry `adj[i,j]` represents how the output of blox `j` influences the input of blox `i`:
35
59
36
-
Now we are ready to build the ModelingToolkit System. Structural simplify creates the final set of equations in which all substiutions are made.
60
+
- Diagonal elements (`adj[1,1]` and `adj[2,2]`): Self-connections, adding feedback to each blox.
61
+
- Off-diagonal elements (`adj[1,2]` and `adj[2,1]`): Inter-blox connections, determining how each blox influences the other.
62
+
63
+
By default, the output of each Wilson-Cowan blox is its excitatory activity (E). The negative self-connections (-1) provide inhibitory feedback, while the positive inter-blox connections (6) provide strong excitatory coupling. This setup creates an oscillatory dynamic between the two Wilson-Cowan units.
64
+
65
+
66
+
### Creating the Model
67
+
Now, let's build the complete model:
37
68
38
69
```@example Wilson-Cowan
39
70
@named sys = system_from_graph(g)
40
71
sys = structural_simplify(sys)
41
72
```
42
73
43
-
To solve the system, we first create an ODEProblem and then solve it over the tspan of (0,100) using a stiff solver. The solution is saved every 0.1ms. The unit of time in Neuroblox is 1ms.
74
+
This creates a differential equations system from our graph representation using ModelingToolkit and symbolically simplifies it for efficient computation.
75
+
76
+
### Simulating the Model
77
+
78
+
Finally, let's simulate our model. The following code creates and solves an `ODEProblem` for our system, simulating 100 time units of activity. In Neuroblox, the default time unit is milliseconds. We use `Rodas4`, a solver efficient for stiff problems. The solution is saved every 0.1 ms, allowing us to observe the detailed evolution of the system's behavior.
44
79
45
80
```@example Wilson-Cowan
46
81
prob = ODEProblem(sys, [], (0.0, 100), [])
47
82
sol = solve(prob, Rodas4(), saveat=0.1)
48
83
plot(sol)
49
84
```
50
85
86
+
87
+
[[1] Wilson, H. R., & Cowan, J. D. (1972). Excitatory and inhibitory interactions in localized populations of model neurons. Biophysical journal, 12(1), 1-24.](https://www.cell.com/biophysj/fulltext/S0006-3495(72)86068-5)
88
+
89
+
[[2] Destexhe, A., & Sejnowski, T. J. (2009). The Wilson–Cowan model, 36 years later. Biological cybernetics, 101(1), 1-2.](https://link.springer.com/article/10.1007/s00422-009-0328-3)
90
+
91
+
92
+
51
93
## Example 2 : Building a Brain Circuit from literature using Neural Mass Models
52
94
53
95
In this example, we will construct a Parkinsons model from eight Jansen-Rit Neural Mass Models as described in Liu et al. (2020). DOI: 10.1016/j.neunet.2019.12.021. The Jansen-Rit Neural Mass model is defined by the following differential equations:
0 commit comments