def synapses(self): s = h.ExpSyn(self.dend(0.8)) # E0 s.tau = 2 self.synlist.append(s) s = h.ExpSyn(self.dend(0.1)) # I1 s.tau = 5 s.e = -80 self.synlist.append(s)
def createSynapses(self): """Add an exponentially decaying synapse """ synsoma = h.ExpSyn(self.soma(0.5)) synsoma.tau = 2 synsoma.e = 0 syndend = h.ExpSyn(self.dend(0.5)) syndend.tau = 2 syndend.e = 0 self.synlist.append(synsoma) # synlist is defined in Cell self.synlist.append(syndend) # synlist is defined in Cell
def make_synapses(self): self.synlist = list() syn = h.ExpSyn(0.5, sec=self.soma) syn.tau = 5 self.synlist.append(syn) syn = h.ExpSyn(0.5, sec=self.soma) syn.tau = 10 syn.e = -80 self.synlist.append(syn)
def construct(self): #Create soma and two dendrites self.soma = h.Section() #Set soma parameters self.soma.nseg = 1 self.soma.diam = 18.8 self.soma.L = 18.8 self.soma.Ra = 123.0 self.soma.insert('hh') self.soma.gnabar_hh = 0.25 self.soma.gl_hh = .0001666 self.soma.el_hh = -60.0 #Create dendrite model self.dend1 = h.Section() self.dend1.nseg = 5 self.dend1.diam = 3.18 self.dend1.L = 701.9 self.dend1.Ra = 123 self.dend1.insert('pas') self.dend1.g_pas = .0001666 self.dend1.e_pas = -60.0 #Create dendrite model self.dend2 = h.Section() self.dend2.nseg = 5 self.dend2.diam = 2.0 self.dend2.L = 549.1 self.dend2.Ra = 123 self.dend2.insert('pas') self.dend2.g_pas = .0001666 self.dend2.e_pas = -60.0 #Create axon model self.axon = h.Section() self.axon.nseg = 10 self.axon.diam = 2 self.axon.L = 5000 self.axon.Ra = 10000 self.axon.insert('pas') self.axon.g_pas = .0001666 self.axon.e_pas = -60.0 #Connect two dendrites to soma, as well as axon self.dend1.connect(self.soma, 0, 1) self.dend2.connect(self.soma, 1, 0) self.axon.connect(self.soma, 0.5, 0) #Add on our synapses! Two on each dendrite, and one on the axon, and one on the soma. self.syn1 = h.ExpSyn(0.5, sec=self.soma) self.syn2 = h.ExpSyn(0, sec=self.dend1) self.syn3 = h.ExpSyn(1, sec=self.dend2) self.syn4 = h.ExpSyn(1, sec=self.axon)
def add_exp_syn(self, secname, pos=0.5, **kw): p = combine(default_model_parameters, kw) syn = h.ExpSyn(self.sections[secname](pos)) syn.tau = p['tau'] self.synapses.append(syn) return len(self.synapses)-1
def create_synapses(self): """Add an exponentially decaying synapse in the middle of the dendrite. Set its tau to 2ms, and append this synapse to the synlist of the cell.""" syn = h.ExpSyn(self.dend(0.5)) syn.tau = 2 self.synlist.append(syn) # synlist is defined in Cell
def connect_axon(self, axon): # configure ExpSyn synapse synapse = h.ExpSyn(1e-3, axon.allseclist) #1e-3 synapse.e = 10 synapse.i = 0.2 synapse.tau = 0.1 # get spike train spikeTrain = self.spikeTrains[self.axonIndex] self.axonIndex += 1 # configure input to synapse vecStim = h.VecStim() spikeVec = h.Vector(spikeTrain) # axon.spikeVec = h.Vector([1,2,3]) vecStim.play(spikeVec) # connect synapse and VecStim input netCon = h.NetCon(vecStim, synapse) netCon.weight[0] = 1 # add the variables to the axon instance in order to keep them alive # delete after simulation excitationMechanismVars = [ synapse, vecStim, spikeVec, spikeTrain, netCon ] axon.append_ex_mech_vars(excitationMechanismVars)
def create_synapses(self): """ """ self.syn_I = h.ExpSyn(self.dend(0.4)) self.syn_I.tau = 17 self.syn_I.e = 0 self.synlist.append(self.syn_I) self.syn_I_inh = h.ExpSyn(self.dend(0.4)) self.syn_I_inh.tau = 5 self.syn_I_inh.e = -70 self.synlist.append(self.syn_I_inh) self.syn_II = h.ExpSyn(self.dend(0.8)) self.syn_II.tau = 18 self.syn_II.e = 0 self.synlist.append(self.syn_II) # synlist is defined in Cell
def insert_synapse(self): """ This method inserts an exponential synapse at the midpoint of the cell dendrite. """ syn = h.ExpSyn(self.dend(0.5)) syn.tau = 2 return syn
def create_synapses(self, n=1): """Add an exponentially decaying synapse in the middle of the dendrite. Set its tau to 2ms, and append this synapse to the synlist of the cell.""" for i in xrange(n): syn = h.ExpSyn(self.dend(0.5)) # syn = h.ExpSyn(self.dend(round(np.random.rand(), 2))) syn.tau = 2 self.synlist.append(syn) # synlist is defined in Cell
def makeStimulus(soma, simTime): stimNc = h.NetStim() stimNc.noise = 1 stimNc.start = 0 stimNc.number = simTime stimNc.interval = 10 syn = h.ExpSyn(0.5, sec=soma) nc = h.NetCon(stimNc, syn) nc.weight[0] = 20 return (stimNc, syn, nc)
def makeStimulus( soma, simTime,NCstrengthStim ): interval = 25 stimNc = h.NetStim() stimNc.noise = 1 stimNc.start = 0 stimNc.number = simTime stimNc.interval = interval syn = h.ExpSyn (0.5, sec = soma) nc = h.NetCon(stimNc, syn) nc.weight[0] = NCstrengthStim return (stimNc, syn, nc)
def makeStimulus( soma, simTime ): interval = 25 stimNc = h.NetStim() stimNc.noise = 1 stimNc.start = ceil(25*rand(1,1)) stimNc.number = simTime stimNc.interval = interval syn = h.ExpSyn (0.5, sec = soma) nc = h.NetCon(stimNc, syn) nc.weight[0] = 20 return (stimNc, syn, nc)
def main(var): global nc_w, nc_d setting = {'geometry': celldim(soma_d=12.6157, soma_l=12.6157, dend_d=1, dend_l=100, dend_seg=101), 'biophysics': cellbiophy(Ra=100, Cm=1, soma_hh_gnabar=0.12, soma_hh_gkbar=0.036, soma_hh_gl=0.0003, soma_hh_el=-54.3, dend_g=0.001, dend_e=-65)} N=3 var = np.float(var) deviation = lambda r: np.random.standard_normal(N)*r cell_settings = [] for i in range(N): set = {} set['geometry'] = celldim(soma_d=12.6157, soma_l=12.6157, dend_d=1, dend_l=100, dend_seg=101) set['biophysics'] = cellbiophy(Ra=100, Cm=1, soma_hh_gnabar=0.12 + 0.12*deviation(var)[i], soma_hh_gkbar=0.036 + 0.036*deviation(var)[i], soma_hh_gl= 0.0003 + 0.0003*deviation(var)[i], soma_hh_el=-54.3, dend_g=0.001, dend_e=-65) cell_settings.append(set) cells = [BallAndStick(settings) for settings in cell_settings] nclist = [] esyns = [] # Connect neuron in ring. for i in range(N): src = cells[i] tgt = cells[(i+1)%N] syn = h.ExpSyn(tgt.dend(0.5)) esyns.append(syn) nc = h.NetCon(src.soma(0.5)._ref_v, syn, sec=src.soma) nc.weight[0] = nc_w nc.delay = nc_d nclist.append(nc) # Create AlphaSynapse for init network syn = h.AlphaSynapse(cells[0].dend(0.5)) syn.gmax = 0.1 syn.tau = 1 syn.onset = 20 syn.e = 0 # Create output tables t_vec = h.Vector() soma1_vec = h.Vector() soma2_vec = h.Vector() soma3_vec = h.Vector() t_vec.record(h._ref_t) soma1_vec.record(cells[0].soma(0.5)._ref_v) soma2_vec.record(cells[1].soma(0.5)._ref_v) soma3_vec.record(cells[2].soma(0.5)._ref_v) # Run simulation h.tstop = 50 h.run() # plot results plt.plot(t_vec, soma1_vec, t_vec, soma2_vec, t_vec, soma3_vec)
def define_biophysics(self, syn_loc): """Assign the membrane properties across the cell.""" for sec in self.all: # 'all' exists in parent object. sec.Ra = 70 # Axial resistance in Ohm * cm sec.cm = 1 # Membrane capacitance in micro Farads / cm^2 # Insert active Hodgkin-Huxley current in the soma self.dap_syn_ = h.Exp2Syn(self.soma(0.5)) self.dap_syn_.tau1 = 2 self.dap_syn_.tau2 = 5 self.dap_syn_.e = 50 self.dap_nc_ = h.NetCon(self.soma(0.5)._ref_v,\ self.dap_syn_, sec=self.soma) self.dap_nc_.delay = 0 self.dap_nc_.threshold = 10 self.dend_syn = h.Exp2Syn(self.dend(syn_loc)) #self.dend_syn.tau1 = 1 #self.dend_syn.tau2 = 17 self.dend_syn = h.ExpSyn(self.dend(syn_loc)) self.dend_syn.tau = .5 self.dend_syn.e = 0 self.soma.insert('clarke') # FINAL VERSIONS self.soma.gl_clarke = 0.003 self.soma.tau_n_bar_clarke = 7 self.dap_nc_.weight[0] = 7.5e-3 self.soma.gkrect_clarke = 0.6 # SWEEP VALUES #self.soma.gcaN_clarke = 0 #self.soma.gcaL_clarke = 0 #self.soma.gcak_clarke = 0 #self.soma.gnapbar_clarke = 0 #self.soma.tau_mc_clarke = 0 #self.soma.tau_hc_clarke = 0 #self.soma.tau_n_bar_clarke = 0 #self.dap_nc_.weight[0] = 0 #self.soma.gkrect_clarke = 0 #self.soma.gnabar_clarke = 0 #self.soma.insert('pas') #self.soma.g_pas = 1e-3 # Passive conductance in S/cm2 #self.soma.e_pas = -64 # Leak reversal potential mV #self.soma.insert('extracellular') # Insert passive current in the dendrite self.dend.insert('pas') self.dend.g_pas = 0.001 # Passive conductance in S/cm2 self.dend.e_pas = -54.3 # Leak reversal potential mV
def create_synapse(self, type): """ Create and return a synapse that links motoneuron state variables to external events. The created synapse is also appended to a list containg all synapses the this motoneuron has. Keyword arguments: type -- type of synapse to be created. This could be: 1) "excitatory" to create an excitatory synapse positioned on the dendritic tree 2) "inhibitory" to create an inhibitory synapse positioned on the soma 3) "ees" to create a synapse that mimic the recruitmend induced by electrical stimulation; in this case the synapse is positioned on the axon. """ if type == "excitatory": # from Iaf to Mn we usually have 5 boutons for synapse nBoutonsXsyn = 5 n = 0 for i in range(nBoutonsXsyn): n += np.random.poisson(4) n = round(n / nBoutonsXsyn) - 2 # mean and shift to 0 if n < 0: n = 0 elif n > self._nDendrites: n = self._nDendrites - 1 x = rnd.random() syn = h.ExpSyn(self.dendrite[int(n)](x)) syn.tau = 0.5 syn.e = 0 self.synapses.append(syn) elif type == "inhibitory": syn = h.Exp2Syn(self.soma(0.5)) syn.tau1 = 1.5 syn.tau2 = 2 syn.e = -75 self.synapses.append(syn) elif type == "ees": syn = h.ExpSyn(self.node[3](0.5)) syn.tau = 0.1 syn.e = 50 self.synapses.append(syn) return syn
def activate_hoc_syn(self, source, targetCell, threshold=10.0, delay=0.0, weight=0.0): x = targetCell.sections[self.secID].relPts[self.ptID] hocSec = targetCell.sections[self.secID] self.syn = h.ExpSyn(x, hocSec) self.syn.tau = 1.7 self.syn.e = 0.0 self.netcon = h.NetCon(source, self.syn, threshold, delay, weight) self._active = True
def create_synapses(self): """Add an exponentially decaying synapse in the middle of the dendrite. Set its tau to 2ms, and append this synapse to the synlist of the cell.""" syn = h.ExpSyn(self.dend[0](0.1)) syn.tau = 3 self.synlist.append(syn) # synlist is defined in Cell syn = h.ExpSyn(self.dend[5](0.1)) syn.tau = 3 self.synlist.append(syn) # synlist is defined in Cell syn = h.Exp2Syn(self.soma(0.3)) syn.tau1 = 3 syn.tau2 = 10 syn.e = -85 self.synlist.append(syn) # synlist is defined in Cell syn = h.Exp2Syn(self.soma(0.5)) syn.tau1 = 3 syn.tau2 = 10 syn.e = -85 self.synlist.append(syn) # synlist is defined in Cell
def __init__(self, romans=0, judeans=1): self.source_section = h.Section() self.source = self.source_section(0.5)._ref_v #self.synapse = h.tmgsyn(self.source_section(0.5)) self.record = Mock() self.record_v = Mock() self.record_gsyn = Mock() self.memb_init = Mock() self.excitatory = h.ExpSyn(self.source_section(0.5)) self.inhibitory = None self.romans = romans self.judeans = judeans self.foo_init = -99.9 self.traces = {}
def __init__(self, id, nsec): r = h.Random() r.Random123(id, 0, 0) nsec += int(r.discunif(0, 4)) # for nontrivial cell_permute=1 self.id = id self.secs = [ h.Section(name="d" + str(i), cell=self) for i in range(nsec) ] # somewhat random tree, d[0] plays role of soma with connections to # d[0](0.5) and all others to 1.0 for i in range(1, nsec): iparent = int(r.discunif(0, i - 1)) x = 0.5 if iparent == 0 else 1.0 self.secs[i].connect(self.secs[iparent](x)) # uniform L and diam but somewhat random passive g and e for i, sec in enumerate(self.secs): sec.L = 10 if i > 0 else 5 sec.diam = 1 if i > 0 else 5 sec.insert("pas") sec.g_pas = 0.0001 * r.uniform(1.0, 1.1) sec.e_pas = -65 * r.uniform(1.0, 1.1) # IClamp and ExpSyn at every location (even duplicates) with random # parameters (would rather use a Shunt, but ...) self.ics = [] self.syns = [] self.netcons = [] self.netstim = h.NetStim() self.netstim.number = 1 self.netstim.start = 0.0 for sec in self.secs: for seg in sec.allseg(): ic = h.IClamp(seg) ic.delay = 0.1 ic.dur = 1.0 ic.amp = 0.001 * r.uniform(1.0, 1.1) self.ics.append(ic) syn = h.ExpSyn(seg) syn.e = -65 * r.uniform(1.0, 1.1) syn.tau = r.uniform(0.1, 1.0) self.syns.append(syn) nc = h.NetCon(self.netstim, syn) nc.delay = 0.2 nc.weight[0] = 0.001 * r.uniform(1.0, 1.1) self.netcons.append(nc)
def synapses(self): ''' Adds synapses ''' for i in range(10): for sec in self.dend: s = h.ExpSyn(sec(0.5)) # Excitatory s.tau = 0.1 s.e = 50 self.synlistex.append(s) s = h.ExpSyn(sec(0.5)) # Inhibitory s.tau = 0.5 s.e = -80 self.synlistinh.append(s) s = h.ExpSyn(self.soma(0.1)) # Excitatory s.tau = 0.35 s.e = 50 self.synlistex.append(s) s = h.Exp2Syn(self.soma(0.5)) # Inhibitory s.tau1 = 0.5 s.tau2 = 3.5 s.e = -80 self.synlistinh.append(s)
def makeStimulus( Neurons, simTime, stimInterval ): interval = stimInterval stimNc = h.NetStim() stimNc.noise = 1 stimNc.start = 0 stimNc.number = simTime/interval stimNc.interval = interval syn = h.ExpSyn (0.5, sec = Neurons.soma[0]) nc = h.NetCon(stimNc, syn) nc.weight[0] = 1 #For recording events... tvec = h.Vector() #time idvec = h.Vector() #cell number nc.record(tvec, idvec) return (stimNc, syn, nc, tvec, idvec)
def makeStimulus(soma, simTime): interval = 50 stimNc = h.NetStim() stimNc.noise = 1 stimNc.start = 0 stimNc.number = simTime stimNc.interval = interval syn = h.ExpSyn(0.5, sec=soma) nc = h.NetCon(stimNc, syn) nc.weight[0] = 100 #For recording events... tvec = h.Vector() #time idvec = h.Vector() #cell number nc.record(tvec, idvec) return (stimNc, syn, nc, tvec, idvec)
def __init__(self, n): self.ncell = [1, n, 1] self.nlayer = len(self.ncell) self.cells = {} # make cells for ilayer in range(self.nlayer): for icell in range(self.ncell[ilayer]): gid = self.info2gid(ilayer, icell) if (gid % pc.nhost()) == pc.id(): cell = BallAndStick(gid, float(icell), float(ilayer), 0.0, 0.0) self.cells[gid] = cell cell.ilayer = ilayer cell.icell = icell pc.set_gid2node(gid, pc.id()) pc.cell(gid, self.cells[gid]._spike_detector) # make connections (all to all from layer i-1 to layer i) self.nclist = {} for gid, cell in self.cells.items(): if cell.ilayer > 0: src_ilayer = cell.ilayer - 1 for src_icell in range(self.ncell[src_ilayer]): srcgid = self.info2gid(src_ilayer, src_icell) nc = pc.gid_connect(srcgid, cell.syn) nc.weight[0] = 0.01 nc.delay = 20 self.nclist[(srcgid, gid)] = nc # stimulate gid 0 with NetStim if 0 in self.cells: self.ns = h.NetStim() self.ncstim = h.NetCon(self.ns, self.cells[0].syn) ns = self.ns ns.start = 6 ns.interval = 10 ns.number = 100 nc = self.ncstim nc.delay = 2 nc.weight[0] = 0.01 # For some extra coverage of BBSaveState::node01 if 100 in self.cells: cell = self.cells[100] self.xsyns = [h.ExpSyn(seg) for seg in cell.dend.allseg()] self.xnc = [] for syn in self.xsyns: nc = pc.gid_connect(0, syn) nc.delay = 20 nc.weight[0] = 0.0001 self.xnc.append(nc)
def add_ExpSyn(self, section='soma', position=0.5, name='default', tstim=[50], w=.001): """ Create/replace an Expsyn synapse on a given section which is active at the time in tstim Comments -------- The sort command is here to make sure that tstim are in the right order. This method requires the pre-compiling of vecstim.mod by NEURON. """ self.syn[name] = h.ExpSyn(self.cell.__getattribute__(section)(position)) self.stim[name] = h.Vector(np.sort(tstim)) # Converting tstim into a NEURON vector (to play in NEURON) self.vplay[name] = h.VecStim() # Creating play vectors to interface with NEURON self.vplay[name].play(self.stim[name]) # Connecting vector to VecStim object to play them self.netcon[name] = h.NetCon(self.vplay[name], self.syn[name]) # Building the netcon object to connect the stims and the synapses self.netcon[name].weight[0] = w # Setting the individual weights
def model(): pc.gid_clear() for s in h.allsec(): h.delete_section(sec=s) s = h.Section() s.L = 10 s.diam = 10 s.insert("hh") ic = h.IClamp(s(0.5)) ic.delay = 0.1 ic.dur = 0.1 ic.amp = 0.5 * 0 syn = h.ExpSyn(s(0.5)) nc = h.NetCon(None, syn) nc.weight[0] = 0.001 return {"s": s, "ic": ic, "syn": syn, "nc": nc}
def constructConnections2( connections, numNeurons, Neurons, inhibInd, delay, strength ): """ This definition will a connectivity matrix and make the appropriate CHEMICAL JUNCTIONS. """ SYN = [] NC = [] for i in range(0, numNeurons): count = 0 for j in range(0, numNeurons): if abs(float(connections[i][j])) > 0: syn = h.ExpSyn (0.5, sec = Neurons[j].soma[0]) #Target Neurons[i].soma[0].push() nc = h.NetCon( Neurons[i].soma[0](0.5)._ref_v, syn ) #Source w = float(connections[i][j]) mu, sigma = 1, 0.1 # mean and standard deviation #s = numpy.random.normal(mu, sigma, 1) #s = strength s1 = 20 s2 = 1 #Determine weight from particular type of connection if i < inhibInd: #This means the source is EXCITATORY if j < inhibInd: #E -> E #nc.weight[0] = s*w*0.5 nc.weight[0] = 0.05*s1 else: #E -> I #nc.weight[0] = s*w*0.1 nc.weight[0] = 0.2*s1 else: #This means the source is INHIBITORY if j < inhibInd: #I -> E #nc.weight[0] = -s*w*0.1 nc.weight[0] = -0.05*s2 else: #I -> I #nc.weight[0] = -s*w*0.5 nc.weight[0] = -0.1*s2 #nc.threshold = 1 #Determine delay from intersomatic distance if float(delay[i][j]) > 155: # Long range speed nc.delay = float(delay[i][j])/300 else: # Short range speed nc.delay = float(delay[i][j])/150 NC.append(nc) SYN.append(syn) return (SYN,NC)
def __init__(self, gid): s = {i: h.Section(name=i, cell=self) for i in ["soma", "dend", "axon"]} s["dend"].connect(s["soma"](0)) s["axon"].connect(s["soma"](1)) self.soma = s["soma"] a = s["axon"] self.sections = s for s in self.sections.values(): s.L = 10 s.diam = 10 if "soma" in s.name() else 1 s.insert("hh") self.syn = h.ExpSyn(self.sections["dend"](0.5)) self.syn.e = 0 self.gid = gid pc.set_gid2node(gid, pc.id()) pc.cell(gid, h.NetCon(a(1)._ref_v, None, sec=a))
def constructConnections2(connections, numNeurons, Neurons): """ This definition will a connectivity matrix and make the appropriate synaptic connections. """ SYN = [] NC = [] for i in range(0, numNeurons): count = 0 for j in range(0, numNeurons): if connections[i][j] == 1: syn = h.ExpSyn(0.5, sec=Neurons[j]) Neurons[i].push() nc = h.NetCon(Neurons[i](0.5)._ref_v, syn) nc.weight[0] = 1 SYN.append(syn) NC.append(nc) return (SYN, NC)
def constructConnections( connections, dendrites, numNeurons, Soma, Axon, Dendrites, strength ): """ This definition will a connectivity matrix and make the appropriate synaptic connections. """ SYN = [] NC = [] for i in range(0, numNeurons): count = 0 for j in range(0, numNeurons): if int(connections[i][j]) == 1: syn = h.ExpSyn (0.5, sec = Axon[j]) Dendrites[i][count].push() nc = h.NetCon( Dendrites[i][count](0.5)._ref_v, syn ) nc.weight[0] = strength SYN.append(syn) NC.append(nc) count = count + 1 return (SYN,NC)