Example

In this page I show a usage example of the implemented code.

Network configuration

Suppose you want to simulate the network showed in the Figure below (red (blue) arrows means excitatory (inhibitory) projections):

_images/example_network.png

Then, the configuration files that you need will be similar to:

  • subnets_config_yaml: specify network composition and features of the neurons in each SubNetwork:

    # list of the populations with their parameters
    
    - name:                   S
      neuron_model:           aeif_cond_exp
      N:                      100
      C_m:                    40.                   # pF
      E_L:                    -55.1                 # mV
      E_ex:                   0.                    # mV
      E_in:                   -65.                  # mV
      V_res:                  -60.                  # mV
      V_th:                   -54.7                 # mV
      g_L:                    1.                    # nS
      t_ref:                  0.0                   # ms
      I_e:                    -38.0                 # pA
      osc_amp:                5.0                   # pA
      osc_omega:              0.314                 # kHz  (50 Hz)
      dev_ext_weight:         0.05                  # nS
      ext_in_rate:            0.25                  # kHz
      osc_amp_poiss:          0.                    # kHz
      osc_omega_poiss:        0.                    # kHz
      tau_syn_ex:             10.                   # ms
      tau_syn_in:             5.5                   # ms
      a_adaptive:             2.5                   # nS
      b_adaptive:             70.                   # pA
      tau_w_adaptive:         20.                   # ms
      delta_T_aeif_cond_exp:  1.7                   # mV
      V_peak:                 15.                   # mV
    
    - name:                   T
      neuron_model:           aeif_cond_exp
      N:                      200
      C_m:                    40.
      E_L:                    -55.1
      E_ex:                   0.
      E_in:                   -65.
      V_res:                  -60.
      V_th:                   -54.7
      g_L:                    1.
      t_ref:                  0.0
      I_e:                    -150.0
      osc_amp:                0.0
      osc_omega:              0.0
      dev_ext_weight:         0.05
      ext_in_rate:            0.1
      osc_amp_poiss:          0.
      osc_omega_poiss:        0.
      tau_syn_ex:             10.
      tau_syn_in:             5.5
      a_adaptive:             2.5
      b_adaptive:             70.
      tau_w_adaptive:         20.
      delta_T_aeif_cond_exp:  1.7
      V_peak:                 15.
    
  • weights_config_yaml: connection weights (in nS) with the convention that

    • positive weights are excitatory

    • negative weights are inhibitory

    # weights of connections TO :name:
    
    - name:         S
      S:             -1.2         # S receives inhibitory inputs from S
      ext:           0.45         # S receives excitatory inputs from ext
    
    - name:         T
      S:             0.3          # T receives excitatory inputs from S
      ext:           0.1          # T receives excitatory inputs from ext
    
  • connections_config_yaml: connectivity probabilities between subnetworks and corresponding delays (in ms)

    # Connections probabilities and delays FROM "name"
    
    - name:        S
      S:            0.2       # each S neuron project to each S neuron with probability 0.2
      S_delay:      0.5
      T:            0.8       # each S neuron project to each T neuron with probability 0.8
      T_delay:      1.0
    
  • to_save_config_yaml: list of neurons whose state you want to save at each step

    # list of the neurons whose state is to be saved at each time step
    
    - S:        [0,1]
    
    - T:        [3,5,7]
    

Attention

The configuration files above must be saved in a directory inside the build directory.

Simulation configuration and execution

Once the Network is configured you can set the simulation control variables in a yaml file <sim-name>.yaml:

t_end:                          6500  # ms
dt:                             0.1   # ms
n_step:                         10
out_dir:                        output/example
subnets_config_yaml:            config_example/config.yaml
weights_config_yaml:            config_example/config_weights.yaml
connections_config_yaml:        config_example/config_connections.yaml
to_save_config_yaml:            config_example/config_to_save.yaml
input_mode:                     0
input_mode_config:              unused

Note

  • the variable n_step can be used to execute the simulation in more than one step. This is useful for memory consumption issues (in case of long simulation with many neurons increase the value of n_step for better performance)

  • the example output directory is automatically created

  • note that the network configuration files has been collected in the config_example directory

And finally run the simulation using:

$ ./main <sim-name>.yaml

Output of the simulation

After the simulation has finished, you will find the following files in the output directory:

  • a copy of the configuration files used for the simulation

  • some files containing the spiking times of the neurons separately for each SubNetwork and with format:

    <neuron-index> <list-of-spike-times>
    
  • a directory neuron_states containing:

    • a file t.txt containing the time steps of the simulation

    • a file <SubNetwork-name>_<neuron-index>.txt for each neuron indicated in to_save_config_yaml containing the state x of the neuron at each time step

    Note

    if no neuron is indicated in to_save_config_yaml, the neuron_states directory will not be produced

Basic analysis of the results

Using the code below:

import python_utils as utils

s = utils.SpikeSim("./build/output/example_long", 'example.yaml', 500, 6500.)

s.info()

s.histogram('all', res = 10.)

for (k,v) in (s.MeanActivity()).items():
    print(f'Mean activity of {k} \t {v[0]:.2f} kHz\t N_neurons = {v[1]} \t Activity per Neuron = {v[2]*1000:.4f} Hz')

s.welch_spectogram('S', res = 5.)

you can easily:

  • visualize the results of the simulation
    _images/hist.png
  • perform straightforward spectral analysis on the activity of the nuclei (S in this case)
    _images/spect.png