From fce2c76b471a26f9355540c0aac1b374d0ad41ad Mon Sep 17 00:00:00 2001 From: Sam Yates <halfflat@gmail.com> Date: Thu, 14 Jul 2016 19:31:57 +0200 Subject: [PATCH] Adapt NEURON's standard exp2syn for use and validation * Add a tweaked version of exp2syn.mod that is modparser compatible. * Add option to simple_synapse.py to choose which syn type to use. * Compatibility tweak for runinng nrn scripts with nrniv -python --- mechanisms/CMakeLists.txt | 2 +- mechanisms/mod/exp2syn.mod | 50 ++++++++++++++++++++++++++++++++++++++ nrn/simple_synapse.py | 29 +++++++++++++++++++--- 3 files changed, 76 insertions(+), 5 deletions(-) create mode 100755 mechanisms/mod/exp2syn.mod diff --git a/mechanisms/CMakeLists.txt b/mechanisms/CMakeLists.txt index 203dedff..cf183d75 100644 --- a/mechanisms/CMakeLists.txt +++ b/mechanisms/CMakeLists.txt @@ -1,4 +1,4 @@ -set(mechanisms pas hh expsyn) +set(mechanisms pas hh expsyn exp2syn) set(modcc "${CMAKE_BINARY_DIR}/external/bin/modcc") diff --git a/mechanisms/mod/exp2syn.mod b/mechanisms/mod/exp2syn.mod new file mode 100755 index 00000000..da2d2ae6 --- /dev/null +++ b/mechanisms/mod/exp2syn.mod @@ -0,0 +1,50 @@ +NEURON { + POINT_PROCESS Exp2Syn + RANGE tau1, tau2, e + NONSPECIFIC_CURRENT i +} + +UNITS { + (nA) = (nanoamp) + (mV) = (millivolt) + (uS) = (microsiemens) +} + +PARAMETER { + tau1=.1 (ms) : <1e-9,1e9> + tau2 = 10 (ms) : <1e-9,1e9> + e=0 (mV) +} + +ASSIGNED { + factor +} + +STATE { + A : (uS) + B : (uS) +} + +INITIAL { + LOCAL tp + A = 0 + B = 0 + tp = (tau1*tau2)/(tau2 - tau1) * log(tau2/tau1) + factor = -exp(-tp/tau1) + exp(-tp/tau2) + factor = 1/factor +} + +BREAKPOINT { + SOLVE state METHOD cnexp + i = (B - A)*(v - e) +} + +DERIVATIVE state { + A' = -A/tau1 + B' = -B/tau2 +} + +NET_RECEIVE(weight) { + A = A + weight*factor + B = B + weight*factor +} diff --git a/nrn/simple_synapse.py b/nrn/simple_synapse.py index 1779799f..de7bf22d 100644 --- a/nrn/simple_synapse.py +++ b/nrn/simple_synapse.py @@ -8,7 +8,20 @@ from neuron import gui, h parser = argparse.ArgumentParser(description='generate spike train ball and stick model with hh channels at soma and pas channels in dendrite') parser.add_argument('--plot', action='store_true', dest='plot') -args = parser.parse_args() +parser.add_argument('--synapse', metavar='SYN', dest='synapse', + choices=['exp', 'exp2'], + default='exp', + help='use synapse type SYN (exp or exp2)') + +# hack to make things work with nrniv ... -python: +# throw away args before -python foo.py if -python present. + +if '-python' in sys.argv: + argv = sys.argv[sys.argv.index('-python')+2:] +else: + argv = sys.argv + +args = parser.parse_args(argv) soma = h.Section(name='soma') dend = h.Section(name='dend') @@ -62,8 +75,16 @@ for nseg in [5, 11, 51, 101] : dend.nseg=nseg # add a synapse - syn_ = h.ExpSyn(dend(0.5)) - syn_.tau = 2 + if args.synapse == 'exp': + syn_ = h.ExpSyn(dend(0.5)) + syn_.tau = 2 + elif args.synapse == 'exp2': + syn_ = h.Exp2Syn(dend(0.5)) + syn_.tau1 = 0.5 # artificially slow onset + syn_.tau2 = 2 + else: + raise RuntimeError('unrecognized synapse type') + ncstim = h.NetCon(stim, syn_) ncstim.delay = 1 # 1 ms delay (arrives at 10ms) ncstim.weight[0] = 0.04 # NetCon weight is a vector @@ -127,7 +148,7 @@ end = timer() print "took ", end-start, " seconds" # save the spike info as in json format -fp = open('simple_synapse.json', 'w') +fp = open('simple_'+args.synapse+'_synapse.json', 'w') json.dump(results, fp, indent=2) if args.plot : -- GitLab