"**Scaling parameter** (scale_down_to) is the parameter defines the the ratio of the full scale multi-area model being down-scaled to a model with fewer neurons and indegrees so as to be simulated on machines with lower computational ability and the simulation results can be obtained in relative shorter period of time.<br> <br> \n",
"**Scaling factor** (scale_down_to) is the parameter which defines the the ratio of the full scale multi-area model being down-scaled to a model with fewer neurons and indegrees so as to be simulated on machines with lower computational ability and the simulation results can be obtained within relative shorter period of time.<br> <br> \n",
"Neurons and indegrees are both scaled down to 0.5%, where the model can usually be simulated on a local machine.<br> **Warning: This will not yield reasonable dynamical results from the network and is only meant to demonstrate the simulation workflow.**"
"Neurons and indegrees are both scaled down to 0.5%, where the model can usually be simulated on a local machine.<br> **Warning**: This will not yield reasonable dynamical results from the network and is only meant to demonstrate the simulation workflow.**"
"|Number of local threads| |local_num_threads |1 | |\n",
"| | |recording_dict |input_params | |\n",
"| | |recording_dict |input_params | |\n",
"| | |record_vm |False | |"
"| | |record_vm |False | |"
]
]
},
},
{
{
...
@@ -311,7 +316,8 @@
...
@@ -311,7 +316,8 @@
"sim_params = {'t_sim': 2000.,\n",
"sim_params = {'t_sim': 2000.,\n",
" 'num_processes': 1,\n",
" 'num_processes': 1,\n",
" 'local_num_threads': 1,\n",
" 'local_num_threads': 1,\n",
" 'recording_dict': {'record_vm': False}}"
" 'recording_dict': {'record_vm': False},\n",
" 'rng_seed': 1} # global random seed\n"
]
]
},
},
{
{
...
@@ -319,7 +325,7 @@
...
@@ -319,7 +325,7 @@
"id": "79596d77-c105-45d0-9a57-2d15e31f1189",
"id": "79596d77-c105-45d0-9a57-2d15e31f1189",
"metadata": {},
"metadata": {},
"source": [
"source": [
"### 4. Theory paramters (theory_params)"
"### 2.6. Theory paramters (theory_params)"
]
]
},
},
{
{
...
@@ -342,18 +348,34 @@
...
@@ -342,18 +348,34 @@
"theory_params = {'dt': 0.1}"
"theory_params = {'dt': 0.1}"
]
]
},
},
{
"cell_type": "markdown",
"id": "1472e9c5",
"metadata": {},
"source": [
"<br>"
]
},
{
{
"cell_type": "markdown",
"cell_type": "markdown",
"id": "de4a6703",
"id": "de4a6703",
"metadata": {},
"metadata": {},
"source": [
"source": [
"## Instantiate a multi-area model, predict firing rates from theroy "
"## Instantiate a multi-area model and analyse"
]
},
{
"cell_type": "markdown",
"id": "1fd58841",
"metadata": {},
"source": [
"### 1. Insantiate a multi-area model "
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "d409be95",
"id": "ab25f9f8",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -363,10 +385,18 @@
...
@@ -363,10 +385,18 @@
" theory_spec=theory_params)"
" theory_spec=theory_params)"
]
]
},
},
{
"cell_type": "markdown",
"id": "91649c30",
"metadata": {},
"source": [
"### 2. Predict firing rates from theory"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": null,
"execution_count": null,
"id": "918d907f",
"id": "6a7ddf0e",
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -375,6 +405,70 @@
...
@@ -375,6 +405,70 @@
" \"rate of {0:.3f} spikes/s across all populations.\".format(np.mean(r[:, -1])))"
" \"rate of {0:.3f} spikes/s across all populations.\".format(np.mean(r[:, -1])))"
]
]
},
},
{
"cell_type": "markdown",
"id": "2062ddf3",
"metadata": {},
"source": [
"### 3. Extract connectivity"
]
},
{
"cell_type": "markdown",
"id": "8a7c09e0",
"metadata": {},
"source": [
"The connectivity and neuron numbers are stored in the attributes of the model class. Neuron numbers are stored in `M.N` as a dictionary (and in `M.N_vec` as an array), indegrees in `M.K` as a dictionary (and in `M.K_matrix` as an array). Number of synapses can also be access via `M.synapses` (and in `M.syn_matrix` as an array)."
]
},
{
"cell_type": "markdown",
"id": "b7396606",
"metadata": {},
"source": [
"#### 3.1 Node indegrees"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6316ac24",
"metadata": {},
"outputs": [],
"source": [
"# Dictionary of nodes indegrees organized as:\n",
"# run the simulation, depending on the model parameter and downscale ratio, the running time varies largely.\n",
"M.simulation.simulate()"
"M.simulation.simulate()"
]
]
},
},
{
"cell_type": "markdown",
"id": "fd6e3232",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "markdown",
"id": "28e071f8",
"metadata": {},
"source": [
"## Simulation results analysis"
]
},
{
"cell_type": "markdown",
"id": "89c7b7cf",
"metadata": {},
"source": [
"The following instructions will work when the `simulate` parameter is set to `True` during the creation of the MultiAreaModel object, and the `M.simulation.simulate()` method is executed."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc3b1820",
"metadata": {},
"outputs": [],
"source": [
"# Uncomment the lines in this code cell below to test if the number of synapses created by NEST matches the expected values\n",
"\n",
"# \"\"\"\n",
"# Test if the correct number of synapses has been created.\n",
"# syn = M.synapses[target_area.name][target_pop][source_area.name][source_pop]\n",
"# assert(len(created_syn) == int(syn))"
]
},
{
"cell_type": "markdown",
"id": "57401110",
"metadata": {},
"source": [
"To obtain the connections information, you can extract the lists of connected sources and targets. Moreover, you can access additional synaptic details, such as synaptic weights and delays."
"You can determine the area and subpopulation to which the neuron ID ranges belong by referring to the file `network_gids.txt`, which is automatically generated during network creation."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "902f2800",
"metadata": {},
"outputs": [],
"source": [
"# Open the file using a with statement\n",
"with open(os.path.join(M.simulation.data_dir,\"recordings/network_gids.txt\"), \"r\") as file:\n",
**Scaling parameter** (scale_down_to) is the parameter defines the the ratio of the full scale multi-area model being down-scaled to a model with fewer neurons and indegrees so as to be simulated on machines with lower computational ability and the simulation results can be obtained in relative shorter period of time.<br><br>
**Scaling factor** (scale_down_to) is the parameter which defines the the ratio of the full scale multi-area model being down-scaled to a model with fewer neurons and indegrees so as to be simulated on machines with lower computational ability and the simulation results can be obtained within relative shorter period of time.<br><br>
Neurons and indegrees are both scaled down to 0.5%, where the model can usually be simulated on a local machine.<br>**Warning: This will not yield reasonable dynamical results from the network and is only meant to demonstrate the simulation workflow.**
Neurons and indegrees are both scaled down to 0.5%, where the model can usually be simulated on a local machine.<br>**Warning**: This will not yield reasonable dynamical results from the network and is only meant to demonstrate the simulation workflow.**
## Instantiate a multi-area model, predict firing rates from theroy
## Instantiate a multi-area model and analyse
%% Cell type:code id:d409be95 tags:
%% Cell type:markdown id:1fd58841 tags:
### 1. Insantiate a multi-area model
%% Cell type:code id:ab25f9f8 tags:
``` python
``` python
M=MultiAreaModel(network_params,simulation=True,
M=MultiAreaModel(network_params,simulation=True,
sim_spec=sim_params,
sim_spec=sim_params,
theory=True,
theory=True,
theory_spec=theory_params)
theory_spec=theory_params)
```
```
%% Cell type:code id:918d907f tags:
%% Cell type:markdown id:91649c30 tags:
### 2. Predict firing rates from theory
%% Cell type:code id:6a7ddf0e tags:
``` python
``` python
p,r=M.theory.integrate_siegert()
p,r=M.theory.integrate_siegert()
print("Mean-field theory predicts an average "
print("Mean-field theory predicts an average "
"rate of {0:.3f} spikes/s across all populations.".format(np.mean(r[:,-1])))
"rate of {0:.3f} spikes/s across all populations.".format(np.mean(r[:,-1])))
```
```
%% Cell type:markdown id:2062ddf3 tags:
### 3. Extract connectivity
%% Cell type:markdown id:8a7c09e0 tags:
The connectivity and neuron numbers are stored in the attributes of the model class. Neuron numbers are stored in `M.N` as a dictionary (and in `M.N_vec` as an array), indegrees in `M.K` as a dictionary (and in `M.K_matrix` as an array). Number of synapses can also be access via `M.synapses` (and in `M.syn_matrix` as an array).
# run the simulation, depending on the model parameter and downscale ratio, the running time varies largely.
M.simulation.simulate()
M.simulation.simulate()
```
```
%% Cell type:markdown id:fd6e3232 tags:
<br>
%% Cell type:markdown id:28e071f8 tags:
## Simulation results analysis
%% Cell type:markdown id:89c7b7cf tags:
The following instructions will work when the `simulate` parameter is set to `True` during the creation of the MultiAreaModel object, and the `M.simulation.simulate()` method is executed.
%% Cell type:code id:dc3b1820 tags:
``` python
# Uncomment the lines in this code cell below to test if the number of synapses created by NEST matches the expected values
# """
# Test if the correct number of synapses has been created.
# syn = M.synapses[target_area.name][target_pop][source_area.name][source_pop]
# assert(len(created_syn) == int(syn))
```
%% Cell type:markdown id:57401110 tags:
To obtain the connections information, you can extract the lists of connected sources and targets. Moreover, you can access additional synaptic details, such as synaptic weights and delays.
You can determine the area and subpopulation to which the neuron ID ranges belong by referring to the file `network_gids.txt`, which is automatically generated during network creation.