Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/omv-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:

pip install matplotlib "cython<3.1.0" # let omv handle other deps...
pip install 'numpy==2.2.6' # to test against older numpy versions... TODO: remove when pynn v0.12 used!
pip install 'ruff<0.16.0'

pip list

Expand Down
20 changes: 10 additions & 10 deletions NeuroML2/ConnectionsTest.net.nml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,38 @@
<property tag="radius" value="5"/>
<property tag="color" value="0 0.6 0"/>
<instance id="0">
<location x="90.050794506160045" y="7.254555410622721" z="39.268687873108753"/>
<location x="4.209700831042507" y="-30.060988524501674" z="-81.982020783889737"/>
</instance>
<instance id="1">
<location x="61.304488204048745" y="-59.460091275867221" z="8.858905095534531"/>
<location x="-57.335015039329647" y="-6.297426392275796" z="-0.448761327616043"/>
</instance>
<instance id="2">
<location x="-62.570071785081097" y="-10.844079532907912" z="-61.815815933978449"/>
<location x="52.759440963081737" y="-19.310997522074146" z="31.141571409768186"/>
</instance>
<instance id="3">
<location x="42.375423132204034" y="71.595363566842991" z="9.005942698898073"/>
<location x="-25.867595815569299" y="-62.416348748711449" z="67.109578171047161"/>
</instance>
<instance id="4">
<location x="-20.021124003171842" y="68.472808807587327" z="-26.18178437775336"/>
<location x="-17.357743788692126" y="24.751165168378499" z="32.114864072799996"/>
</instance>
</population>
<population id="pop_post" component="IF_cond_alpha_pop_post" size="5" type="populationList">
<property tag="radius" value="5"/>
<property tag="color" value="0 0.2 0.6"/>
<instance id="0">
<location x="48.678916194264673" y="279.316954300792474" z="-21.690907467921839"/>
<location x="1.916209654706091" y="177.082836325877679" z="-80.457283927372018"/>
</instance>
<instance id="1">
<location x="26.883422152791823" y="255.692772966582908" z="-6.507133033574863"/>
<location x="3.848313976389739" y="156.951533198278497" z="-14.941016596081692"/>
</instance>
<instance id="2">
<location x="-55.187165174992444" y="266.61320420224979" z="48.892538134082784"/>
<location x="64.896573629684994" y="195.130355191321598" z="16.953216848059682"/>
</instance>
<instance id="3">
<location x="-29.859781674876395" y="241.67170994380615" z="52.303168968100323"/>
<location x="-6.688354462962809" y="221.60729005120686" z="12.184740549366623"/>
</instance>
<instance id="4">
<location x="-56.517126882764245" y="252.075622642045374" z="46.648919980159874"/>
<location x="8.846145050113407" y="169.077614429419157" z="33.027602199152462"/>
</instance>
</population>
<projection id="pop_pre__TO__pop_post" presynapticPopulation="pop_pre" postsynapticPopulation="pop_post" synapse="syn__pop_pre__TO__pop_post">
Expand Down
Binary file modified NeuroML2/Positions.net.nml.h5
Binary file not shown.
139 changes: 86 additions & 53 deletions PyNN/ConnectionsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,130 +2,163 @@
Simple network for testing export to NeuroML v1 & v2

"""
import logging
logging.basicConfig(format='%(levelname)s - %(name)s: %(message)s', level=logging.DEBUG)

import sys
import os
from importlib import import_module
import numpy as np

from pyNN.utility import get_script_args
import pyNN.space as space

simulator_name = get_script_args(1)[0]
import numpy as np
import logging
import sys
import os

logging.basicConfig(format="%(levelname)s - %(name)s: %(message)s", level=logging.DEBUG)


simulator_name = get_script_args(1)[0]
sim = import_module("pyNN.%s" % simulator_name)

tstop = 500.0
time_step = 0.005

sim.setup(timestep=time_step, debug=True, reference='ConnectionsTest')
sim.setup(timestep=time_step, debug=True, reference="ConnectionsTest")


sphere1 = space.Sphere(radius=100.0)
struct1 = space.RandomStructure(sphere1, origin=(0.0, 0.0, 0.0))

cell_params = {'tau_refrac':5,'v_thresh':-50.0, 'v_reset':-65.0, 'i_offset': 0.9, 'tau_syn_E' : 2.0, 'tau_syn_I': 5.0}
pop_pre = sim.Population(5, sim.IF_cond_alpha(**cell_params), label="pop_pre",structure=struct1)
pop_pre.record('v')
cell_params = {
"tau_refrac": 5,
"v_thresh": -50.0,
"v_reset": -65.0,
"i_offset": 0.9,
"tau_syn_E": 2.0,
"tau_syn_I": 5.0,
}
pop_pre = sim.Population(
5, sim.IF_cond_alpha(**cell_params), label="pop_pre", structure=struct1
)
pop_pre.record("v")
pop_pre.annotate(radius=5)
pop_pre.annotate(color='0 0.6 0')
pop_pre.annotate(color="0 0.6 0")

sphere2 = space.Sphere(radius=100.0)
struct2 = space.RandomStructure(sphere2, origin=(0.0, 200.0, 0.0))
pop_post = sim.Population(5, sim.IF_cond_alpha(**cell_params), label="pop_post",structure=struct2)
pop_post.record('v')
pop_post = sim.Population(
5, sim.IF_cond_alpha(**cell_params), label="pop_post", structure=struct2
)
pop_post.record("v")
pop_post.annotate(radius=5)
pop_post.annotate(color='0 0.2 0.6')
pop_post.annotate(color="0 0.2 0.6")

pre_selection = sim.PopulationView(pop_pre, np.array([1,3]),label='pre_selection')
print("Creating view: %s"%pre_selection)
post_selection = sim.PopulationView(pop_post, np.array([0,2,4]),label='post_selection')
print("Creating view: %s"%post_selection)
pre_selection = sim.PopulationView(pop_pre, np.array([1, 3]), label="pre_selection")
print("Creating view: %s" % pre_selection)
post_selection = sim.PopulationView(
pop_post, np.array([0, 2, 4]), label="post_selection"
)
print("Creating view: %s" % post_selection)

###################################################################
# Projection less connection
connE = sim.connect(pop_pre, pop_post, weight=0.01, receptor_type='excitatory', delay=10)
connE = sim.connect(
pop_pre, pop_post, weight=0.01, receptor_type="excitatory", delay=10
)


###################################################################
# AllToAllConnector connection
proj1 = sim.Projection(pop_pre, pop_post, sim.AllToAllConnector(),
sim.StaticSynapse(weight=0.05, delay=5),label="AllToAllConnectorProj")
proj1 = sim.Projection(
pop_pre,
pop_post,
sim.AllToAllConnector(),
sim.StaticSynapse(weight=0.05, delay=5),
label="AllToAllConnectorProj",
)

###################################################################
# OneToOneConnector connection
proj2 = sim.Projection(pop_pre, pop_post, sim.OneToOneConnector(),
sim.StaticSynapse(weight=0.02, delay=4),label="OneToOneConnector")
proj2 = sim.Projection(
pop_pre,
pop_post,
sim.OneToOneConnector(),
sim.StaticSynapse(weight=0.02, delay=4),
label="OneToOneConnector",
)

###################################################################
# FixedProbabilityConnector connection
proj3 = sim.Projection(pop_pre, pop_post, sim.FixedProbabilityConnector(p_connect=0.2),
sim.StaticSynapse(weight=0.1, delay=1),label="FixedProbabilityConnector")

proj3 = sim.Projection(
pop_pre,
pop_post,
sim.FixedProbabilityConnector(p_connect=0.2),
sim.StaticSynapse(weight=0.1, delay=1),
label="FixedProbabilityConnector",
)


###################################################################
# AllToAllConnector between pre_selection & post_selection
proj1 = sim.Projection(pre_selection, post_selection, sim.AllToAllConnector(),
sim.StaticSynapse(weight=0.05, delay=5),label="AllToAllConnectorProjSelection")
proj1 = sim.Projection(
pre_selection,
post_selection,
sim.AllToAllConnector(),
sim.StaticSynapse(weight=0.05, delay=5),
label="AllToAllConnectorProjSelection",
)

sim.run(tstop)

use_hdf5 = False

if use_hdf5:
from neo.io import NeoHdf5IO as NeoIO
suffix = 'h5'

suffix = "h5"

results_file = "Results/ConnectionTest_%s.%s" % (simulator_name, suffix)
if os.path.exists(results_file):
os.remove(results_file)
io = NeoIO(results_file)
""" to be updated...
pop_IF_curr_alpha.write_data(io)
pop_IF_curr_exp.write_data(io)
pop_IF_cond_alpha.write_data(io)
pop_IF_cond_exp.write_data(io)
pop_EIF_cond_exp_isfa_ista.write_data(io)
pop_HH_cond_exp.write_data(io)
pop_post1.write_data(io)
pop_post2.write_data(io)
pop_post2.write_data(io)"""

else:
#from neo.io import AsciiSignalIO as NeoIO
#suffix = 'txt'
#results_file = "Results/NeuroMLTest_%s.%s" % (simulator_name, suffix)
# from neo.io import AsciiSignalIO as NeoIO
# suffix = 'txt'
# results_file = "Results/NeuroMLTest_%s.%s" % (simulator_name, suffix)

for pop in [pop_pre, pop_post]:
data = pop.get_data('v', gather=False)
filename = "%s_v.dat"%(pop.label)
print("Writing data for %s"%pop)
for segment in data.segments :
data = pop.get_data("v", gather=False)
filename = "%s_v.dat" % (pop.label)
print("Writing data for %s" % pop)
for segment in data.segments:
vm = segment.analogsignals[0].transpose()[0]
tt = np.array([t*time_step/1000. for t in range(len(vm))])
times_vm = np.array([tt, vm/1000.]).transpose()
np.savetxt(filename, times_vm , delimiter = '\t', fmt='%s')
tt = np.array([t * time_step / 1000.0 for t in range(len(vm))])
times_vm = np.array([tt, vm / 1000.0]).transpose()
np.savetxt(filename, times_vm, delimiter="\t", fmt="%s")


sim.end()

if '-gui' in sys.argv:
if simulator_name in ['neuron', 'nest', 'brian']:
if "-gui" in sys.argv:
if simulator_name in ["neuron", "nest", "brian"]:
import matplotlib.pyplot as plt
print("Plotting results of simulation in %s"%simulator_name)

print("Plotting results of simulation in %s" % simulator_name)

plt.figure("Voltages for IaF cells")
for pop in [pop_pre, pop_post]:
data = pop.get_data()
vm = data.segments[0].analogsignals[0]
plt.plot(vm, '-', label='%s: v'%pop.label)

plt.legend()


plt.plot(vm, "-", label="%s: v" % pop.label)

plt.legend()

plt.show()



Loading