def __init__(self,origin,delay=1,duration=5,initial_amplitude=38.0,distance=1000,pulses=1,frequency=1): from numpy import pi self.origin=h.secname(sec=origin) self.sec=h.Section(name=str(self)) self.sec.L=1000 self.sec.diam=200 # um # Aravanis: 200 um # Gradinaru: 400 um self.stim=h.ostim(0.5,sec=self.sec) self.delay=delay self.pulses=pulses self.frequency=frequency self.duration=duration self.amplitude=initial_amplitude h.setpointer(h._ref_source_irradiance_chanrhod, 'irradiance',self.stim) h.setpointer(h._ref_source_photons_chanrhod, 'photons',self.stim) h.setpointer(h._ref_source_flux_chanrhod, 'flux',self.stim) h.setpointer(h._ref_tstimon_chanrhod, 'tstimon',self.stim) h.setpointer(h._ref_tstimoff_chanrhod, 'tstimoff',self.stim) self.stim.radius=self.sec.diam/2.0 self.stim.pulses=self.pulses self.stim.isi = 1000 / self.frequency - self.duration #in ms self.stim.amp=initial_amplitude self.absorbance_coefficient = 0.1249 # (1/mm) # Range: (0.05233, 0.1975) self.scatter_coefficient = 7.37 # (1/mm) # Range: (6.679, 8.062) self.n = 1.36 # index of refraction of gray matter self.NA = 0.37 # numerical aperture of the optical fiber #self.NA = 0.48 self.set_distance(origin, distance)
def set_synapse(self, sec, x): """ Creates, sets and returns a synapse. Parameters ---------- sec : neuron.hoc.HocObject the section into which synapse will be inserted x : neuron.hoc.HocObject the synapse location at the section Returns ------- neuron.hoc.HocObject synapse """ syn = h.Exp2SynSTDP_multNNb_globBCM_intscount_precentred(sec(x)) syn.tau1 = self.setting['synapse']['SYN_TAU1'] syn.tau2 = self.setting['synapse']['SYN_TAU2'] syn.e = self.setting['synapse']['SYN_E'] syn.start = self.setting['synapse']['SYN_START'] syn.dtau = self.setting['synapse']['SYN_DTAU'] syn.ptau = self.setting['synapse']['SYN_PTAU'] h.setpointer(self.bcm._ref_d, 'd', syn) h.setpointer(self.bcm._ref_p, 'p', syn) return syn
def add_5HTreceptors(self, compartment, x, time, g): ''' Adds 5HT receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of serotonin application time: int (ms) time of serotonin application g: float receptor conductance ''' if self.fast_diff: diff = h.diff_5HT(compartment(0.5)) diff.h = math.sqrt((x-self.coordinates.get(compartment).get('x'))**2 + (0-self.coordinates.get(compartment).get('y'))**2 + (0.001-self.coordinates.get(compartment).get('z'))**2) diff.tx1 = time #diff.a = 1000 #diff.Deff = 0.0004 #diff.c0cleft = 2 else: diff = h.slow_5HT(compartment(0.5)) diff.h = math.sqrt((x-self.coordinates.get(compartment).get('x'))**2 + (0-self.coordinates.get(compartment).get('y'))**2 + (0.001-self.coordinates.get(compartment).get('z'))**2) diff.tx1 = time + 0 + (diff.h/1250)*1000 diff.c0cleft = 100 rec = h.r5ht3a(compartment(0.5)) rec.gmax = g h.setpointer(diff._ref_serotonin, 'serotonin', rec) self.diffs.append(diff) self.recs.append(rec)
def synapse(sender, receiver, synloc, e=0): #Function: synapse #Input: presynaptic neuron class, postsynaptic neuron class #Process: connect neurons #Output: synapse of neurons sdistances = [] rdistances = [] for sd in sender.dendgraph.keys(): sdistances.append( [sd, distance.euclidean(sender.dendgraph[sd], synloc)]) for rd in receiver.dendgraph.keys(): rdistances.append( [rd, distance.euclidean(receiver.dendgraph[rd], synloc)]) sdistances = numpy.array(sdistances) rdistances = numpy.array(rdistances) senderdend = sdistances[numpy.argmin(sdistances[:, 1])][0] receiverdend = rdistances[numpy.argmin(rdistances[:, 1])][0] syn = h.AlphaConvol(0.5, sec=receiver.compartmentdict[receiverdend][1]) syn.e = e if syn.e == -80: syn.k = 2.81e-4 h.setpointer(sender.compartmentdict[senderdend][1](0.5)._ref_v, 'Vpre', syn) return syn
def test_max_open_probability(): reset( raiseError=False ) # reset() fails as unable to remove all neuron objects, unless we ignore the error sec = h.Section() # Create AMPA and NMDA mechanisms # AMPA uses mode=0; no rectification apsd = h.AMPATRUSSELL(0.5, sec=sec) # For NMDA we will hold the cell at +40 mV npsd = h.NMDA_Kampa(0.5, sec=sec) # And a presynaptic terminal to provide XMTR input term = h.MultiSiteSynapse(0.5, sec=sec) term.nZones = 1 h.setpointer(term._ref_XMTR[0], 'XMTR', apsd) h.setpointer(term._ref_XMTR[0], 'XMTR', npsd) h.celsius = 34.0 h.finitialize() op = [[], []] for i in range(100): # force very high transmitter concentration for every timestep term.XMTR[0] = 10000 sec.v = 40.0 h.fadvance() op[0].append(apsd.Open) op[1].append(npsd.Open) assert np.allclose(max(op[0]), apsd.MaxOpen) assert np.allclose(max(op[1]), npsd.MaxOpen)
def create_ggn_kc_conn(fd, kc_name_sec_dict, ggn_name_sec_dict, path=ggn_kc_syn_path, config=None): """Create graded synapses from GGN sections to KC based on synaptic connection data in fd at path `ggn_kc_syn_path`.""" global model_dict cfg.logger.info('Started GGN->KC connection') model_dict['ggn_kc_conn'] = [] syn_dict = {} syn_data = fd[path] if len(syn_data.shape) == 2: syn_data = syn_data[:, 0] for row in syn_data: kc = kc_name_sec_dict[row['post']] syn = h.GradedSyn(kc(row['postpos'])) syn.vmid = row['vmid'] syn.vslope = row['vslope'] syn.e = row['e'] syn.gbar = row['gbar'] syn.tau = row['tau'] h.setpointer(ggn_name_sec_dict[row['pre']](row['prepos'])._ref_v, 'vpre', syn) model_dict['ggn_kc_conn'].append({'pre': row['pre'], 'prepos': row['prepos'], 'post': row['post'], 'postpos': row['postpos'], 'vmid': syn.vmid, 'vslope': syn.vslope, 'e': syn.e, 'gbar': syn.gbar, 'tau': syn.tau}) syn_dict[row['post']] = syn model_dict['ggn_kc_syn'] = syn_dict cfg.logger.info('Finished GGN->KC connection') return syn_dict
def add_cpampars(self, locations, section_name, release_time, gmax=500, pconc=100): for section in self.dendrites: if section.name() == section_name: self.dendrite = section #print 'adding synapses to', self.dendrite.name() pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 1.0 pre.del_rel = release_time self.pre_cpampa_list.append(pre) for loc in locations: cpampa = h.cpampa12st(loc, sec=self.dendrite) cpampa.pconc = pconc cpampa.gmax = gmax h.setpointer(pre(0.5).rel._ref_T, 'C', cpampa) self.cpampa_list.append(cpampa)
def make_gradedsyn_one_one(presec, prepos, postsec, postpos, syn_params): """Make identical synapses between lists of sections and positions. presec: list of presynaptic sections. prepos: list of positions in presynaptic sections. postsec: list of postsynaptic sections. postpos: list of postsynaptic positions. syn_params: properties of the synapse. A dict containing the attributes for the synapse. Returns dict containing `synapses` - a list of synapses, `adjacency` a list of tuple (name of presynaptic section, presynaptic position, name of postsynaptic section, postsynaptic position) """ adjacency = [] synapses = [] for presec_, prepos_, postsec_, postpos_ in zip(presec, prepos, postsec, postpos): syn = h.GradedSyn(postsec_(postpos_)) for attr, val in syn_params.items(): setattr(syn, attr, val) h.setpointer(presec_(prepos_)._ref_v, 'vpre', syn) synapses.append(syn) adjacency.append((presec_.name(), prepos_, postsec_.name(), postpos_)) return {'synapses': synapses, 'adjacency': adjacency}
def add_P2X3receptors(self, compartment, x, time, g): ''' Adds P2X3 receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of ATP application time: int (ms) time of ATP application g: float receptor conductance ''' if self.fast_diff: diff = h.AtP_4(compartment(0.5)) diff.h = math.sqrt((x-self.coordinates.get(compartment).get('x'))**2 + (0-self.coordinates.get(compartment).get('y'))**2 + (0.001-self.coordinates.get(compartment).get('z'))**2) diff.tx1 = time diff.Deff = 0.8 diff.c0cleft = 10 #diff.k = 1 else: diff = h.AtP_slow(compartment(0.5)) diff.h = math.sqrt((x-self.coordinates.get(compartment).get('x'))**2 + (0-self.coordinates.get(compartment).get('y'))**2 + (0.001-self.coordinates.get(compartment).get('z'))**2) diff.tx1 = time + 0 + (diff.h/1250)*1000 diff.c0cleft = 100 rec = h.p2x3(compartment(0.5)) rec.gmax = g rec.Ev = 5 h.setpointer(diff._ref_atp, 'patp', rec) self.diffs.append(diff) self.recs.append(rec)
def add_5HTreceptors(self, compartment, time, g): ''' Adds 5HT receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of serotonin application time: int (ms) time of serotonin application g: float receptor conductance ''' if self.fast_diff: diff = h.diff_5HT(compartment(0.5)) diff.h = self.distances.get(compartment) diff.tx1 = time if self.numofmodel == 14: diff.a = 100 else: diff.a = 0 diff.Deff = 0.004 diff.c0cleft = 3 else: diff = h.slow_5HT(compartment(0.5)) diff.h = self.distances.get(compartment) diff.tx1 = time + 0 + (diff.h/50)*1000 diff.c0cleft = 3 rec = h.r5ht3a(compartment(0.5)) rec.gmax = g h.setpointer(diff._ref_serotonin, 'serotonin', rec) self.diffs.append(diff) self.recs.append(rec)
def get_synapse_iv(self, synpase_type='ampa', p_conc=0, ampa_gmax=5000, nmda_gmax=5000, t_rel=40.0, vc_range=np.arange(-90.0, 50.0, 5.0), nmda_mech='h.NMDA_Mg_T', vshift=None): ''' Method for generating large IV curves... Not sure if best, use synapse __ref__i ''' self.clamp = h.SEClamp(0.5, sec=self.root) self.clamp.dur1 = 10 self.clamp.dur2 = 60 self.clamp.dur3 = 10 self.clamp.amp1 = -70 self.clamp.amp2 = -70 self.clamp.amp3 = -70 self.clamp.rs = 0.0001 pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 3.0 pre.del_rel = t_rel if synpase_type.lower() == 'ampa': print('running simulation of AMPAR IV with', p_conc, 'µM polyamines') cpampa = h.cpampa12st(0.5, sec=self.root) cpampa.pconc = p_conc cpampa.gmax = ampa_gmax h.setpointer(pre(0.5).rel._ref_T, 'C', cpampa) if synpase_type.lower() == 'nmda': print('running simulation of NMDA IV') nmda = eval(nmda_mech + '(0.5,sec=self.root)') print('inserted: ' + nmda_mech + '(0.5,sec=self.root)') #nmda = h.NMDA_Mg_T(0.5,sec=self.root) if vshift: print('vshift: ' + str(vshift)) nmda.vshift = vshift nmda.gmax = nmda_gmax h.setpointer(pre(0.5).rel._ref_T, 'C', nmda) v, i, t = self.run_vclamp(vc_range, tstop=80) i_list, v_list = self.calc_iv_relationship(v, i, t) return i_list, v_list,
def add_P2Xreceptors(self, compartment, time, g): ''' Adds P2X3 receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of ATP application time: int (ms) time of ATP application g: float receptor conductance ''' if self.fast_diff: diff = h.AtP_42(compartment(0.5)) diff.h = self.distances.get(compartment) diff.tx1 = time diff.Deff = 0.8 if self.numofmodel == 4 or self.numofmodel == 5: diff.c0cleft = 10 else: diff.c0cleft = 1 if self.numofmodel == 1: diff.k = 0 elif self.numofmodel == 3: diff.k = 0.6 else: diff.k = 0.01 else: diff = h.AtP_slow(compartment(0.5)) diff.h = self.distances.get(compartment) diff.tx1 = time + 0 + (diff.h / 1250) * 1000 diff.c0cleft = 100 self.diffusions.update({diff: compartment}) rec = h.p2x3(compartment(0.5)) rec.gmax = g rec.Ev = 5 if self.numofmodel == 4 or self.numofmodel == 5: rec2 = h.p2x2(compartment(0.5)) rec2.Ev = -7 rec2.gmax = 1 h.setpointer(diff._ref_atp, 'patp', rec2) self.recs.append(rec2) if self.numofmodel == 4: rec.gmax = 0 if self.numofmodel == 5: rec.gmax = 0.2 rec2.gmax = 0.2 h.setpointer(diff._ref_atp, 'patp', rec) self.recs.append(rec) self.diffs.append(diff)
def synapse(sender,receiver,e=0): #Function: synapse #Input: presynaptic and postsynaptic neuron classes #Process: create synapse #Output: synapse syn = h.AlphaConvol(0.5, sec=receiver.soma) syn.e = e if syn.e == -80: syn.k = 2.81e-4 h.setpointer(sender.soma(0.5)._ref_v,'Vpre', syn) return syn
def constructConnections1(connections, numNeurons, Neurons): """ This definition will a connectivity matrix and make the appropriate synaptic connections. """ gaps = [] for i in range(0, numNeurons): count = 0 for j in range(0, numNeurons): if abs(float(connections[i][j])) > 0: gap_junction = h.gapc(1, sec=Neurons[i]) gap_junction.g = float(connections[i][j]) / 100 h.setpointer(Neurons[j](1)._ref_v, 'vgap', gap_junction) gaps.append(gap_junction) return gaps
def constructConnections1( connections, numNeurons, Neurons ): """ This definition will a connectivity matrix and make the appropriate GAP JUNCTIONS. """ gaps = [] for i in range(0, numNeurons): count = 0 for j in range(0, numNeurons): if abs(float(connections[i][j])) > 0: gap_junction = h.gapc(1, sec=Neurons[i].soma[0]) gap_junction.g = 0.000000001*float(connections[i][j]) h.setpointer(Neurons[j].soma[0](1)._ref_v, 'vgap', gap_junction) gaps.append(gap_junction) return gaps
def constructConnections1( connections, dendrites, numNeurons, Soma, Axon, Dendrites, strength ): """ This definition will a connectivity matrix and make the appropriate synaptic connections. """ gaps = [] for i in range(0, numNeurons): count = 0 for j in range(0, numNeurons): if int(connections[i][j]) == 1: gap_junction = h.gapc(1, sec=Dendrites[i][count]) gap_junction.g = strength h.setpointer(Axon[j](1)._ref_v, 'vgap', gap_junction) gaps.append(gap_junction) return gaps
def add_cpampa(self, pconc=100, gmax=1000, release_time=50): syn = h.cpampa12st(0.5, sec=self.soma) syn.pconc = pconc syn.gmax = gmax pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 2.0 pre.del_rel = release_time h.setpointer(pre(0.5).rel._ref_T, 'C', syn) self.syn = syn self.pre = pre
def addNMDASynapse(self, loc, g_max, e_rev, c_mg, dur_rel, amp_rel): loc = MorphLoc(loc, self) # create the synapse syn = h.NMDA_Mg_T(self.sections[loc['node']](loc['x'])) syn.gmax = g_max syn.Erev = e_rev syn.mg = c_mg # create the presynaptic segment for release pre = h.Section(name='pre %d' % len(self.pres)) pre.insert('release_BMK') pre(0.5).release_BMK.dur = dur_rel pre(0.5).release_BMK.amp = amp_rel # connect h.setpointer(pre(0.5).release_BMK._ref_T, 'C', syn) # store the synapse self.nmdas.append(syn) self.pres.append(pre)
def get_iv(self, synpase_type='ampa', p_conc=0, ampa_gmax=5000, nmda_gmax=5000, t_rel=40.0): self.clamp = h.SEClamp(0.5, sec=self.root) self.clamp.dur1 = 10 self.clamp.dur2 = 60 self.clamp.dur3 = 10 self.clamp.amp1 = -70 self.clamp.amp2 = -70 self.clamp.amp3 = -70 self.clamp.rs = 0.0001 pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 3.0 pre.del_rel = t_rel if synpase_type.lower() == 'ampa': print('running simulation of AMPAR IV with', p_conc, 'µM polyamines') cpampa = h.cpampa12st(0.5, sec=self.root) cpampa.pconc = p_conc cpampa.gmax = ampa_gmax h.setpointer(pre(0.5).rel._ref_T, 'C', cpampa) if synpase_type.lower() == 'nmda': print('running simulation of NMDA IV') nmda = h.NMDA_Mg_T(0.5, sec=self.root) nmda.gmax = nmda_gmax h.setpointer(pre(0.5).rel._ref_T, 'C', nmda) vc_range = np.arange(-90.0, 50.0, 10.0) v, i, t = self.run_vclamp(vc_range, tstop=80) i_list, v_list = self.calc_iv_relationship(v, i, t) return i_list, v_list
def initialize_network(N_cells): cells = [] gap_junctions_f=[] gap_junctions_b=[] for i in range(N_cells): cells.append(h.Section()) define_geometry(cells[i]) # cells[i].insert('pas') insert_mechanisms(cells[i]) for i in range(N_cells-1): gap_junctions_f.append(h.gap()) gap_junctions_b.append(h.gap()) gap_junctions_f[i].loc(cells[i](1)) gap_junctions_b[i].loc(cells[i+1](0)) h.setpointer(cells[i+1](0)._ref_v,'vgap',gap_junctions_f[i]) h.setpointer(cells[i](1)._ref_v,'vgap',gap_junctions_b[i]) return gap_junctions_f,gap_junctions_b, cells
def _addConnPlasticity (self, params, sec, netcon, weightIndex): plasticity = params.get('plast') if plasticity and sim.cfg.createNEURONObj: try: plastMech = getattr(h, plasticity['mech'], None)(0, sec=sec['hSec']) # create plasticity mechanism (eg. h.STDP) for plastParamName,plastParamValue in plasticity['params'].iteritems(): # add params of the plasticity mechanism setattr(plastMech, plastParamName, plastParamValue) if plasticity['mech'] == 'STDP': # specific implementation steps required for the STDP mech precon = sim.pc.gid_connect(params['preGid'], plastMech); precon.weight[0] = 1 # Send presynaptic spikes to the STDP adjuster pstcon = sim.pc.gid_connect(self.gid, plastMech); pstcon.weight[0] = -1 # Send postsynaptic spikes to the STDP adjuster h.setpointer(netcon._ref_weight[weightIndex], 'synweight', plastMech) # Associate the STDP adjuster with this weight #self.conns[-1]['hPlastSection'] = plastSection self.conns[-1]['hSTDP'] = plastMech self.conns[-1]['hSTDPprecon'] = precon self.conns[-1]['hSTDPpstcon'] = pstcon self.conns[-1]['STDPdata'] = {'preGid':params['preGid'], 'postGid': self.gid, 'receptor': weightIndex} # Not used; FYI only; store here just so it's all in one place if sim.cfg.verbose: print(' Added STDP plasticity to synaptic mechanism') except: print 'Error: exception when adding plasticity using %s mechanism' % (plasticity['mech'])
def load_gabaergic_data(synM, amac, dendseg): # Load gabaergic data gabasyn = [] n_gsyn = len(synM) # Gabaergic synaptic inputs print n_gsyn, "Gabaergic synaptic inputs" # Parameters for GABA synapsis # Lateral inhibition???? for row in range(n_gsyn): cell1, cell2, dend1, dend2, seg1, seg2, olap = synM[row].astype(int) olap = float(olap) gabasyn.append( h.GABAsyn((seg2 + 0.5) / dendseg, sec=amac[cell2].dend[dend2])) # gabasyn[row].minG = gabaGmin*olap / 5000 # gabasyn[row].maxG = gabaGmax*olap / 5000 h.setpointer(amac[cell1].dend[dend1]((seg1 + 0.5) / dendseg)._ref_v, 'vpre', gabasyn[row]) print "Gabaergic synaptic inputs created" return gabasyn, amac
def __init__(self, section, terminal, ampa_gmax, nmda_gmax, gvar=0, eRev=0, ampa_params=None, loc=0.5): PSD.__init__(self, section, terminal) # print('\033[0;33;40m ^^^^^ GVAR = %.4f ^^^^^\033[0;37;40m ' % gvar) ampa_params = {} if ampa_params is None else ampa_params # and then make a set of postsynaptic receptor mechanisms ampa_psd = [] nmda_psd = [] relsite = terminal.relsite self.section.push() for i in range(0, terminal.n_rzones): # create mechanisms ampa = h.AMPATRUSSELL(loc, self.section) # raman/trussell AMPA with rectification nmda = h.NMDA_Kampa(loc, self.section) # Kampa state model NMDA receptors # Connect terminal to psd h.setpointer(relsite._ref_XMTR[i], 'XMTR', ampa) h.setpointer(relsite._ref_XMTR[i], 'XMTR', nmda) # Set any extra ampa parameters provided by the caller # (Ro1, Ro2, Rc1, Rc2, PA, ...) for k,v in ampa_params.items(): setattr(ampa, k, v) # add a little variability - gvar is CV of amplitudes v = 1.0 + gvar * np.random.standard_normal() # set gmax and eRev for each postsynaptic receptor mechanism ampa.gmax = ampa_gmax * v ampa.Erev = eRev nmda.gmax = nmda_gmax * v nmda.Erev = eRev nmda.vshift = 0 ampa_psd.append(ampa) nmda_psd.append(nmda) h.pop_section() self.ampa_psd = ampa_psd self.nmda_psd = nmda_psd self.all_psd = nmda_psd + ampa_psd
def get_nmda_ampa_ratio(self, p_conc, ampa_gmax, nmda_gmax, t_rel=40.0, vc_range=[-60, 60]): self.clamp = h.SEClamp(0.5, sec=self.root) self.clamp.dur1 = 10 self.clamp.dur2 = 150 self.clamp.dur3 = 10 self.clamp.amp1 = -70 self.clamp.amp2 = -70 self.clamp.amp3 = -70 self.clamp.rs = 0.0001 pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 3.0 pre.del_rel = t_rel syn_list = [] locs = np.linspace(0, 1, 35) for l in locs: cpampa = h.cpampa12st(l, sec=self.root) cpampa.pconc = p_conc cpampa.gmax = ampa_gmax h.setpointer(pre(0.5).rel._ref_T, 'C', cpampa) nmda = h.NMDA_Mg_T(l, sec=self.root) nmda.gmax = nmda_gmax h.setpointer(pre(0.5).rel._ref_T, 'C', nmda) syn_list.append((nmda, cpampa)) v, i, t = self.run_vclamp(vc_range, tstop=170) return v, i, t
def add_5HTreceptors(self, compartment, time, g): ''' Adds 5HT receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of serotonin application time: int (ms) time of serotonin application g: float receptor conductance ''' x = [8300, 13485, 13485] y = [0, 1800, -1800] z = [0, 0, 0] if self.fast_diff: for i in range(len(x)): diff = h.diff_5HT(compartment(0.5)) diff.h = self.distance(compartment, x[i], y[i], z[i]) print(compartment) print(diff.h) diff.tx1 = time + i * self.dt diff.a = 0.25 diff.Deff = 0.4 diff.c0cleft = 2 rec = h.r5ht3a(compartment(0.5)) rec.gmax = g h.setpointer(diff._ref_serotonin, 'serotonin', rec) self.recs.append(rec) self.diffs.append(diff) else: diff = h.slow_5HT(compartment(0.5)) diff.h = self.distance(compartment, x[0], y[0], z[0]) diff.tx1 = time + 0 + (diff.h / 50) * 10 #00 diff.c0cleft = 3 rec = h.r5ht3a(compartment(0.5)) rec.gmax = g h.setpointer(diff._ref_serotonin, 'serotonin', rec) self.diffs.append(diff) self.recs.append(rec)
def conn_specif_cells(self, sec1, sec2, ind1, ind2, gap_res, flag): "electrically connects sec1 and sec2 reciprocally with weight" dist = self.distances[ind1][ind2] dendLength = sec1.L minpos = dist / dendLength / 2.0 if flag: pos = numpy.random.uniform(minpos, 1) else: pos = minpos gapj1 = h.gap(pos, sec=sec1) gapj1.r = gap_res gapj2 = h.gap(pos, sec=sec2) gapj2.r = gap_res h.setpointer(sec2(pos)._ref_v, 'vgap', gapj1) h.setpointer(sec1(pos)._ref_v, 'vgap', gapj2) self.gaplist.append(gapj1) self.gaplist.append(gapj2)
def update_imemb_ptrs(self): """ Callback function for when i_membrane range variables have changed. Re-establish pointers to each compartment's transmembrane current. """ i_seg = 0 for seclist in self.tracked_seclists: for sec in seclist: for seg in sec: if self.use_fast_imem: h.setpointer(seg._ref_i_membrane_, 'temp_ptr', self.summator) else: h.setpointer(seg._ref_i_membrane, 'temp_ptr', self.summator) self.summator.update_imemb_ptr(i_seg) i_seg += 1 print("Updated i_memb pointers for sectionlist {}". format(seclist))
def create_halfgaps(self, conduct_range): self.gaps = [0, 0] (pre_soma_dx, pre_axon_dx) = self.pre.give_dxs() (post_soma_dx, post_axon_dx) = self.post.give_dxs() # Create HalfGap Objects self.gaps[0] = h.HalfGap(self.pre.axon(1 - (pre_axon_dx / 2))) self.gaps[1] = h.HalfGap(self.post.soma(0 + (post_soma_dx / 2))) # Identify cathode vs anode self.gaps[0].isanode = 1 self.gaps[1].isanode = -1 # Set voltage pointers h.setpointer( self.post.soma(0 + (post_soma_dx) / 2)._ref_v, 'vgap', self.gaps[0]) h.setpointer( self.pre.axon(1 - (pre_axon_dx) / 2)._ref_v, 'vgap', self.gaps[1]) # Set conductance min and max self.gaps[0].gmin = conduct_range[0] self.gaps[1].gmin = conduct_range[0] self.gaps[0].gmax = conduct_range[1] self.gaps[1].gmax = conduct_range[1]
def add_glu_receptors(compartment, pre, g1, g2): ''' Adds 5HT receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of serotonin application time: int (ms) time of serotonin application g: float receptor conductance ''' recs =[] diffs = [] diff = h.GrC_Gludif3(pre(0.5)) h.setpointer(pre(0.5)._ref_v, 'affv', diff) diffs.append(diff) for sec in compartment: rec = h.ampa_rec(sec(0.5)) rec.gmax=g1 h.setpointer(diff._ref_glu, 'glu_m', rec) # vc = h.IClamp(0.5, sec=cell.axon1.node[5]) recs.append(rec) rec2 = h.nmda_rec(sec(0.5)) rec2.gmax=g2 h.setpointer(diff._ref_glu, 'glu_m', rec2) # vc = h.IClamp(0.5, sec=cell.axon1.node[5]) recs.append(rec2)
def _addConnPlasticity(self, params, sec, netcon, weightIndex): from .. import sim plasticity = params.get('plast') if plasticity and sim.cfg.createNEURONObj: try: plastMech = getattr(h, plasticity['mech'], None)( 0, sec=sec['hObj'] ) # create plasticity mechanism (eg. h.STDP) for plastParamName, plastParamValue in plasticity[ 'params'].items( ): # add params of the plasticity mechanism setattr(plastMech, plastParamName, plastParamValue) if plasticity[ 'mech'] == 'STDP': # specific implementation steps required for the STDP mech precon = sim.pc.gid_connect(params['preGid'], plastMech) precon.weight[ 0] = 1 # Send presynaptic spikes to the STDP adjuster pstcon = sim.pc.gid_connect(self.gid, plastMech) pstcon.weight[ 0] = -1 # Send postsynaptic spikes to the STDP adjuster h.setpointer( netcon._ref_weight[weightIndex], 'synweight', plastMech ) # Associate the STDP adjuster with this weight #self.conns[-1]['hPlastSection'] = plastSection self.conns[-1]['hSTDP'] = plastMech self.conns[-1]['hSTDPprecon'] = precon self.conns[-1]['hSTDPpstcon'] = pstcon self.conns[-1]['STDPdata'] = { 'preGid': params['preGid'], 'postGid': self.gid, 'receptor': weightIndex } # Not used; FYI only; store here just so it's all in one place if sim.cfg.verbose: print(' Added STDP plasticity to synaptic mechanism') except: print( 'Error: exception when adding plasticity using %s mechanism' % (plasticity['mech']))
def add_cpampars(self, locations, dendrite_strings, gmax=500, release_times=[20], pconc=100, NMDARs=False): self.cpampa_list = [] self.pre_cpampa_list = [] self.NMDARs_list = [] # find the dendrite of choice! for string in dendrite_strings: for sec in self.sec_list: if sec.name().find(string) >= 0: self.dendrite = sec for x, loc in enumerate(locations): pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 1.0 pre.del_rel = release_times[x] cpampa = h.cpampa12st(locations[x], sec=self.dendrite) cpampa.pconc = pconc cpampa.gmax = gmax if NMDARs: NMDA = h.NMDA_Mg_T(locations[x], sec=self.dendrite) NMDA.gmax = gmax h.setpointer(pre(0.5).rel._ref_T, 'C', NMDA) self.NMDARs_list.append(NMDA) h.setpointer(pre(0.5).rel._ref_T, 'C', cpampa) self.cpampa_list.append(cpampa) self.pre_cpampa_list.append(pre)
def add_cpampars_for_stim_electrodes(self, section_loc_list, release_time, stim_string, gmax=500, pconc=100): ''' Method adds across sections, expects a list of tuples containing (section(str), loc(float)). Stores the stims in a dictionary... ''' # should make this a method pre = h.Section() pre.diam = 1.0 pre.L = 1.0 pre.insert('rel') pre.dur_rel = 0.5 pre.amp_rel = 1.0 pre.del_rel = release_time self.pre_cpampa_list.append(pre) stim_syns = [] for sec_loc in section_loc_list: section_name = sec_loc[0] loc = sec_loc[1] #print 'adding at:', section_name, loc for section in self.dendrites: if section.name() == section_name: dendrite = section cpampa = h.cpampa12st(loc, sec=dendrite) cpampa.pconc = pconc cpampa.gmax = gmax h.setpointer(pre(0.5).rel._ref_T, 'C', cpampa) stim_syns.append(cpampa) self.cpampa_stim_dict[stim_string] = stim_syns # hacky just go with last dendrite for recording - change this! self.dendrite = dendrite
def add_5HTreceptors(self, compartment, time, g): ''' Adds 5HT receptors Parameters ---------- compartment: section of NEURON cell part of neuron x: int x - coordinate of serotonin application time: int (ms) time of serotonin application g: float receptor conductance ''' diff = h.slow_5HT(compartment(0.5)) diff.h = random.uniform(10, 2500) diff.tx1 = time + 0 + (diff.h / 50) * 10 #00 diff.c0cleft = 3 diff.a = 0.1 rec = h.r5ht3a(compartment(0.5)) rec.gmax = g h.setpointer(diff._ref_serotonin, 'serotonin', rec) self.diffs.append(diff) self.recs.append(rec)
from neuron import h h("create a, b") for sec in h.allsec(): sec.nseg = 10 sec.insert('t2') for seg in h.a: seg.t2.r = 10 + seg.x*9 h.b(seg.x).t2.r = 40 + seg.x*9 h.setpointer(h.b(seg.x)._ref_r_t2, 'p', seg.t2) h.setpointer(seg._ref_r_t2, 'p', h.b(seg.x).t2) def pr(sec): sec.push() for seg in sec: print '%s x=%g r=%g t2.p=%g p_t2=%g' % (sec.name(), seg.x, seg.t2.r, seg.t2.p, seg.p_t2), h.setdata_t2(seg.x) print ' f()=%g\n' % (h.f_t2()), print('\n') h.pop_section() pr(h.a) pr(h.b)
from neuron import h a = h.Section() vec = h.Vector(10).indgen().add(100) tp = [] for i in range(0, 10): tp.append(h.t1(.5, sec=a)) a.v = 10 tp[2].f1() h.setpointer(a(.5)._ref_v, 'p1', tp[0]) for i in range(1, 10): h.setpointer(vec._ref_x[i], 'p1', tp[i]) for i in range(0, 10): print i, tp[i].p1, tp[i].f1() tp[2].p1 = 25 print vec[2], tp[2].p1
def addConn(self, params): if params['preGid'] == self.gid: print 'Error: attempted to create self-connection on cell gid=%d, section=%s '%(self.gid, params['sec']) return # if self-connection return if not params['sec'] or not params['sec'] in self.secs: # if no section specified or section specified doesnt exist if 'soma' in self.secs: params['sec'] = 'soma' # use 'soma' if exists elif self.secs: params['sec'] = self.secs.keys()[0] # if no 'soma', use first sectiona available for secName, secParams in self.secs.iteritems(): # replace with first section that includes synapse if 'syns' in secParams: if secParams['syns']: params['sec'] = secName break else: print 'Error: no Section available on cell gid=%d to add connection'%(self.gid) return # if no Sections available print error and exit sec = self.secs[params['sec']] weightIndex = 0 # set default weight matrix index pointp = None if 'pointps' in self.secs[params['sec']]: # check if point processes with '_vref' (artificial cell) for pointpName, pointpParams in self.secs[params['sec']]['pointps'].iteritems(): if '_vref' in pointpParams: # if includes vref param means doesn't use Section v or synapses pointp = pointpName if '_synList' in pointpParams: if params['syn'] in pointpParams['_synList']: weightIndex = pointpParams['_synList'].index(params['syn']) # udpate weight index based pointp synList if not pointp: # not a point process if 'syns' in sec: # section has synapses if params['syn']: # desired synapse specified in conn params if params['syn'] not in sec['syns']: # if exact name of desired synapse doesn't exist synIndex = [0] # by default use syn 0 synIndex.extend([i for i,syn in enumerate(sec['syns']) if params['syn'] in syn]) # check if contained in any of the synapse names params['syn'] = sec['syns'].keys()[synIndex[-1]] else: # if no synapse specified params['syn'] = sec['syns'].keys()[0] # use first synapse available in section else: # if still no synapse print 'Error: no Synapse or point process available on cell gid=%d, section=%s to add stim'%(self.gid, params['sec']) return # if no Synapse available print error and exit if not params['threshold']: params['threshold'] = 10.0 self.conns.append(params) if pointp: postTarget = sec['pointps'][pointp]['hPointp'] # local point neuron else: postTarget= sec['syns'][params['syn']]['hSyn'] # local synapse netcon = f.pc.gid_connect(params['preGid'], postTarget) # create Netcon between global gid and target netcon.weight[weightIndex] = f.net.params['scaleConnWeight']*params['weight'] # set Netcon weight netcon.delay = params['delay'] # set Netcon delay netcon.threshold = params['threshold'] # set Netcon delay self.conns[-1]['hNetcon'] = netcon # add netcon object to dict in conns list if f.cfg['verbose']: print('Created connection preGid=%d, postGid=%d, sec=%s, syn=%s, weight=%.4g, delay=%.1f'% (params['preGid'], self.gid, params['sec'], params['syn'], f.net.params['scaleConnWeight']*params['weight'], params['delay'])) plasticity = params.get('plasticity') if plasticity: # add plasticity try: plastSection = h.Section() plastMech = getattr(h, plasticity['mech'], None)(0, sec=plastSection) # create plasticity mechanism (eg. h.STDP) for plastParamName,plastParamValue in plasticity['params'].iteritems(): # add params of the plasticity mechanism setattr(plastMech, plastParamName, plastParamValue) if plasticity['mech'] == 'STDP': # specific implementation steps required for the STDP mech precon = f.pc.gid_connect(params['preGid'], plastMech); precon.weight[0] = 1 # Send presynaptic spikes to the STDP adjuster pstcon = f.pc.gid_connect(self.gid, plastMech); pstcon.weight[0] = -1 # Send postsynaptic spikes to the STDP adjuster h.setpointer(netcon._ref_weight[weightIndex], 'synweight', plastMech) # Associate the STDP adjuster with this weight self.conns[-1]['hPlastSection'] = plastSection self.conns[-1]['hSTDP'] = plastMech self.conns[-1]['hSTDPprecon'] = precon self.conns[-1]['hSTDPpstcon'] = pstcon self.conns[-1]['STDPdata'] = {'preGid':params['preGid'], 'postGid': self.gid, 'receptor': weightIndex} # Not used; FYI only; store here just so it's all in one place if f.cfg['verbose']: print(' Added STDP plasticity to synapse') except: print 'Error: exception when adding plasticity using %s mechanism' % (plasticity['mech'])