File: build_network.py

package info (click to toggle)
bmtk 0.0%2Bgit20210109.8572664%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 74,876 kB
  • sloc: python: 24,853; javascript: 1,998; makefile: 34; sh: 16
file content (90 lines) | stat: -rw-r--r-- 2,538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import numpy as np

from bmtk.builder import NetworkBuilder
from bmtk.builder.auxi.node_params import positions_columinar


def random_connections(source, target, p=0.1):
    sid = source['node_id']  # Get source id
    tid = target['node_id']  # Get target id

    # Avoid self-connections.
    if sid == tid:
        return None

    return np.random.binomial(1, p)  # nsyns


LIF_models = {
    'LIF_exc': {
        'N': 80,
        'ei': 'e',
        'pop_name': 'LIF_exc',
        'model_type': 'point_process',
        'model_template': 'nest:iaf_psc_delta',
        'dynamics_params': 'iaf_psc_delta_exc.json'
    },
    'LIF_inh': {
        'N': 40,
        'ei': 'i',
        'pop_name': 'LIF_inh',
        'model_type': 'point_process',
        'model_template': 'nest:iaf_psc_delta',
        'dynamics_params': 'iaf_psc_delta_inh.json'
    }
}


net = NetworkBuilder('cortex')
for model in LIF_models:
    params = LIF_models[model].copy()
    positions = positions_columinar(N=LIF_models[model]['N'], center=[0, 10.0, 0], max_radius=50.0, height=200.0)
    net.add_nodes(x=positions[:, 0], y=positions[:, 1], z=positions[:, 2],
                  **params)


net.add_edges(source={'ei': 'e'},
              connection_rule=random_connections,
              connection_params={'p': 0.1},
              syn_weight=2.0,
              delay=1.5,
              dynamics_params='ExcToInh.json',
              model_template='static_synapse')

net.add_edges(source={'ei': 'i'},
              connection_rule=random_connections,
              connection_params={'p': 0.1},
              syn_weight=-1.5,
              delay=1.5,
              dynamics_params='InhToExc.json',
              model_template='static_synapse')

net.build()
net.save_nodes(output_dir='network')
net.save_edges(output_dir='network')



input_network_model = {
    'input_network': {
        'N': 100,
        'ei': 'e',
        'pop_name': 'input_network',
        'model_type': 'virtual'
    }
}


inputNetwork = NetworkBuilder("thalamus")
inputNetwork.add_nodes(**input_network_model['input_network'])

inputNetwork.add_edges(target=net.nodes(),
                       connection_rule=random_connections,
                       connection_params={'p': 0.1},
                       syn_weight=4.2,
                       delay=1.5,
                       dynamics_params='ExcToExc.json',
                       model_template='static_synapse')
inputNetwork.build()
inputNetwork.save_nodes(output_dir='network')
inputNetwork.save_edges(output_dir='network')