|
1 | | -from neuromllite import Network, Cell, InputSource, Population, Synapse, RectangularRegion, RandomLayout |
| 1 | +from neuromllite import ( |
| 2 | + Network, |
| 3 | + Cell, |
| 4 | + InputSource, |
| 5 | + Population, |
| 6 | + Synapse, |
| 7 | + RectangularRegion, |
| 8 | + RandomLayout, |
| 9 | +) |
2 | 10 | from neuromllite import Projection, RandomConnectivity, Input, Simulation |
3 | 11 | from neuromllite.NetworkGenerator import generate_and_run |
4 | 12 | import sys |
5 | 13 |
|
6 | 14 | ################################################################################ |
7 | 15 | ### Build new network |
8 | 16 |
|
9 | | -net = Network(id='SimpleNet') |
10 | | -net.notes = 'Simple network with single population' |
| 17 | +net = Network(id="SimpleNet") |
| 18 | +net.notes = "Simple network with single population" |
11 | 19 | net.temperature = 32.0 |
12 | 20 |
|
13 | | -cell = Cell(id='RS', neuroml2_source_file='../../NeuroML2/prototypes/izhikevich/RS.cell.nml') |
| 21 | +cell = Cell( |
| 22 | + id="RS", neuroml2_source_file="../../NeuroML2/prototypes/izhikevich/RS.cell.nml" |
| 23 | +) |
14 | 24 | net.cells.append(cell) |
15 | 25 |
|
16 | | -syn = Synapse(id='ampa', neuroml2_source_file='../../NeuroML2/prototypes/synapses/ampa.synapse.nml') |
| 26 | +syn = Synapse( |
| 27 | + id="ampa", |
| 28 | + neuroml2_source_file="../../NeuroML2/prototypes/synapses/ampa.synapse.nml", |
| 29 | +) |
17 | 30 | net.synapses.append(syn) |
18 | 31 |
|
19 | | -input_source = InputSource(id='poissonFiringSyn', |
20 | | - neuroml2_input='poissonFiringSynapse', |
21 | | - parameters={'average_rate':"50Hz", 'synapse':syn.id, 'spike_target':"./ampa"}) |
| 32 | +input_source = InputSource( |
| 33 | + id="poissonFiringSyn", |
| 34 | + neuroml2_input="poissonFiringSynapse", |
| 35 | + parameters={"average_rate": "50Hz", "synapse": syn.id, "spike_target": "./ampa"}, |
| 36 | +) |
22 | 37 | net.input_sources.append(input_source) |
23 | 38 |
|
24 | | -r1 = RectangularRegion(id='region1', x=0,y=0,z=0,width=100,height=100,depth=100) |
| 39 | +r1 = RectangularRegion(id="region1", x=0, y=0, z=0, width=100, height=100, depth=100) |
25 | 40 | net.regions.append(r1) |
26 | 41 |
|
27 | | -p0 = Population(id='RS_pop', size=3, component=cell.id, properties={'color':'0 .8 0'},random_layout = RandomLayout(region=r1.id)) |
| 42 | +p0 = Population( |
| 43 | + id="RS_pop", |
| 44 | + size=3, |
| 45 | + component=cell.id, |
| 46 | + properties={"color": "0 .8 0"}, |
| 47 | + random_layout=RandomLayout(region=r1.id), |
| 48 | +) |
28 | 49 |
|
29 | 50 | net.populations.append(p0) |
30 | 51 |
|
31 | | -net.inputs.append(Input(id='Stim0', |
32 | | - input_source=input_source.id, |
33 | | - population=p0.id, |
34 | | - percentage=100)) |
| 52 | +net.inputs.append( |
| 53 | + Input(id="Stim0", input_source=input_source.id, population=p0.id, percentage=100) |
| 54 | +) |
35 | 55 |
|
36 | 56 | print(net.to_json()) |
37 | | -new_file = net.to_json_file('%s.json'%net.id) |
| 57 | +new_file = net.to_json_file("%s.json" % net.id) |
38 | 58 |
|
39 | 59 |
|
40 | 60 | ################################################################################ |
41 | 61 | ### Build Simulation object & save as JSON |
42 | 62 |
|
43 | | -sim = Simulation(id='SimSimpleNet', |
44 | | - network=new_file, |
45 | | - duration='1000', |
46 | | - dt='0.025', |
47 | | - record_traces={'all':'*'}) |
| 63 | +sim = Simulation( |
| 64 | + id="SimSimpleNet", |
| 65 | + network=new_file, |
| 66 | + duration="1000", |
| 67 | + dt="0.025", |
| 68 | + record_traces={"all": "*"}, |
| 69 | +) |
48 | 70 |
|
49 | 71 | sim.to_json_file() |
50 | 72 |
|
51 | 73 |
|
52 | | - |
53 | 74 | ################################################################################ |
54 | 75 | ### Run in some simulators |
55 | 76 |
|
|
0 commit comments