diff --git a/mechanisms/CMakeLists.txt b/mechanisms/CMakeLists.txt index 203dedff949356b1a715146baf0ad6d6714aac56..cf183d75545c011dbb5fbb3436221ab7ab4d0933 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 0000000000000000000000000000000000000000..da2d2ae639143b1732b714b20f5ce0c2cf1f2216 --- /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 1779799f716157df995f2321346ad6ff52f1a608..de7bf22d7c84f652148605bdb3581defc249d208 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 :