Skip to content

Commit

Permalink
Update the example files to work with the latest version of Brian2
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
mstimberg committed Nov 28, 2016
1 parent 0487392 commit 0553caf
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 77 deletions.
12 changes: 3 additions & 9 deletions examples/shortEx.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from brian2 import *
import brian2genn

set_device('genn')
set_device('genn', directory='shortEx')
#set_device('cpp_standalone')

tau = 5*ms
Expand All @@ -12,12 +12,6 @@
G = NeuronGroup(10, eqs, threshold='V>1', reset='V=0')
G.k = linspace(1, 5, len(G))
H = NeuronGroup(10, 'V:1')
S = Synapses(H, G, post='V_pre += 1', connect='i==j')
S = Synapses(H, G, post='V_pre += 1')
S.connect(j='i')
run(101*ms)


device.build(directory='shortEx',
compile=True,
run=True,
use_GPU=True)

9 changes: 2 additions & 7 deletions examples/simple_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from brian2 import *
import brian2genn

set_device('genn')
set_device('genn', directory='simple_example')

N = 10000
tau = 10*ms
Expand All @@ -11,9 +11,4 @@
'''
G = NeuronGroup(N, eqs, threshold='V>1', reset='V=0', refractory=5 * ms)

run(10*ms)

device.build(directory='simple_example',
compile=True,
run=True,
use_GPU=True)
run(10*ms)
9 changes: 2 additions & 7 deletions examples/simple_example_HH.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from brian2 import *
import brian2genn

set_device('genn')
set_device('genn', directory='simple_example_HH')

N = 50000
Iin = 10
Expand All @@ -18,11 +18,6 @@
dh/dt= (0.07*exp(-V/20-3)*(1-h)-1/(exp(-3-0.1*V)+1)*h)/ms : 1
dn/dt= ((-0.5-0.01*V)/(exp(-5-0.1*V)-1)*(1-n)-0.125*exp(-(V+60)/80)*n)/ms : 1
'''
G = NeuronGroup(N, eqs, threshold='V> 0', reset='')
G = NeuronGroup(N, eqs, threshold='V> 0', reset='', method='exponential_euler')

run(500*ms)

device.build(project_dir='simple_example_HH',
compile_project=True,
run_project=False,
use_GPU=False)
9 changes: 3 additions & 6 deletions examples/simple_example_HH_CPP.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from brian2 import *
import brian2genn

set_device('cpp_standalone')
set_device('cpp_standalone', directory='simple_example_HH_CPP')

N = 50000
Iin = 10
Expand All @@ -18,12 +18,9 @@
dh/dt= (0.07*exp(-V/20-3)*(1-h)-1/(exp(-3-0.1*V)+1)*h)/ms : 1
dn/dt= ((-0.5-0.01*V)/(exp(-5-0.1*V)-1)*(1-n)-0.125*exp(-(V+60)/80)*n)/ms : 1
'''
G = NeuronGroup(N, eqs, threshold='V> 30', refractory='3*ms')
G = NeuronGroup(N, eqs, threshold='V> 30', refractory='3*ms',
method='exponential_euler')
mon = SpikeMonitor(G,record=True)
mon2= StateMonitor(G,'V',record=True)

run(500*ms)

device.build(project_dir='simple_example_HH_CPP',
compile_project=True,
run_project=False)
57 changes: 23 additions & 34 deletions examples/simple_example_synapses.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from brian2 import *
import brian2genn

set_device('genn')
set_device('genn', directory='simple_example_synapses')
#set_device('cpp_standalone')

N = 100
Expand All @@ -11,49 +11,38 @@
Iin : 1
'''
G = NeuronGroup(N, eqs, threshold='V>1', reset='V=0', name='PN')
G.V= rand()
G2= NeuronGroup(N, eqs, threshold='V>1', reset='V=0', name='LN')
G2.V= 2*rand()
G.V = rand()
G2 = NeuronGroup(N, eqs, threshold='V>1', reset='V=0', name='LN')
G2.V = 2 * rand()

alpha= 20*ms
beta= 30*ms
S= Synapses(G, G2,
model='''
alpha = 20 * ms
beta = 30 * ms
S = Synapses(G, G2,
model='''
ds/dt= alpha*(1-s) - beta*s: 1
g: 1
''',
pre='Iin_post+= g',
name='ex_syns')

alpha2= 40*ms
beta2= 60*ms
p_post= 1
p_pre= 30
S2= Synapses(G2, G,
model='''
pre='Iin_post+= g',
name='ex_syns')

alpha2 = 40 * ms
beta2 = 60 * ms
p_post = 1
p_pre = 30
S2 = Synapses(G2, G,
model='''
ds/dt= alpha2*(1-s) - beta2*s: 1
g: 1
''',
pre='Iin_post+= g*p_pre',
post='''
pre='Iin_post+= g*p_pre',
post='''
g*= p_post-0.9;
''',
name='inh_syns')
name='inh_syns')

S.connect(1,5);
S.connect('i != j', n=2);
S.connect([1, 2],[1, 2]);
S.connect(i=1, j=5)
S.connect(i=[1, 2], j=[1, 2])

S.g= 'rand()'
S.g = 'rand()'

run(100*ms)

device.build(directory='simple_example_synapses',
compile=True,
run=True,
use_GPU=True)

#device.build(directory='simple_example_synapses',
# compile=True,
# run=True)

19 changes: 5 additions & 14 deletions examples/simple_spikesource.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
from brian2 import *
import brian2genn

set_device('genn')
set_device('genn', directory='simple_spikesource')
#set_device('cpp_standalone')

G = NeuronGroup(10, 'v:1')
mon = StateMonitor(G, 'v', record=True)
indices = np.array([3, 2, 1, 1, 4, 5])
times = np.array([6, 5, 4, 3, 3, 1]) * ms
times = np.array([6, 5, 4, 3, 3, 1]) * ms
SG = SpikeGeneratorGroup(10, indices, times)
mon2= SpikeMonitor(SG, record=True);
S = Synapses(SG, G, pre='v+=1', connect='i==j')
mon2 = SpikeMonitor(SG, record=True)
S = Synapses(SG, G, on_pre='v+=1')
S.connect(j='i')
run(7*ms)

device.build(directory='simple_spikesource',
compile=True,
run=True,
use_GPU=True)

#device.build(directory='simple_statemon',
# compile=True,
# run=True)

0 comments on commit 0553caf

Please sign in to comment.