-
Notifications
You must be signed in to change notification settings - Fork 0
/
runscript.py
77 lines (54 loc) · 2.72 KB
/
runscript.py
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
"""Starting script to run a network simulation of the clustered network
by Litwin-Kumar and Doiron (Nature neuroscience 2012).
The network has been implemented using the *pypet* network framework.
"""
__author__ = 'Robert Meyer'
import numpy as np
import os # To allow path names work under Windows and Linux
from pypet.environment import Environment
from pypet.brian.network import NetworkManager, run_network
from clusternet import CNMonitorAnalysis, CNNeuronGroup, CNNetworkRunner, CNConnections,\
CNFanoFactorComputer
def main():
filename = os.path.join('hdf5', 'Clustered_Network.hdf5')
env = Environment(trajectory='Clustered_Network',
add_time=False,
filename=filename,
continuable=False,
lazy_debug=False,
multiproc=True,
ncores=2,
use_pool=False, # We cannot use a pool, our network cannot be pickled
wrap_mode='QUEUE',
overwrite_file=True)
#Get the trajectory container
traj = env.v_trajectory
# We introduce a `meta` parameter that we can use to easily rescale our network
scale = 1.0 # To obtain the results from the paper scale this to 1.0
# Be aware that your machine will need a lot of memory then!
traj.f_add_parameter('simulation.scale', scale,
comment='Meta parameter that can scale default settings. '
'Rescales number of neurons and connections strenghts, but '
'not the clustersize.')
# We create a Manager and pass all our components to the Manager.
# Note the order, CNNeuronGroups are scheduled before CNConnections,
# and the Fano Factor computation depends on the CNMonitorAnalysis
clustered_network_manager = NetworkManager(network_runner=CNNetworkRunner(),
component_list=(CNNeuronGroup(), CNConnections()),
analyser_list=(CNMonitorAnalysis(),CNFanoFactorComputer()))
# Add original parameters (but scaled according to `scale`)
clustered_network_manager.add_parameters(traj)
# We need `tolist` here since our parameter is a python float and not a
# numpy float.
explore_list = np.arange(1.0, 2.6, 0.2).tolist()
# Explore different values of `R_ee`
traj.f_explore({'R_ee' : explore_list})
# Pre-build network components
clustered_network_manager.pre_build(traj)
# Run the network simulation
traj.f_store() # Let's store the parameters already before the run
env.f_run(clustered_network_manager.run_network)
# Finally disable logging and close all log-files
env.f_disable_logging()
if __name__=='__main__':
main()