def __init__(self, x=0, y=0, z=0, ID=0, ty=0): Cell.__init__(self, x, y, z, ID, ty) self.soma.insert('k_ion') self.soma.insert('na_ion') self.soma.insert('ca_ion') # using an ohmic current rather than GHK equation h.ion_style("ca_ion", 0, 1, 0, 0, 0) self.soma.Ra = 100.0 self.soma.nseg = 1 self.soma.diam = 70.0 # one-compartment of 14260 um2 self.soma.L = 64.86 self.soma.insert('pas') # leak current self.soma.insert('hh2ad') # Hodgin-Huxley INa and IK -- HH2.mod self.soma.insert('itre') # reticular IT current -- IT2.mod self.soma.insert('kl') # K leak -- kl.mod self.soma.insert('cadad') # calcium decay self.soma.e_pas = -77 self.soma.g_pas = 5e-5 self.soma.ena = 50 self.soma.ek = -95 self.soma.gnabar_hh2ad = 90e-3 # 0.1 self.soma.vtraub_hh2ad = -50.0 # adjusts threshold self.soma.gkbar_hh2ad = 0.01 self.soma.gmax_itre = 2e-3 h.erev_kl = self.soma.ek self.soma.gmax_kl = 3e-6 h.q10h_itre = 3.0
def test_units(): s = h.Section() pp = h.UnitsTest(s(0.5)) h.ion_style("na_ion", 1, 2, 1, 1, 0, sec=s) h.finitialize(-65) R_std = pp.gasconst erev_std = pp.erev ghk_std = pp.ghk from neuron import coreneuron h.CVode().cache_efficient(1) coreneuron.enable = True coreneuron.gpu = bool( distutils.util.strtobool(os.environ.get("CORENRN_ENABLE_GPU", "false"))) pc.set_maxstep(10) h.finitialize(-65) pc.psolve(h.dt) assert R_std == pp.gasconst # mod2c needs nrnunits.lib.in assert abs(erev_std - pp.erev) <= (1e-13 if coreneuron.gpu else 0 ) # GPU has tiny numerical differences assert ghk_std == pp.ghk
def __init__(self, ID=0, ty=0, col=0, rho=165.0, kappa=10.0, soma_pas=False): self.ID = ID self.ty = ty self.col = col self.soma_pas = soma_pas self.soma = soma = h.Section(name='soma', cell=self) self.dend = dend = h.Section(name='dend', cell=self) self.dend.connect(self.soma, 0.5, 0) # connect dend(0), soma(0.5) self.rho = rho # dendritic to axo-somatic area ratio self.kappa = kappa # coupling resistance (Mohm) for sec in [self.soma, self.dend]: sec.insert('k_ion') sec.insert('na_ion') sec.insert('ca_ion') sec.ek = -90 # K+ current reversal potential (mV) sec.ena = 60 # Na+ current reversal potential (mV) sec.eca = 140 # Ca2+ current reversal potential (mV) h.ion_style("ca_ion", 0, 1, 0, 0, 0) # using an ohmic current rather than GHK equation sec.Ra = 100 self.initsoma() self.initdend()
def set_conductances(self): soma = self.soma Tfactor = 0.0002 Ttau = 0.0 Hfactor = 0.000001 Htau = 0.003 # kv.mod, na2_mh.mod, cal_mh.mod, kca.mod, cat_traub.mod, ar_traub.mod for ioc in ['pas', 'kv', 'na', 'ca', 'cadad', 'kca', 'catt', 'ar']: soma.insert(ioc) soma.taur_cadad = 20 soma.g_pas = .00007 soma.e_pas = -74 #soma.ek = -60 soma.ek = -90 + 10 soma.ena = 75 - 20 soma.vshift_na = -18 soma.eca = 140 # from original Mainen patdemo code h.ion_style("ca_ion", 0, 1, 0, 0, 0) # from original Mainen patdemo code soma.gbar_ar = Hfactor soma.gbar_na = 7000 * 0.5 soma.gmax_kv = 350 * 0.5 soma.gbar_ca = 30 * 0.5 soma.gmax_kca = 5 * 0.5 soma.gbar_catt = Tfactor
def _ion_register(self): charge = self._charge if self._name is not None: ion_type = h.ion_register(self._name, charge) if ion_type == -1: raise RxDException('Unable to register species: %s' % self._name) # insert the species if not already present regions = self._regions if hasattr(self._regions, '__len__') else [self._regions] for r in regions: if r.nrn_region in ('i', 'o'): for s in r.secs: try: ion_forms = [ self._name + 'i', self._name + 'o', 'i' + self._name, 'e' + self._name ] for i in ion_forms: # this throws an exception if one of the ion forms is missing temp = s.__getattribute__(self._name + 'i') except: s.insert(self._name + '_ion') # set to recalculate reversal potential automatically # the last 1 says to set based on global initial concentrations # e.g. nai0_na_ion, etc... h.ion_style(self._name + '_ion', 3, 2, 1, 1, 1, sec=s)
def define_biophysics(self): self.Rm_axosomatic = 15000 self.spinefactor = 2.0 self.decay_kfast = 50.0 self.decay_kslow = 50.0 self.soma.Ra = 82 self.basal.Ra = 734 self.tuft.Ra = 527 Ra_apical = 261 self.apical.Ra = Ra_apical self.hillock.Ra = self.soma.Ra self.axon.Ra = self.soma.Ra self.iseg.Ra = self.soma.Ra for sec in self.all: # 'all' defined in build_subsets sec.insert('pas') sec.cm = 1.0 sec.g_pas = 1./15000 sec.e_pas = -70 for sec in self.ih_list: sec.insert('ih') for seg in sec: seg.ehd_ih = -47 for sec in self.nat_list: sec.insert('nat') sec.ena = 55 sec.vshift_nat = 10 for sec in self.kfast_list: sec.insert('kfast') sec.ek = -80 for sec in self.kslow_list: sec.insert('kslow') sec.ek = -80 self.soma.insert('nap') self.soma.insert('km') self.tuft.insert('cad') self.tuft.insert('sca') self.tuft.insert('kca') self.tuft.eca = 140 h.ion_style("ca_ion",0,1,0,0,0) self.recalculate_passive_properties() self.recalculate_channel_densities()
def _ion_register(self): """modified from neuron.rxd.species.Species._ion_register""" ion_type = h.ion_register(self._species, self._charge) if ion_type == -1: raise RxDException('Unable to register species: %s' % self._species) # insert the species if not already present ion_forms = [self._species + 'i', self._species + 'o', 'i' + self._species, 'e' + self._species] for s in h.allsec(): try: for i in ion_forms: # this throws an exception if one of the ion forms is missing temp = s.__getattribute__(i) except: s.insert(self._species + '_ion') # set to recalculate reversal potential automatically # the last 1 says to set based on global initial concentrations # e.g. nao0_na_ion, etc... # TODO: this is happening GLOBALLY even to sections that aren't inside the extracellular domain (FIX THIS) h.ion_style(self._species + '_ion', 3, 2, 1, 1, 1, sec=s)
def initdend(self): dend = self.dend dend.nseg = 1 dend.diam = 10.0 / pi self.config() dend.cm = 0.75 dend.insert('naz') # naz.mod dend.insert('km') # km.mod dend.insert('kca') # kca.mod dend.insert('Nca') # Nca.mod dend.insert('cadad') # cadad.mod dend.insert('pas') dend.eca = 140 h.ion_style("ca_ion", 0, 1, 0, 0, 0) # already called before dend.e_pas = -70 # only dendrite has leak conductance - why? dend.g_pas = 1 / 3e4 # only dendrite has leak conductance dend.gmax_naz = 15 dend.gmax_Nca = 0.3 # high voltage-activated Ca^2+ dend.gmax_km = 0.1 # slow voltage-dependent non-inactivating K+ dend.gmax_kca = 3 # slow Ca^2+-activated K+
def test_units(): s = h.Section() pp = h.UnitsTest(s(.5)) h.ion_style("na_ion", 1, 2, 1, 1, 0, sec=s) h.finitialize(-65) R_std = pp.gasconst erev_std = pp.erev ghk_std = pp.ghk from neuron import coreneuron h.CVode().cache_efficient(1) coreneuron.enable = True pc.set_maxstep(10) h.finitialize(-65) pc.psolve(h.dt) assert (R_std == pp.gasconst) # mod2c needs nrnunits.lib.in assert (erev_std == pp.erev) assert (ghk_std == pp.ghk)
def _ion_register(self): charge = self._charge if self._name is not None: ion_type = h.ion_register(self._name, charge) if ion_type == -1: raise RxDException('Unable to register species: %s' % self._name) # insert the species if not already present regions = self._regions if hasattr(self._regions, '__len__') else [self._regions] for r in regions: if r.nrn_region in ('i', 'o'): for s in r.secs: try: ion_forms = [self._name + 'i', self._name + 'o', 'i' + self._name, 'e' + self._name] for i in ion_forms: # this throws an exception if one of the ion forms is missing temp = s.__getattribute__(self._name + 'i') except: s.insert(self._name + '_ion') # set to recalculate reversal potential automatically # the last 1 says to set based on global initial concentrations # e.g. nai0_na_ion, etc... h.ion_style(self._name + '_ion', 3, 2, 1, 1, 1, sec=s)
def test_mod_legacy(): s = h.Section() ut = h.UnitsTest(s(0.5)) h.ion_style("na_ion", 1, 2, 1, 1, 0, sec=s) switch_units(1) h.finitialize() names = ["mole", "e", "faraday", "planck", "hbar", "gasconst"] legacy_hex_values = [ "0x1.fe18fef60659ap+78", "0x1.7a4e7164efbbcp-63", "0x1.78e54cccccccdp+16", "0x1.b85f8c5445f02p-111", "0x1.18779454e3d48p-113", "0x1.0a10624dd2f1bp+3", ] for i, n in enumerate(names): val = eval("ut." + n) print("%s = %s (%s)" % (n, str(val.hex()), str(val))) legacy_value = float.fromhex(legacy_hex_values[i]) assert val == legacy_value assert ut.avogadro == float.fromhex(legacy_hex_values[0]) ghk_std = h.ghk(-50, 0.001, 10, 2) erev_std = h.nernst(s(0.5).nai, s(0.5).nao, 1) assert ut.ghk == ghk_std assert ut.erev == erev_std switch_units(0) h.finitialize() ghk_std = h.ghk(-50, 0.001, 10, 2) erev_std = h.nernst(s(0.5).nai, s(0.5).nao, 1) assert ut.mole != float.fromhex(legacy_hex_values[0]) assert ut.e * ut.avogadro == ut.faraday assert abs(ut.faraday - h.FARADAY) < 1e-10 assert ut.gasconst == h.R assert ut.k * ut.avogadro == ut.gasconst assert abs(ut.planck - ut.hbar * 2.0 * h.PI) < 1e-49 assert ut.avogadro == h.Avogadro_constant assert ut.ghk == h.ghk(-50, 0.001, 10, 2) assert ut.erev == h.nernst(s(0.5).nai, s(0.5).nao, 1)
def __init__(self): # =======Add-on to original Purkinje.py======= cwd = os.getcwd() # this is the root path_to_files = cwd + os.sep + "models" + \ os.sep + "cells" + os.sep + \ "PC2015Masoli" + os.sep os.chdir(path_to_files) # change to path_to_files # ==============End of the Add-on============= #Soma self.soma = h.Section(name='soma') self.soma.nseg = 1 self.soma.diam = 29.8 self.soma.cm = 0.77 self.soma.L = 29.8 self.soma.Ra = 122 self.soma.insert('Leak') self.soma.e_Leak = pc_param['eleak'] self.soma.gmax_Leak = pc_param['LeakSoma'] self.soma.insert('Cav3_1') self.soma.pcabar_Cav3_1 = pc_param['Cav3.1Soma'] self.soma.insert('Cav2_1') self.soma.pcabar_Cav2_1 = pc_param['Cav2.1Soma'] self.soma.insert('HCN1') self.soma.gbar_HCN1 = pc_param['HCNSoma'] self.soma.eh = -34.4 self.soma.insert('Nav1_6') self.soma.gbar_Nav1_6 = pc_param['Nav1.6Soma'] self.soma.ena = 60 self.soma.insert('Kv3_4') self.soma.gkbar_Kv3_4 = pc_param['Kv3.4Soma'] self.soma.ek = -88 self.soma.insert('Kv1_1') self.soma.gbar_Kv1_1 = pc_param['Kv1.1Soma'] self.soma.insert('Cav3_2') self.soma.gcabar_Cav3_2 = pc_param['Cav3.2Soma'] self.soma.insert('Kca3_1') self.soma.gkbar_Kca3_1 = pc_param['Kca3.1Soma'] self.soma.insert('Cav3_3') self.soma.pcabar_Cav3_3 = pc_param['Cav3.3Soma'] self.soma.insert('Kir2_3') self.soma.gkbar_Kir2_3 = pc_param['PC_KirSoma'] self.soma.insert('Kca1_1') self.soma.gbar_Kca1_1 = pc_param['Kca1.1Soma'] self.soma.insert('Kca2_2') self.soma.gkbar_Kca2_2 = pc_param['Kca2.2Soma'] self.soma.insert('cdp5') self.soma.Nannuli_cdp5 = 0.326 + (1.94 * (self.soma.diam)) + ( 0.289 * (self.soma.diam) * (self.soma.diam)) - ( (3.33e-2) * (self.soma.diam) * (self.soma.diam) * (self.soma.diam)) + ((1.55e-3) * (self.soma.diam) * (self.soma.diam) * (self.soma.diam) * (self.soma.diam)) - (2.55e-5 * (self.soma.diam) * (self.soma.diam) * (self.soma.diam) * (self.soma.diam) * (self.soma.diam)) self.soma.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.soma.diam) / 1.4) self.soma.rf3_cdp5 = 0.162 - 0.106 * math.exp(-(self.soma.diam) / 2.29) self.soma.rf4_cdp5 = 0.000267 + 0.0167 * math.exp( -(self.soma.diam) / 0.722) + 0.0028 * math.exp( -(self.soma.diam) / 4) self.soma.TotalPump_cdp5 = 5e-8 self.soma.push() h.pt3dclear() h.pt3dadd(0.0, 0, 0.0, 29.8) h.pt3dadd(0.0, 29.8, 0.0, 29.8) h.pop_section() self.soma.push() h.ion_style("ca_ion", 1, 1, 0, 1, 0) self.soma.eca = 137.52625 self.soma.cai = h.cai0_ca_ion self.soma.cao = h.cao0_ca_ion h.pop_section() #Dend coordinate self.sectioncoordinate = np.genfromtxt("coordinate.csv") fh = open("PC_dendnames.dlist") self.dendnames = [line[:-1] for line in fh.readlines()] self.dend = [] for i_idx, i in enumerate(self.sectioncoordinate): self.dend.append(h.Section(name=self.dendnames[i_idx])) self.dend[-1].push() h.pt3dclear() h.pt3dadd(i.item(1), i.item(2), i.item(3), i.item(4)) h.pt3dadd(i.item(5), i.item(6), i.item(7), i.item(8)) self.dend[-1].diam = i.item(4) self.dend[-1].insert('cdp5') self.dend[-1].Nannuli_cdp5 = 0.326 + (1.94 * (i.item(8))) + ( 0.289 * (i.item(8)) * (i.item(8))) - ( (3.33e-2) * (i.item(8)) * (i.item(8)) * (i.item(8))) + ((1.55e-3) * (i.item(8)) * (i.item(8)) * (i.item(8)) * (i.item(8))) - (2.55e-5 * (i.item(8)) * (i.item(8)) * (i.item(8)) * (i.item(8)) * (i.item(8))) self.dend[-1].Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(i.item(8)) / 1.4) self.dend[-1].rf3_cdp5 = 0.162 - 0.106 * math.exp( -(i.item(8)) / 2.29) if ((i.item(8)) >= 2): self.dend[-1].rf4_cdp5 = 0.000267 + 0.0167 * math.exp( -(i.item(8)) / 0.722) + 0.0028 * math.exp(-(i.item(8)) / 4) else: self.dend[-1].rf4_cdp5 = 0.003 h.pop_section() #Connection between dend and soma self.dend[0].connect(self.soma, 1, 0) #Connection between each dend for c in np.genfromtxt("connections.csv"): self.dend[int(c[0])].connect(self.dend[int(c[2])], int(c[3]), int(c[1])) self.subsets = np.genfromtxt("ModelViewParmSubset.txt", dtype=int) self.ModelViewParmSubset = [[ self.dend[int(i)] for i in self.subsets[np.where(self.subsets[..., 1] == M), 0][0] ] for M in range(88)] for d in self.dend: d.Ra = 122 d.insert('Leak') d.e_Leak = pc_param['eleak'] d.insert('Cav2_1') d.pcabar_Cav2_1 = pc_param['Cav2.1Dend'] d.insert('Kca1_1') d.gbar_Kca1_1 = pc_param['Kca1.1Dend'] d.insert('Kv4_3') d.gkbar_Kv4_3 = pc_param['Kv4.3Dend'] d.insert('Kv1_1') d.gbar_Kv1_1 = pc_param['Kv1.1Dend'] d.insert('Kv1_5') d.gKur_Kv1_5 = pc_param['Kv1.5Dend'] d.insert('Kv3_3') d.gbar_Kv3_3 = pc_param['Kv3.3Dend'] d.insert('Cav3_3') d.pcabar_Cav3_3 = pc_param['Cav3.3Dend'] d.insert('HCN1') d.gbar_HCN1 = pc_param['HCNDend'] d.eh = -34.4 d.TotalPump_cdp5 = 2e-8 if d.diam >= 3.5 and d.diam <= 12: d.insert('Cav3_2') d.gcabar_Cav3_2 = pc_param['Cav3.2Dend'] d.insert('Kca3_1') d.gkbar_Kca3_1 = pc_param['Kca3.1Dend'] d.insert('Cav3_1') d.pcabar_Cav3_1 = pc_param['Cav3.1Dend'] d.insert('Kca2_2') d.gkbar_Kca2_2 = pc_param['Kca2.2Dend'] d.insert('Kir2_3') d.gkbar_Kir2_3 = pc_param['PC_KirDend'] if d.diam >= 8 and d.diam <= 12: d.insert('Nav1_6') d.gbar_Nav1_6 = pc_param['Nav1.6Dend'] d.ena = 60 d.ek = -88 d.push() d.eca = 137.52625 d.cai = h.cai0_ca_ion d.cao = h.cao0_ca_ion h.ion_style("ca_ion", 1, 1, 0, 1, 0) h.pop_section() self.subsets_cm = np.genfromtxt("ModelViewParmSubset_cm.txt") for cm in self.subsets_cm: for d in self.ModelViewParmSubset[int(cm[0])]: d.cm = cm[1] * 0.77 / 1.64 self.dend[138].cm = 8.58298 * 0.77 / 1.64 self.subsets_paraextra = np.genfromtxt("modelsubsetextra.txt", dtype=[ ('modelviewsubset', 'f8'), ('channel', 'S5'), ('channel2', 'S5'), ('value', 'f8') ]) for para in self.subsets_paraextra: for d in self.ModelViewParmSubset[int(para[0])]: d.insert(para[1]) exec 'd.gmax_' + para[2] + ' = ' + str(para[3]) listgmax = [] for d in self.ModelViewParmSubset[2]: d.gmax_Leak = d.gmax_Leak / 2 self.dend[138].insert('Leak') self.dend[138].gmax_Leak = 1.74451E-4 / 2 #Axon AIS. First section after the soma self.axonAIS = h.Section(name='axonAIS') self.axonAIS.nseg = 1 self.axonAIS.diam = 0.97 self.axonAIS.cm = 0.77 self.axonAIS.L = 17 self.axonAIS.Ra = 122 self.axonAIS.insert('Leak') self.axonAIS.e_Leak = pc_param['eleak'] self.axonAIS.gmax_Leak = 0.0003 self.axonAIS.insert('Nav1_6') self.axonAIS.gbar_Nav1_6 = pc_param['Nav1.6AIS'] self.axonAIS.ena = 75 self.axonAIS.insert('Cav3_1') self.axonAIS.pcabar_Cav3_1 = pc_param['Cav3.1Ais'] self.axonAIS.insert('Cav2_1') self.axonAIS.pcabar_Cav2_1 = pc_param['Cav2.1AIS'] self.axonAIS.insert('Kv3_4') self.axonAIS.gkbar_Kv3_4 = pc_param['Kv3.4AIS'] self.axonAIS.ek = -88 self.axonAIS.insert('cdp5') self.axonAIS.Nannuli_cdp5 = 0.326 + (1.94 * (self.axonAIS.diam)) + ( 0.289 * (self.axonAIS.diam) * (self.axonAIS.diam)) - ( (3.33e-2) * (self.axonAIS.diam) * (self.axonAIS.diam) * (self.axonAIS.diam)) + ( (1.55e-3) * (self.axonAIS.diam) * (self.axonAIS.diam) * (self.axonAIS.diam) * (self.axonAIS.diam)) - (2.55e-5 * (self.axonAIS.diam) * (self.axonAIS.diam) * (self.axonAIS.diam) * (self.axonAIS.diam) * (self.axonAIS.diam)) self.axonAIS.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.axonAIS.diam) / 1.4) self.axonAIS.rf3_cdp5 = 0.162 - 0.106 * math.exp( -(self.axonAIS.diam) / 2.29) self.axonAIS.rf4_cdp5 = 0.003 self.axonAIS.TotalPump_cdp5 = 5e-8 self.axonAIS.push() h.ion_style("ca_ion", 1, 1, 0, 1, 0) self.axonAIS.eca = 137.52625 self.axonAIS.cai = h.cai0_ca_ion self.axonAIS.cao = h.cao0_ca_ion h.pop_section() #AISK self.axonAISK = h.Section(name='axonAISK') self.axonAISK.nseg = 1 self.axonAISK.diam = 0.97 self.axonAISK.cm = 0.77 self.axonAISK.L = 4 self.axonAISK.Ra = 122 self.axonAISK.insert('Leak') self.axonAISK.e_Leak = pc_param['eleak'] self.axonAISK.gmax_Leak = 0.0003 self.axonAISK.insert('Kv1_1') self.axonAISK.gbar_Kv1_1 = pc_param['Kv1.1AisK'] self.axonAISK.ek = -88 #First Myelination self.axonmyelin = h.Section(name='axonmyelin') self.axonmyelin.nseg = 1 self.axonmyelin.diam = 0.73 self.axonmyelin.L = 100 self.axonmyelin.insert('pas') self.axonmyelin.e_pas = -63 self.axonmyelin.g_pas = 5.60e-9 self.axonmyelin.cm = 1.87e-11 self.axonmyelin.Ra = 122 #First Node of Ranvier self.axonNOR = h.Section(name='axonNOR') self.axonNOR.nseg = 1 self.axonNOR.diam = 0.73 self.axonNOR.cm = 0.77 self.axonNOR.L = 4 self.axonNOR.Ra = 122 self.axonNOR.insert('Leak') self.axonNOR.e_Leak = pc_param['eleak'] self.axonNOR.gmax_Leak = 0.0003 self.axonNOR.insert('Nav1_6') self.axonNOR.gbar_Nav1_6 = pc_param['Nav1.6Nor'] self.axonNOR.ena = 60 self.axonNOR.insert('Kv3_4') self.axonNOR.gkbar_Kv3_4 = pc_param['Kv3.4Nor'] self.axonNOR.ek = -88 self.axonNOR.insert('cdp5') self.axonNOR.Nannuli_cdp5 = 0.326 + (1.94 * (self.axonNOR.diam)) + ( 0.289 * (self.axonNOR.diam) * (self.axonNOR.diam)) - ( (3.33e-2) * (self.axonNOR.diam) * (self.axonNOR.diam) * (self.axonNOR.diam)) + ( (1.55e-3) * (self.axonNOR.diam) * (self.axonNOR.diam) * (self.axonNOR.diam) * (self.axonNOR.diam)) - (2.55e-5 * (self.axonNOR.diam) * (self.axonNOR.diam) * (self.axonNOR.diam) * (self.axonNOR.diam) * (self.axonNOR.diam)) self.axonNOR.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.axonNOR.diam) / 1.4) self.axonNOR.rf3_cdp5 = 0.162 - 0.106 * math.exp( -(self.axonNOR.diam) / 2.29) self.axonNOR.rf4_cdp5 = 0.003 self.axonNOR.insert('Cav3_1') self.axonNOR.pcabar_Cav3_1 = pc_param['Cav3.1Nor'] self.axonNOR.insert('Cav2_1') self.axonNOR.pcabar_Cav2_1 = pc_param['Cav2.1Nor'] self.axonNOR.TotalPump_cdp5 = 5e-7 #second part of the axon self.axonmyelin2 = h.Section(name='axonmyelin2') self.axonmyelin2.nseg = 1 self.axonmyelin2.diam = 0.73 self.axonmyelin2.L = 100 self.axonmyelin2.insert('pas') self.axonmyelin2.e_pas = -63 self.axonmyelin2.g_pas = 5.60e-9 self.axonmyelin2.cm = 1.87e-11 self.axonmyelin2.Ra = 122 #Second Node of Ranvier self.axonNOR2 = h.Section(name='axonNOR2') self.axonNOR2.nseg = 1 self.axonNOR2.diam = 0.73 self.axonNOR2.cm = 0.77 self.axonNOR2.L = 4 self.axonNOR2.Ra = 122 self.axonNOR2.insert('Leak') self.axonNOR2.e_Leak = pc_param['eleak'] self.axonNOR2.gmax_Leak = 0.0003 self.axonNOR2.insert('Nav1_6') self.axonNOR2.gbar_Nav1_6 = pc_param['Nav1.6Nor2'] self.axonNOR2.ena = 60 self.axonNOR2.insert('Kv3_4') self.axonNOR2.gkbar_Kv3_4 = pc_param['Kv3.4Nor2'] self.axonNOR2.ek = -88 self.axonNOR2.insert('cdp5') self.axonNOR2.Nannuli_cdp5 = 0.326 + (1.94 * (self.axonNOR2.diam)) + ( 0.289 * (self.axonNOR2.diam) * (self.axonNOR2.diam)) - ( (3.33e-2) * (self.axonNOR2.diam) * (self.axonNOR2.diam) * (self.axonNOR2.diam)) + ( (1.55e-3) * (self.axonNOR2.diam) * (self.axonNOR2.diam) * (self.axonNOR2.diam) * (self.axonNOR2.diam)) - (2.55e-5 * (self.axonNOR2.diam) * (self.axonNOR2.diam) * (self.axonNOR2.diam) * (self.axonNOR2.diam) * (self.axonNOR2.diam)) self.axonNOR2.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.axonNOR2.diam) / 1.4) self.axonNOR2.rf3_cdp5 = 0.162 - 0.106 * math.exp( -(self.axonNOR2.diam) / 2.29) self.axonNOR2.rf4_cdp5 = 0.003 self.axonNOR2.insert('Cav3_1') self.axonNOR2.pcabar_Cav3_1 = pc_param['Cav3.1Nor2'] self.axonNOR2.insert('Cav2_1') self.axonNOR2.pcabar_Cav2_1 = pc_param['Cav2.1Nor2'] self.axonNOR2.TotalPump_cdp5 = 5e-7 #Third part of the axon self.axonmyelin3 = h.Section(name='axonmyelin3') self.axonmyelin3.nseg = 1 self.axonmyelin3.diam = 0.73 self.axonmyelin3.L = 100 self.axonmyelin3.insert('pas') self.axonmyelin3.e_pas = -63 self.axonmyelin3.g_pas = 5.60e-9 self.axonmyelin3.cm = 1.87e-11 self.axonmyelin3.Ra = 122 #Third Node of Ranvier self.axonNOR3 = h.Section(name='axonNOR3') self.axonNOR3.nseg = 1 self.axonNOR3.diam = 0.73 self.axonNOR3.cm = 0.77 self.axonNOR3.L = 4 self.axonNOR3.Ra = 122 self.axonNOR3.insert('Leak') self.axonNOR3.e_Leak = pc_param['eleak'] self.axonNOR3.gmax_Leak = 0.0003 self.axonNOR3.insert('Nav1_6') self.axonNOR3.gbar_Nav1_6 = pc_param['Nav1.6Nor3'] self.axonNOR3.ena = 60 self.axonNOR3.insert('Kv3_4') self.axonNOR3.gkbar_Kv3_4 = pc_param['Kv3.4Nor3'] self.axonNOR3.ek = -88 self.axonNOR3.insert('cdp5') self.axonNOR3.Nannuli_cdp5 = 0.326 + (1.94 * (self.axonNOR3.diam)) + ( 0.289 * (self.axonNOR3.diam) * (self.axonNOR3.diam)) - ( (3.33e-2) * (self.axonNOR3.diam) * (self.axonNOR3.diam) * (self.axonNOR3.diam)) + ( (1.55e-3) * (self.axonNOR3.diam) * (self.axonNOR3.diam) * (self.axonNOR3.diam) * (self.axonNOR3.diam)) - (2.55e-5 * (self.axonNOR3.diam) * (self.axonNOR3.diam) * (self.axonNOR3.diam) * (self.axonNOR3.diam) * (self.axonNOR3.diam)) self.axonNOR3.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.axonNOR3.diam) / 1.4) self.axonNOR3.rf3_cdp5 = 0.162 - 0.106 * math.exp( -(self.axonNOR3.diam) / 2.29) self.axonNOR3.rf4_cdp5 = 0.003 self.axonNOR3.insert('Cav3_1') self.axonNOR3.pcabar_Cav3_1 = pc_param['Cav3.1Nor3'] self.axonNOR3.insert('Cav2_1') self.axonNOR3.pcabar_Cav2_1 = pc_param['Cav2.1Nor3'] self.axonNOR3.TotalPump_cdp5 = 5e-7 #Third part of the axon self.axonmyelin4 = h.Section(name='axonmyelin4') self.axonmyelin4.nseg = 1 self.axonmyelin4.diam = 0.73 self.axonmyelin4.L = 100 self.axonmyelin4.insert('pas') self.axonmyelin4.e_pas = -63 self.axonmyelin4.g_pas = 5.60e-9 self.axonmyelin4.cm = 1.87e-11 self.axonmyelin4.Ra = 122 #Collateral. self.axoncoll = h.Section(name='axoncoll') self.axoncoll.nseg = 1 self.axoncoll.diam = 0.6 self.axoncoll.L = 100 self.axoncoll.Ra = 122 self.axoncoll.insert('Leak') self.axoncoll.e_Leak = pc_param['eleak'] self.axoncoll.gmax_Leak = 0.0003 self.axoncoll.insert('Nav1_6') self.axoncoll.gbar_Nav1_6 = pc_param['Nav1.6Axoncoll'] self.axoncoll.ena = 60 self.axoncoll.insert('Kv3_4') self.axoncoll.gkbar_Kv3_4 = pc_param['Kv3.4Axoncoll'] self.axoncoll.ek = -88 self.axoncoll.insert('Cav3_1') self.axoncoll.pcabar_Cav3_1 = pc_param['Cav3.1Axoncoll'] self.axoncoll.insert('Cav2_1') self.axoncoll.pcabar_Cav2_1 = pc_param['Cav2.1Axoncoll'] self.axoncoll.insert('cdp5') self.axoncoll.Nannuli_cdp5 = 0.326 + (1.94 * (self.axoncoll.diam)) + ( 0.289 * (self.axoncoll.diam) * (self.axoncoll.diam)) - ( (3.33e-2) * (self.axoncoll.diam) * (self.axoncoll.diam) * (self.axoncoll.diam)) + ( (1.55e-3) * (self.axoncoll.diam) * (self.axoncoll.diam) * (self.axoncoll.diam) * (self.axoncoll.diam)) - (2.55e-5 * (self.axoncoll.diam) * (self.axoncoll.diam) * (self.axoncoll.diam) * (self.axoncoll.diam) * (self.axoncoll.diam)) self.axoncoll.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.axoncoll.diam) / 1.4) self.axoncoll.rf3_cdp5 = 0.162 - 0.106 * math.exp( -(self.axoncoll.diam) / 2.29) self.axoncoll.rf4_cdp5 = 0.003 self.axoncoll.TotalPump_cdp5 = 5e-7 self.axoncoll.push() h.ion_style("ca_ion", 1, 1, 0, 1, 0) self.axoncoll.eca = 137.52625 self.axoncoll.cai = h.cai0_ca_ion self.axoncoll.cao = h.cao0_ca_ion h.pop_section() #Collateral second part self.axoncoll2 = h.Section(name='axoncoll2') self.axoncoll2.nseg = 1 self.axoncoll2.diam = 0.6 self.axoncoll2.L = 100 self.axoncoll2.Ra = 122 self.axoncoll2.insert('Leak') self.axoncoll2.e_Leak = pc_param['eleak'] self.axoncoll2.gmax_Leak = 0.0003 self.axoncoll2.insert('Nav1_6') self.axoncoll2.gbar_Nav1_6 = pc_param['Nav1.6Axoncoll'] self.axoncoll2.ena = 60 self.axoncoll2.insert('Kv3_4') self.axoncoll2.gkbar_Kv3_4 = pc_param['Kv3.4Axoncoll'] self.axoncoll2.ek = -88 self.axoncoll2.insert('cdp5') self.axoncoll2.Nannuli_cdp5 = 0.326 + ( 1.94 * (self.axoncoll2.diam)) + ( 0.289 * (self.axoncoll2.diam) * (self.axoncoll2.diam)) - ( (3.33e-2) * (self.axoncoll2.diam) * (self.axoncoll2.diam) * (self.axoncoll2.diam)) + ( (1.55e-3) * (self.axoncoll2.diam) * (self.axoncoll2.diam) * (self.axoncoll2.diam) * (self.axoncoll2.diam)) - (2.55e-5 * (self.axoncoll2.diam) * (self.axoncoll2.diam) * (self.axoncoll2.diam) * (self.axoncoll2.diam) * (self.axoncoll2.diam)) self.axoncoll2.Buffnull2_cdp5 = 64.2 - 57.3 * math.exp( -(self.axoncoll2.diam) / 1.4) self.axoncoll2.rf3_cdp5 = 0.162 - 0.106 * math.exp( -(self.axoncoll2.diam) / 2.29) self.axoncoll2.rf4_cdp5 = 0.003 self.axoncoll2.insert('Cav3_1') self.axoncoll2.pcabar_Cav3_1 = pc_param['Cav3.1Axoncoll'] self.axoncoll2.insert('Cav2_1') self.axoncoll2.pcabar_Cav2_1 = pc_param['Cav2.1Axoncoll'] self.axoncoll2.TotalPump_cdp5 = 5e-7 self.axoncoll2.push() h.ion_style("ca_ion", 1, 1, 0, 1, 0) self.axoncoll2.eca = 137.52625 self.axoncoll2.cai = h.cai0_ca_ion self.axoncoll2.cao = h.cao0_ca_ion h.pop_section() #Connections of the axon self.axonAIS.connect(self.soma, 1, 0) self.axonAISK.connect(self.axonAIS, 1, 0) self.axonmyelin.connect(self.axonAISK, 1, 0) self.axonNOR.connect(self.axonmyelin, 1, 0) self.axonmyelin2.connect(self.axonNOR, 1, 0) self.axonNOR2.connect(self.axonmyelin2, 1, 0) self.axonmyelin3.connect(self.axonNOR2, 1, 0) self.axonNOR3.connect(self.axonmyelin3, 1, 0) self.axonmyelin4.connect(self.axonNOR3, 1, 0) self.axoncoll.connect(self.axonNOR2, 1, 0) self.axoncoll2.connect(self.axoncoll, 1, 0) #vectors for the time and voltage in the soma and axon. self.rec_t = h.Vector() self.rec_t.record(h._ref_t) self.vm_soma = h.Vector() self.vm_soma.record(self.soma(0.5)._ref_v) self.vm_NOR3 = h.Vector() self.vm_NOR3.record(self.axonNOR3(0.5)._ref_v) # =======Add-on to original Purkinje.py======= os.chdir(cwd) # reset to start directory
def __init__(self, regions=None, d=0, name=None, charge=0, initial=None): """s = rxd.Species(regions, d = 0, name = None, charge = 0, initial = None) Declare a species. Parameters: regions -- a Region or list of Region objects containing the species d -- the diffusion constant of the species (optional; default is 0, i.e. non-diffusing) name -- the name of the Species; used for syncing with HOC (optional; default is none) charge -- the charge of the Species (optional; default is 0) initial -- the initial concentration or None (if None, then imports from HOC if the species is defined at finitialize, else 0) Note: charge must match the charges specified in NMODL files for the same ion, if any.""" # TODO: if a list of sections is passed in, make that one region # _species_count is used to create a unique _real_name for the species global _species_count # TODO: check about the 0<x<1 problem alluded to in the documentation h.define_shape() self._name = name if name is not None: if not isinstance(name, str): raise Exception('Species name must be a string') if name in _defined_species and _defined_species[name]() is not None: raise Exception('Species "%s" previously defined: %r' % (name, _defined_species[name]())) else: name = _species_count self._id = _species_count _species_count += 1 _defined_species[name] = weakref.ref(self) if regions is None: raise Exception('Must specify region where species is present') if hasattr(regions, '__len__'): regions = list(regions) else: regions = list([regions]) if not all(isinstance(r, region.Region) for r in regions): raise Exception('regions list must consist of Region objects only') self._regions = regions self._real_name = name self.initial = initial self._charge = charge self._d = d # at this point self._name is None if unnamed or a string == name if # named if self._name is not None: ion_type = h.ion_register(name, charge) if ion_type == -1: raise Exception('Unable to register species: %s' % species) # insert the species if not already present for r in regions: if r.nrn_region in ('i', 'o'): for s in r.secs: try: ion_forms = [name + 'i', name + 'o', 'i' + name, 'e' + name] for i in ion_forms: # this throws an exception if one of the ion forms is missing temp = s.__getattribute__(name + 'i') except: s.insert(name + '_ion') # set to recalculate reversal potential automatically # the last 1 says to set based on global initial concentrations # e.g. nai0_na_ion, etc... h.ion_style(name + '_ion', 3, 2, 1, 1, 1, sec=s) self._real_secs = region._sort_secs(sum([r.secs for r in regions], [])) # TODO: at this point the sections are sorted within each region, but for # tree solver (which not currently using) would need sorted across # all regions if diffusion between multiple regions self._secs = [Section1D(self, sec, d, r) for r in regions for sec in r.secs] if self._secs: self._offset = self._secs[0]._offset else: self._offset = 0 self._has_adjusted_offsets = False self._assign_parents() self._update_region_indices()
def __init__(self, regions=None, d=0, name=None, charge=0, initial=None): """s = rxd.Species(regions, d = 0, name = None, charge = 0, initial = None) Declare a species. Parameters: regions -- a Region or list of Region objects containing the species d -- the diffusion constant of the species (optional; default is 0, i.e. non-diffusing) name -- the name of the Species; used for syncing with HOC (optional; default is none) charge -- the charge of the Species (optional; default is 0) initial -- the initial concentration or None (if None, then imports from HOC if the species is defined at finitialize, else 0) Note: charge must match the charges specified in NMODL files for the same ion, if any.""" # TODO: if a list of sections is passed in, make that one region # _species_count is used to create a unique _real_name for the species global _species_count # TODO: check about the 0<x<1 problem alluded to in the documentation h.define_shape() self._name = name if name is not None: if not isinstance(name, str): raise Exception('Species name must be a string') if name in _defined_species and _defined_species[name]( ) is not None: raise Exception('Species "%s" previously defined: %r' % (name, _defined_species[name]())) else: name = _species_count self._id = _species_count _species_count += 1 _defined_species[name] = weakref.ref(self) if regions is None: raise Exception('Must specify region where species is present') if hasattr(regions, '__len__'): regions = list(regions) else: regions = list([regions]) if not all(isinstance(r, region.Region) for r in regions): raise Exception('regions list must consist of Region objects only') self._regions = regions self._real_name = name self.initial = initial self._charge = charge self._d = d # at this point self._name is None if unnamed or a string == name if # named if self._name is not None: ion_type = h.ion_register(name, charge) if ion_type == -1: raise Exception('Unable to register species: %s' % species) # insert the species if not already present for r in regions: if r.nrn_region in ('i', 'o'): for s in r.secs: try: ion_forms = [ name + 'i', name + 'o', 'i' + name, 'e' + name ] for i in ion_forms: # this throws an exception if one of the ion forms is missing temp = s.__getattribute__(name + 'i') except: s.insert(name + '_ion') # set to recalculate reversal potential automatically # the last 1 says to set based on global initial concentrations # e.g. nai0_na_ion, etc... h.ion_style(name + '_ion', 3, 2, 1, 1, 1, sec=s) self._real_secs = region._sort_secs(sum([r.secs for r in regions], [])) # TODO: at this point the sections are sorted within each region, but for # tree solver (which not currently using) would need sorted across # all regions if diffusion between multiple regions self._secs = [ Section1D(self, sec, d, r) for r in regions for sec in r.secs ] if self._secs: self._offset = self._secs[0]._offset else: self._offset = 0 self._has_adjusted_offsets = False self._assign_parents() self._update_region_indices()
def init_cell(cell_path, spines=True): """ cell: path to cell definiton """ h("forall delete_section()") # ---- conditions ---- h.celsius = temp # ---- soma & dendrite ---- h.xopen(cell_path) soma = h.soma dendritic = [] # segment lengths should be not longer than 50um # contains soma! for sec in h.allsec(): diam = sec.diam n = sec.L / 50.0 + 1 sec.nseg = int(n) # needed in Python, automatic in hoc if h.n3d() == 0: sec.diam = diam dendritic.append(sec) dendritic_only = [] for sec in dendritic: if sec != h.soma: dendritic_only.append(sec) assert len(dendritic) - 1 == len(dendritic_only) # ---- spines --- if spines: for sec in dendritic_only: a = 0.0 for seg in sec.allseg(): a += seg.area() F = (sec.L * spine_area * spine_dens + a) / a sec.L = sec.L * F ** (2 / 3.0) for seg in sec.allseg(): seg.diam = seg.diam * F ** (1 / 3.0) # ---- axon ---- # initial segment between hillock + myelin iseg = h.Section(name="iseg") iseg.L = iseg_L iseg.nseg = iseg_nseg soma_compl_area = 0 for seg in soma: soma_compl_area += seg.area() print soma_compl_area iseg.diam = (soma_compl_area / (4.0 * np.pi)) ** (0.5) / 10.0 # axon hillock hill = h.Section(name="hill") hill.L = hill_L hill.nseg = hill_nseg taper_diam(hill, 4 * iseg.diam, iseg.diam) myelin = [h.Section(name="myelin %d" % i) for i in range(n_axon_seg)] for myelin_sec in myelin: myelin_sec.nseg = myelin_nseg # each of the 5 sections has 5 segments myelin_sec.L = myelin_L myelin_sec.diam = iseg.diam node = [h.Section(name="node %d" % i) for i in range(n_axon_seg)] for node_sec in node: node_sec.nseg = node_nseg node_sec.L = node_L node_sec.diam = iseg.diam * 0.75 # syntax: childsec.connect(parentsec, parentx, childx) hill.connect(soma, 0.5, 0) iseg.connect(hill, 1, 0) myelin[0].connect(iseg, 1, 0) node[0].connect(myelin[0], 1, 0) for i in range(n_axon_seg - 1): myelin[i + 1].connect(node[i], 1, 0) node[i + 1].connect(myelin[i + 1], 1, 0) # ---- mechanisms ---- for sec in h.allsec(): sec.insert("pas") sec.Ra = ra sec.cm = c_m sec.g_pas = 1.0 / rm sec.e_pas = v_init sec.insert("na") # dendrite for sec in dendritic_only: sec.gbar_na = gna_dend sec.insert("km") sec.gbar_km = gkm sec.insert("kca") sec.gbar_kca = gkca sec.insert("ca") sec.gbar_ca = gca sec.insert("cad") # na+ channels soma.gbar_na = gna_soma soma.insert("kv") soma.gbar_kv = gkv_soma soma.insert("km") soma.gbar_km = gkm_soma soma.insert("kca") soma.gbar_kca = gkca_soma soma.insert("ca") soma.gbar_ca = gca_soma soma.insert("cad") for myelin_sec in myelin: myelin_sec.cm = cm_myelin myelin_sec.gbar_na = gna_dend hill.gbar_na = gna_node iseg.gbar_na = gna_node for node_sec in node: node_sec.g_pas = g_pas_node node_sec.gbar_na = gna_node iseg.insert("kv") iseg.gbar_kv = gkv_axon hill.insert("kv") hill.gbar_kv = gkv_axon for sec in h.allsec(): if h.ismembrane("k_ion"): sec.ek = Ek if h.ismembrane("na_ion"): sec.ena = Ena h.vshift_na = -5 if h.ismembrane("ca_ion"): sec.eca = 140 h.ion_style("ca_ion", 0, 1, 0, 0, 0) h.vshift_ca = 0 axon = [iseg, hill, myelin, node] return soma, dendritic_only, axon