File: test3.py

package info (click to toggle)
neuron 8.2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,760 kB
  • sloc: cpp: 149,571; python: 58,465; ansic: 50,329; sh: 3,510; xml: 213; pascal: 51; makefile: 35; sed: 5
file content (92 lines) | stat: -rw-r--r-- 1,961 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from neuron import h

h.load_file("stdrun.hoc")


class Cell(object):
    def __init__(self):
        self.topology()
        self.subsets()
        self.geometry()
        self.biophys()
        self.synapses()

    def topology(self):
        self.soma = h.Section(cell=self)
        self.dend = h.Section(cell=self)
        self.dend.connect(self.soma)
        self.nseg = 5

    def subsets(self):
        self.all = h.SectionList()
        self.all.wholetree(sec=self.soma)

    def geometry(self):
        self.soma.L = 10
        self.soma.diam = 10
        self.dend.L = 500
        self.dend.diam = 1

    def biophys(self):
        for sec in self.all:
            sec.Ra = 100
            sec.cm = 1
        self.soma.insert("hh")

    def synapses(self):
        self.syn = h.ExpSyn(0.5, sec=self.dend)
        self.syn.e = 0
        self.syn.tau = 1

    def connectToTarget(self, syn):
        nc = h.NetCon(self.soma(0.5)._ref_v, syn, sec=self.soma)
        nc.threshold = -10
        return nc


# read which group we are part of
# in the old c interface it was
# g = new_intp()
# if MUSIC_configInt(s, 'group', g):
#  group = intp_value(g)
#  delete_intp(g)
# else:
#  group = 0
# del(g)
from sys import argv
from getopt import gnu_getopt

optlist, args = gnu_getopt(argv[3:], "g:")
group = int(optlist[0][1])

pc = h.ParallelContext()
rank = int(pc.id())
print("group=", group, " rank=", rank)

gid = group
pc.set_gid2node(gid, pc.id())
cell = Cell()
pc.cell(gid, cell.connectToTarget(None))
if gid == 1:
    stim = h.IClamp(cell.soma(0.5))
    stim.delay = 0
    stim.dur = 0.5
    stim.amp = 0.2


from neuronmusic import *

out = publishEventOutput("output")
inp = publishEventInput("input")

out.gid2index(gid, gid - 1)
nc = inp.index2target(gid % 2, cell.syn)
nc.weight[0] = 0.005
nc.delay = 8

pc.set_maxstep(5)
print(group, rank, " call stdinit")
h.stdinit()
print(group, rank, " call psolve")
pc.psolve(50)
print(group, rank, " done")