Пример #1
0
def _addRates(self, params):
    from .. import sim

    for label, param in params.items():

        dynamicVars = {'sim': sim, 'rxd': rxd}

        # species
        if 'species' not in param:
            print('  Error creating Rate %s: "species" parameter was missing' %
                  (label))
            continue
        if isinstance(param['species'], basestring):
            speciesStr = self._replaceRxDStr(param['species'])
            exec('species = ' + speciesStr, dynamicVars)
            if 'species' not in dynamicVars:
                dynamicVars['species']  # fix for python 2
        else:
            print(
                '  Error creating Rate %s: "species" parameter should be a string'
                % (param['species']))
            continue

        # rate
        if 'rate' not in param:
            print('  Error creating Rate %s: "rate" parameter was missing' %
                  (label))
            continue
        if isinstance(param['rate'], basestring):
            rateStr = self._replaceRxDStr(param['rate'])
            exec('rate = ' + rateStr, dynamicVars)
            if 'rate' not in dynamicVars:
                dynamicVars['rate']  # fix for python 2

        # regions
        if 'regions' not in param:
            param['regions'] = [None]
        elif not isinstance(param['regions'], list):
            param['regions'] = [param['regions']]
        try:
            nrnRegions = [
                self.rxd['regions'][region]['hObj']
                for region in param['regions'] if region is not None
                and self.rxd['regions'][region]['hObj'] != None
            ]
        except:
            print('  Error creating Rate %s: could not find regions %s' %
                  (label, param['regions']))

        # membrane_flux
        if 'membrane_flux' not in param:
            param['membrane_flux'] = False

        self.rxd['rates'][label]['hObj'] = rxd.Rate(
            dynamicVars['species'],
            dynamicVars['rate'],
            regions=nrnRegions,
            membrane_flux=param['membrane_flux'])

        print('  Created Rate %s' % (label))
Пример #2
0
    def create_ca_rxd(self):
        cainf = 100e-6
        taur = self.p_all['L5Pyr_dend_taur_cad']  # temporary
        # drive_channel = -(10000) * self.ica_soma / (.2)
        # [sec for sec in h.allsec() if 'soma' in sec.name()]

        ca_reg = rxd.Region(h.allsec(),
                            nrn_region='i',
                            name='ca_reg',
                            geometry=rxd.Shell(0.9848, 1))
        ca = rxd.Species(ca_reg, d=0.3, name='ca', charge=2, initial=cainf)
        ca_pump = rxd.Rate(ca, (cainf - ca) / taur)

        self.ca = ca
        self.ca_reg = ca_reg
        self.ca_pump = ca_pump
Пример #3
0
    d=1.0,
    charge=1,
    initial=0,
)
Xcyt = x[cyt]
Xorg = x[org]
Xecs = x[ecs]

# What? - produce X in cell 1
# parameter to limit production to cell 1
cell1_param = rxd.Parameter(org,
                            initial=lambda node: 1.0
                            if node.segment.sec == cell1 else 0)

# production with a rate following Michaels Menton kinetics
createX = rxd.Rate(Xorg, cell1_param[org] * 1.0 / (10.0 + Xorg))

# leak between organelles and cytosol
cyt_org_leak = rxd.MultiCompartmentReaction(Xcyt,
                                            Xorg,
                                            1e4,
                                            1e4,
                                            membrane=cyt_org_membrane,
                                            membrane_flux=False)
from math import pi

e = 1.60217662e-19
scale = 1e-14 / e
cyt_ecs_pump1 = rxd.MultiCompartmentReaction(
    Xcyt,
    Xecs,
Пример #4
0
# the species and other states
ca = rxd.Species([cyt, er], d=caDiff, name='ca', charge=2, initial=cac_init)
ip3 = rxd.Species(cyt, d=ip3Diff, initial=ip3_init)
ip3r_gate_state = rxd.State(cyt_er_membrane, initial=0.8)
h_gate = ip3r_gate_state[cyt_er_membrane]


# pumps and channels between ER and Cytosol

serca = rxd.MultiCompartmentReaction(ca[cyt]>ca[er], gserca/((kserca / (1000. * ca[cyt])) ** 2 + 1), membrane=cyt_er_membrane, custom_dynamics=True)
leak = rxd.MultiCompartmentReaction(ca[er]!=ca[cyt], gleak, gleak, membrane=cyt_er_membrane)

minf = ip3[cyt] * 1000. * ca[cyt] / (ip3[cyt] + kip3) / (1000. * ca[cyt] + kact)
k = gip3r * (minf * h_gate) ** 3 
ip3r = rxd.MultiCompartmentReaction(ca[er]!=ca[cyt], k, k, membrane=cyt_er_membrane)
ip3rg = rxd.Rate(h_gate, (1. / (1 + 1000. * ca[cyt] / (0.3)) - h_gate) / ip3rtau)




cae_init = (0.0017 - cac_init * fc) / fe
ca[er].concentration = cae_init

#ip3.nodes.concentration = 2
for node in ip3.nodes:
    if node.x < .2:
        node.concentration = 2


h.CVode().re_init()
Пример #5
0
Файл: hh.py Проект: vogdb/nrn
ki, ko, nai, nao, xi, xo = k[cyt], k[ecs], na[cyt], na[ecs], x[cyt], x[ecs]

# gates
ngate = rxd.State([cyt, mem], name='ngate', initial=0.24458654944007166)
mgate = rxd.State([cyt, mem], name='mgate', initial=0.028905534475191907)
hgate = rxd.State([cyt, mem], name='hgate', initial=0.7540796658225246)

# somaA parameter
pA = rxd.Parameter([cyt, mem],
                   name='paramA',
                   initial=lambda nd: 1 if nd.segment in somaA else 0)

#What
# gates
m_gate = rxd.Rate(mgate, (minf - mgate) / mtau)
h_gate = rxd.Rate(hgate, (hinf - hgate) / htau)
n_gate = rxd.Rate(ngate, (ninf - ngate) / ntau)

# Nernst potentials
ena = 1e3 * h.R * (h.celsius + 273.15) * log(nao / nai) / h.FARADAY
ek = 1e3 * h.R * (h.celsius + 273.15) * log(ko / ki) / h.FARADAY

gna = pA * gnabar * mgate**3 * hgate
gk = pA * gkbar * ngate**4

na_current = rxd.MultiCompartmentReaction(nai,
                                          nao,
                                          gna * (v - ena),
                                          mass_action=False,
                                          membrane=mem,
Пример #6
0
                                     gserca / ((kserca /
                                                (1000. * ca[cyt]))**2 + 1),
                                     membrane=cyt_er_membrane,
                                     custom_dynamics=True)
leak = rxd.MultiCompartmentReaction(ca[er],
                                    ca[cyt],
                                    gleak,
                                    gleak,
                                    membrane=cyt_er_membrane)

ip3r = rxd.MultiCompartmentReaction(ca[er],
                                    ca[cyt],
                                    k,
                                    k,
                                    membrane=cyt_er_membrane)
ip3rg = rxd.Rate(h_gate, (1. / (1 + rescale_v * v * ca[cyt] /
                                (0.3)) - h_gate) / ip3rtau)

h.finitialize()

cacyt_trace = h.Vector()
cacyt_trace.record(ca[cyt].nodes(sec)(.5)[0]._ref_concentration)

caer_trace = h.Vector()
caer_trace.record(ca[er].nodes(sec)(.5)[0]._ref_concentration)

ip3_trace = h.Vector()
ip3_trace.record(ip3.nodes(sec)(.5)[0]._ref_concentration)

times = h.Vector()
times.record(h._ref_t)
dend2.connect(dend1)

diff_constant = 1
h.cvode_active(True)
r = rxd.Region(h.allsec(), dx=0.25)

rxd.set_solve_type([dend1], dimension=3)

ca = rxd.Species(
    r,
    d=diff_constant,
    atolscale=0.1,
    initial=lambda node: 1 if (0.8 < node.x and node.segment in dend1) or
    (node.x < 0.2 and node.segment in dend2) else 0,
)
bistable_reaction = rxd.Rate(ca, -ca * (1 - ca) * (0.01 - ca))
h.finitialize()

for i in range(2):
    h.fadvance()
rxd.nthread(2)
for i in range(2, 4):
    h.fadvance()
rxd.nthread(3)
for i in range(4, 6):
    h.fadvance()
rxd.nthread(4)
for i in range(6, 8):
    h.fadvance()
rxd.nthread(1)
for i in range(8, 11):
Пример #8
0
from neuron import h, crxd as rxd, gui
from neuron.crxd import initializer

h.CVode().active(1)

rxdsec = [h.Section(), h.Section()]
cyt = rxd.Region(rxdsec)
er = rxd.Region(rxdsec)
ca = rxd.Species([cyt, er])
caextrude = rxd.Rate(ca, 1)

# test for forced initialization before model fully described
initializer._do_init()
ip3 = rxd.Species(cyt)
h.tstop = 1000
h.run()