-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into benchmarking
* development: Add clickable image to quick start page Regenerated with latest nmllite Use latest nml libraries; Regenerated multiple nml files Adding generated mdf files and images for pynn based examples Specify py version for actions/setup-python@v4 One more gha action version update Update versions github actions Latests tests More tests More tests on pynn examples Improved handling of spike transfers Updates to test pynn hh Formatted Initial tests NeuroMLlite->PyNN->MDF type info in input ports in generated graphs Fix issue with onnx trying to add int to float Regenerated with latest nml libraries Test latest modelspec
- Loading branch information
Showing
35 changed files
with
2,062 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
from neuromllite import ( | ||
Network, | ||
Cell, | ||
InputSource, | ||
Population, | ||
Synapse, | ||
RectangularRegion, | ||
RandomLayout, | ||
) | ||
from neuromllite import Projection, RandomConnectivity, Input, Simulation | ||
import sys | ||
|
||
|
||
def generate( | ||
ref, | ||
num_pop0=2, | ||
num_pop1=2, | ||
conn_prob=1, | ||
conn_weight=0.3, | ||
input_percentage=50, | ||
input_weight=".8", | ||
pynn_cell="IF_curr_alpha", | ||
): | ||
|
||
################################################################################ | ||
### Build new network | ||
|
||
net = Network(id=ref) | ||
net.notes = "Example: %s" % ref | ||
net.parameters = {"input_amp": 0.99} | ||
|
||
cell = Cell(id="testcell", pynn_cell=pynn_cell) | ||
|
||
cell.parameters = {"i_offset": 0.0} | ||
if "IF_" in pynn_cell: | ||
cell.parameters["tau_refrac"] = 5 | ||
else: | ||
cell.parameters = {"i_offset": 0.05} | ||
net.parameters = {"input_amp": 0} | ||
net.cells.append(cell) | ||
|
||
input_source = InputSource( | ||
id="i_clamp", | ||
pynn_input="DCSource", | ||
parameters={"amplitude": "input_amp", "start": 200.0, "stop": 800.0}, | ||
) | ||
net.input_sources.append(input_source) | ||
|
||
r1 = RectangularRegion( | ||
id="region1", x=0, y=0, z=0, width=1000, height=100, depth=1000 | ||
) | ||
net.regions.append(r1) | ||
|
||
p0 = Population( | ||
id="pop0", | ||
size=num_pop0, | ||
component=cell.id, | ||
properties={"color": "1 0 0", "radius": 20}, | ||
random_layout=RandomLayout(region=r1.id), | ||
) | ||
net.populations.append(p0) | ||
|
||
if num_pop1 > 0: | ||
p1 = Population( | ||
id="pop1", | ||
size=num_pop1, | ||
component=cell.id, | ||
properties={"color": "0 1 0", "radius": 20}, | ||
random_layout=RandomLayout(region=r1.id), | ||
) | ||
net.populations.append(p1) | ||
|
||
"""p2 = Population( | ||
id="pop2", | ||
size=1, | ||
component=cell2.id, | ||
properties={"color": "0 0 1", "radius": 20}, | ||
random_layout=RandomLayout(region=r1.id), | ||
) | ||
net.populations.append(p2)""" | ||
|
||
net.synapses.append( | ||
Synapse( | ||
id="ampaSyn", | ||
pynn_receptor_type="excitatory", | ||
pynn_synapse_type="curr_alpha", | ||
parameters={"tau_syn": 20}, | ||
) | ||
) | ||
"""net.synapses.append( | ||
Synapse( | ||
id="gabaSyn", | ||
pynn_receptor_type="inhibitory", | ||
pynn_synapse_type="cond_alpha", | ||
parameters={"e_rev": -80, "tau_syn": 10}, | ||
) | ||
)""" | ||
|
||
if num_pop1 > 0: | ||
net.projections.append( | ||
Projection( | ||
id="proj0", | ||
presynaptic=p0.id, | ||
postsynaptic=p1.id, | ||
synapse="ampaSyn", | ||
delay=2, | ||
weight=conn_weight, | ||
) | ||
) | ||
net.projections[0].random_connectivity = RandomConnectivity( | ||
probability=conn_prob | ||
) | ||
|
||
"""net.projections.append( | ||
Projection( | ||
id="proj1", | ||
presynaptic=p0.id, | ||
postsynaptic=p2.id, | ||
synapse="gabaSyn", | ||
delay=2, | ||
weight=0.01, | ||
) | ||
) | ||
net.projections[1].random_connectivity = RandomConnectivity(probability=1)""" | ||
|
||
net.inputs.append( | ||
Input( | ||
id="stim", | ||
input_source=input_source.id, | ||
population=p0.id, | ||
percentage=input_percentage, | ||
weight=input_weight, | ||
) | ||
) | ||
|
||
net_json_file = net.to_json_file("%s.json" % net.id) | ||
net_yaml_file = net.to_yaml_file("%s.yaml" % net.id) | ||
|
||
################################################################################ | ||
### Build Simulation object & save as JSON | ||
|
||
sim = Simulation( | ||
id="Sim%s" % net.id, | ||
network=net_json_file, | ||
duration="1000", | ||
dt="0.01", | ||
record_traces={"all": "*"}, | ||
record_spikes={"all": "*"} if "IF_" in pynn_cell else {}, | ||
) | ||
|
||
sim.to_json_file() | ||
sim.network = net_yaml_file | ||
sim.to_yaml_file("%s.yaml" % sim.id) | ||
|
||
sim.network = net_json_file # reverting, for call below... | ||
|
||
return sim, net | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
if "-one" in sys.argv: | ||
sim, net = generate("OneCell", num_pop0=1, num_pop1=0, input_percentage=100) | ||
elif "-hh" in sys.argv: | ||
sim, net = generate( | ||
"HH", num_pop0=1, num_pop1=0, input_percentage=0, pynn_cell="HH_cond_exp" | ||
) | ||
elif "-input_weights" in sys.argv: | ||
sim, net = generate( | ||
"InputWeights", | ||
num_pop0=4, | ||
num_pop1=0, | ||
input_percentage=62, | ||
input_weight=".8*random()", | ||
) | ||
elif "-simple_net" in sys.argv: | ||
sim, net = generate( | ||
"SimpleNet", | ||
num_pop0=1, | ||
num_pop1=1, | ||
input_percentage=100, | ||
input_weight="1", | ||
) | ||
elif "-net1" in sys.argv: | ||
sim, net = generate( | ||
"Net1", | ||
num_pop0=2, | ||
num_pop1=3, | ||
conn_weight="random()", | ||
input_percentage=100, | ||
input_weight="2*random()", | ||
) | ||
else: | ||
sim, net = generate("All") | ||
|
||
################################################################################ | ||
### Run in some simulators | ||
|
||
from neuromllite.NetworkGenerator import check_to_generate_or_run | ||
|
||
check_to_generate_or_run(sys.argv, sim) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.