Beispiel #1
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
Beispiel #2
0
#Create cell
cell = Neuron()
'''
stim = h.IClamp(cell.soma(0.5))
stim.delay = 50
stim.dur = 50
stim.amp = 1
'''
time = h.Vector().record(h._ref_t)
print(5)
ecs = rxd.Extracellular(-Lx/2.0, -Ly/2.0,
                        -Lz/2.0, Lx/2.0, Ly/2.0, Lz/2.0, dx=1,
                        volume_fraction=alpha, tortuosity=tort) 
print(6)
k = rxd.Species(ecs, name='k', d=2.62, charge=1, initial=lambda nd: 50 
                if nd.x3d**2 + nd.y3d**2 + nd.z3d**2 < r0**2 else 3,
                ecs_boundary_conditions=3)

na = rxd.Species(ecs, name='na', d=1.78, charge=1, initial=148,
                 ecs_boundary_conditions=148)

pc.set_maxstep(100)
h.finitialize()

sys.stdout.write('\ninit')
sys.stdout.flush()

def progress_bar(tstop, size=40):
    prog = h.t / float(tstop)
    fill = int(size * prog)
    empt = size - fill
Beispiel #3
0
# extracellular
ecs = rxd.Extracellular(xl, yl, zl, xh, yh, zh, dx=50)

# Who?


def init(ics, ecs):
    return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular
                                        ) else ics


# ions
k = rxd.Species([cyt, mem, ecs],
                name='k',
                d=1,
                charge=1,
                initial=init(54.4, 2.5))

na = rxd.Species([cyt, mem, ecs],
                 name='na',
                 d=1,
                 charge=1,
                 initial=init(10.0, 140.0))
x = rxd.Species([cyt, mem, ecs], name='x', charge=1)

ki, ko, nai, nao, xi, xo = k[cyt], k[ecs], na[cyt], na[ecs], x[cyt], x[ecs]

# gates
ngate = rxd.Species([cyt, mem], name='ngate', initial=0.24458654944007166)
mgate = rxd.Species([cyt, mem], name='mgate', initial=0.028905534475191907)
Beispiel #4
0
gserca = 0.3913
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000
h.CVode().active(1)
h.cvode.atol(1e-10)

# define the regions for the rxd
cyt = rxd.Region(h.allsec(), nrn_region='i', geometry=rxd.FractionalVolume(fc, surface_fraction=1))
er = rxd.Region(h.allsec(), geometry=rxd.FractionalVolume(fe))
cyt_er_membrane = rxd.Region(h.allsec(), geometry=rxd.FixedPerimeter(1))

# 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)
Beispiel #5
0
Datei: hh.py Projekt: vogdb/nrn
mem = rxd.Region(h.allsec(), name='cell_mem', geometry=rxd.membrane())

# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=100)


# Who?
def init(ics, ecs):
    return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular
                                        ) else ics


# ions
k = rxd.Species([cyt, mem, ecs],
                name='k',
                d=1e3,
                charge=1,
                initial=init(54.4, 2.5),
                ecs_boundary_conditions=2.5)

na = rxd.Species([cyt, mem, ecs],
                 name='na',
                 d=1e3,
                 charge=1,
                 initial=init(10.0, 140.0),
                 ecs_boundary_conditions=140)
x = rxd.Species([cyt, mem, ecs], name='x', charge=1)

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)
Beispiel #6
0
fe = 0.3
caCYT_init = 0.1

cyt = rxd.Region(h.allsec(),
                 name='cyt',
                 nrn_region='i',
                 geometry=rxd.FractionalVolume(fc, surface_fraction=1))

er = rxd.Region(h.allsec(), name='er', geometry=rxd.FractionalVolume(fe / 2.))

cyt_er_membrane = rxd.Region(h.allsec(),
                             name='mem',
                             geometry=rxd.ScalableBorder(
                                 1, on_cell_surface=False))

ca = rxd.Species([cyt, er], d=caDiff, name="ca", charge=2, initial=caCYT_init)

ip3 = rxd.Species(cyt, d=ip3Diff, name="ip3", initial=ip3_init)
ip3r_gate_state = rxd.Species(cyt_er_membrane, name="gate", initial=0.8)
h_gate = ip3r_gate_state[cyt_er_membrane]
minf = ip3[cyt] * rescale_v * v * ca[cyt] / (ip3[cyt] + kip3) / (
    rescale_v * v * ca[cyt] + kact)
k = gip3r * (minf * h_gate)**3

ip3r = rxd.MultiCompartmentReaction(ca[er],
                                    ca[cyt],
                                    k,
                                    k,
                                    membrane=cyt_er_membrane)

serca = rxd.MultiCompartmentReaction(ca[cyt],
Beispiel #7
0
Datei: hh.py Projekt: pramodk/nrn
# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=100)


# Who?
def init(ics, ecs):
    return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular
                                        ) else ics


# ions
k = rxd.Species(
    [cyt, mem, ecs],
    name="k",
    d=1e3,
    charge=1,
    initial=init(54.4, 2.5),
    ecs_boundary_conditions=2.5,
)

na = rxd.Species(
    [cyt, mem, ecs],
    name="na",
    d=1e3,
    charge=1,
    initial=init(10.0, 140.0),
    ecs_boundary_conditions=140,
)
x = rxd.Species([cyt, mem, ecs], name="x", charge=1)

ki, ko, nai, nao, xi, xo = k[cyt], k[ecs], na[cyt], na[ecs], x[cyt], x[ecs]
dend2 = h.Section()
dend2.diam = 2
dend2.nseg = 101
dend2.L = 50
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)
Beispiel #9
0
# membrane
mem = rxd.Region(h.allsec(), name="cell_mem", geometry=rxd.membrane())

# extracellular
ecs = rxd.Extracellular(xl, yl, zl, xh, yh, zh, dx=50)

# Who?


def init(ics, ecs):
    return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular) else ics


# ions
k = rxd.Species([cyt, mem, ecs], name="k", d=1, charge=1, initial=init(54.4, 2.5))

na = rxd.Species([cyt, mem, ecs], name="na", d=1, charge=1, initial=init(10.0, 140.0))
x = rxd.Species([cyt, mem, ecs], name="x", charge=1)

ki, ko, nai, nao, xi, xo = k[cyt], k[ecs], na[cyt], na[ecs], x[cyt], x[ecs]

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

# mycellA parameter
pA = rxd.Parameter(
    [cyt, mem],
    name="paramA",
Beispiel #10
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()
Beispiel #11
0
    def __init__(self):

        self.soma = h.Section(name='soma', cell=self)
        self.soma.pt3dclear()
        self.soma.pt3dadd(x, y, z + somaR, 2.0 * somaR)
        self.soma.pt3dadd(x, y, z - somaR, 2.0 * somaR)

        self.dend = h.Section(name='dend', cell=self)
        self.dend.pt3dclear()
        self.dend.pt3dadd(x, y, z - somaR, 2.0 * dendR)
        self.dend.pt3dadd(x, y, z - somaR - dendL, 2.0 * dendR)
        self.dend.nseg = 10

        self.dend.connect(self.soma, 1, 0)
        self.all = [self.soma, self.dend]

        #---------------soma----------------
        #        for mechanism_s in ['h','hNa','hha2', 'IA','kadcr','borgka','Ih','Ihvip', 'kap', 'km' ,'pas', 'Nafcr', 'kdrcr', 'IKscr', 'iCcr', 'kadcr']:
        #           self.soma.insert(mechanism_s)
        for mechanism_s in [
                'extracellular', 'h', 'hNa', 'hha2', 'IA', 'Ih', 'Nasoma',
                'km', 'Ksoma', 'pas', 'k_ion', 'na_ion', 'kap', 'nap', 'kdrcr',
                'Nafcr', 'IKscr'
        ]:
            self.soma.insert(mechanism_s)

        self.soma(0.5).IA.gkAbar = 0.0165
        self.soma(0.5).Ih.gkhbar = 0.00035 * 0.1
        self.soma(0.5).Nasoma.gnasoma = 0.0107 * 1.2
        self.soma(0.5).Nasoma.gl = 1 / Rm
        self.soma(0.5).Nasoma.el = -67
        self.soma(0.5).Ksoma.gksoma = 0.0319 * 1.5
        #print(self.soma.psection())
        self.n_Ksoma = h.Vector().record(self.soma(0.5).Ksoma._ref_n)
        self.h_Nasoma = h.Vector().record(self.soma(0.5).Nasoma._ref_h)
        self.m_Nasoma = h.Vector().record(self.soma(0.5).Nasoma._ref_m)

        self.soma(0.5).h.ghdbar = 0.00005
        self.soma(0.5).h.vhalfl = -73
        self.soma(0.5).Ih.gkhbar = 0.00035 * 0.1
        self.soma(0.5).km.gbar = 0.06
        #self.soma(0.5).borgka.gkabar = 0.00015*4*0.5
        #self.soma(0.5).kadcr.gkabar = 0.003
        self.soma(0.5).hha2.gnabar = 0.007
        self.soma(0.5).hha2.gkbar = 0.007 / 10
        self.soma(0.5).hha2.gl = 0
        self.soma(0.5).hha2.el = -70
        #self.soma(0.5).pas.g = 1/Rm
        #self.soma(0.5).pas.e = -70
        self.soma(0.5).Nafcr.gnafbar = 0.015
        self.soma(0.5).kdrcr.gkdrbar = 0.018
        self.soma(0.5).IKscr.gKsbar = 0.000725
        #self.soma(0.5).iCcr.gkcbar = 0.00003
        #self.soma(0.5).kadcr.gkabar = 0.003

        #print(self.soma.psection())
        #self.n_Ksoma = h.Vector().record(self.soma(0.5).Ksoma._ref_n)
        #self.h_Nasoma = h.Vector().record(self.soma(0.5).Nasoma._ref_h)
        #self.m_Nasoma = h.Vector().record(self.soma(0.5).Nasoma._ref_m)

        self.somaV = h.Vector()
        self.somaV.record(self.soma(0.5)._ref_v)

        #---------------dend----------------

        for mechanism_d in [
                'Nadend', 'Kdend', 'hha_old', 'h', 'hNa', 'IA', 'kap', 'pas',
                'Nafcr', 'kdrcr', 'nap', 'k_ion', 'na_ion', 'Ihvip', 'kad'
        ]:
            self.dend.insert(mechanism_d)
        self.dend(0.5).IA.gkAbar = 0.004 * 1.2
        #self.dend1(0.5).Ih.gkhbar = 0.00035*0.1
        self.dend(0.5).Nadend.gnadend = 2 * 0.0117
        self.dend(0.5).Nadend.gl = 1 / Rm
        self.dend(0.5).Nadend.el = -65
        self.dend(0.5).Kdend.gkdend = 20 * 0.023
        self.dend(0.5).h.ghdbar = 0.00005 * 4
        self.dend(0.5).h.vhalfl = -81
        self.dend(0.5).IA.gkAbar = 0.004 * 1.2
        self.dend(0.5).kad.gkabar = 0
        #self.dend(0.5).km.gbar = 0.06
        #self.dend(0.5).borgka.gkabar = 0.00015*4*0.5
        self.dend(0.5).hha_old.gnabar = 0.007
        self.dend(0.5).hha_old.gkbar = 0.007 / 8.065
        self.dend(0.5).hha_old.el = -70
        self.dend(0.5).hha_old.gl = 0
        #self.dend(0.5).pas.g = 1/20000
        #self.dend(0.5).pas.e = -70

        self.dend(0.5).Nafcr.gnafbar = 0.018 * 5
        self.dend(0.5).kdrcr.gkdrbar = 0.018 * 0.5
        #self.Dn_Kdend = h.Vector().record(self.dend(0.5).Kdend._ref_n)
        #self.Dh_Nadend = h.Vector().record(self.dend(0.5).Nadend._ref_h)
        #self.Dm_Nadend = h.Vector().record(self.dend(0.5).Nadend._ref_m)
        self.dendV = h.Vector()
        self.dendV.record(self.dend(0.5)._ref_v)
        self.k_vec = h.Vector().record(self.soma(0.5)._ref_ik)
        self.na_vec = h.Vector().record(self.soma(0.5)._ref_ina)
        self.na_concentration = h.Vector().record(self.soma(0.5)._ref_nai)
        self.k_concentration = h.Vector().record(self.soma(0.5)._ref_ki)
        self.v_vec = h.Vector().record(self.soma(0.5)._ref_vext[0])

        for sec in self.all:
            Ra = 150
            cm = 1.2

        self.cyt = rxd.Region(self.all,
                              name='cyt',
                              nrn_region='i',
                              dx=1.0,
                              geometry=rxd.FractionalVolume(
                                  0.9, surface_fraction=1.0))
        self.na = rxd.Species([self.cyt],
                              name='na',
                              charge=1,
                              d=1.0,
                              initial=14)
        self.k = rxd.Species([self.cyt],
                             name='k',
                             charge=1,
                             d=1.0,
                             initial=120)
        self.k_i = self.k[self.cyt]
Beispiel #12
0
# enable extracellular RxD
rxd.options.enable.extracellular = True

# simulation parameters
dx = 1.0    # voxel size
L = 9.0     # length of initial cube
Lecs = 21.0 # lengths of ECS

# define the extracellular region
extracellular = rxd.Extracellular(-Lecs/2., -Lecs/2., -Lecs/2.,
                                  Lecs/2., Lecs/2., Lecs/2., dx=dx,
                                  volume_fraction=0.2, tortuosity=lambda x,y,z: 1.6)

# define the extracellular species
k_rxd = rxd.Species(extracellular, name='k', d=2.62, charge=1,
                    initial=lambda nd: 1.0 if abs(nd.x3d) <= L/2. and
                    abs(nd.y3d) <= L/2. and abs(nd.z3d) <= L/2. else 0.0)

# copy of the initial state to plot (figure 4a upper panel)
states_init = k_rxd[extracellular].states3d.copy()

# record the concentration at (0,0,0)
ecs_vec = h.Vector()
ecs_vec.record(k_rxd[extracellular].node_by_location(0, 0, 0)._ref_value)
# record the time
t_vec = h.Vector()
t_vec.record(h._ref_t)

h.finitialize()
h.dt = 0.1
h.continuerun(100) #run the simulation
Beispiel #13
0
# the extracellular space
ecs = rxd.Extracellular(-55,
                        -55,
                        -55,
                        55,
                        55,
                        55,
                        dx=10,
                        volume_fraction=0.2,
                        tortuosity=1.6)

# Who?
x = rxd.Species([cyt, org, cyt_org_membrane, ecs],
                name='x',
                d=1.0,
                charge=1,
                initial=0)
Xcyt = x[cyt]
Xorg = x[org]

# 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
Beispiel #14
0
Dcab = 0 

# create sections
soma = h.Section(name="soma")
dend = h.Section(name="dend")
soma.L=100
soma.diam=1
soma.nseg=101
dend.L=100
dend.diam=1
dend.nseg=101
soma.connect(dend)


r = rxd.Region(h.allsec())
Ca = rxd.Species(r, name='Ca', d=Dca)
Buf = rxd.Species(r, name='Buf', d=Db)
CaBuf = rxd.Species(r, name='CaBuf', d=Dcab)

buffering = rxd.Reaction(Ca[r] + Buf[r], CaBuf[r], kf, kb)


#
# set initial concentrations to ca0, b0, cab0 in soma, 
# and to 0.001 in dend
#
Ca.initial = lambda node: (ca0 if node.sec._sec==soma else 0.001)
Buf.initial = lambda node: (b0 if node.sec._sec==soma else 0.001)
CaBuf.initial = lambda node:(cab0 if node.sec._sec==soma else 0.001)

stim1.amp = 10

ecs = rxd.Extracellular(-Lx / 2.0,
                        -Ly / 2.0,
                        -Lz / 2.0,
                        Lx / 2.0,
                        Ly / 2.0,
                        Lz / 2.0,
                        dx=20,
                        volume_fraction=alpha,
                        tortuosity=tort)

k = rxd.Species(ecs,
                name='k',
                d=2.62,
                charge=1,
                initial=lambda nd: 3
                if nd.x3d**2 + nd.y3d**2 + nd.z3d**2 < r0**2 else 3,
                ecs_boundary_conditions=3)

na = rxd.Species(ecs,
                 name='na',
                 d=1.78,
                 charge=1,
                 initial=135,
                 ecs_boundary_conditions=135)

ca = rxd.Species(ecs,
                 name='ca',
                 d=0.08,
                 charge=2,
Beispiel #16
0
from neuron import h, crxd as rxd

h.load_file("stdrun.hoc")

cell = h.Section(name="cell")
r = rxd.Region([cell])


def Declare_Parameters(**kwargs):
    """helper function enabling clean declaration of parameters in top namespace"""
    for key, value in kwargs.items():
        globals()[key] = rxd.Parameter(r, name=key, initial=value)


def Declare_Species(**kwargs):
    """helper function enabling clean declaration of species in top namespace"""
    for key, value in kwargs.items():
        globals()[key] = rxd.Species(r, name=key, initial=value)


k3 = rxd.Parameter(r, name="k3", initial=1.2)
k4 = rxd.Parameter(r, name="k4", initial=0.6)

P2 = rxd.Species(r, name="P2", initial=0.0614368)
T2 = rxd.Species(r, name="T2", initial=0.0145428)
C = rxd.Species(r, name="C", initial=0.207614)

h.finitialize(-65)
h.continuerun(72)
Beispiel #17
0
def Declare_Species(**kwargs):
    """helper function enabling clean declaration of species in top namespace"""
    for key, value in kwargs.items():
        globals()[key] = rxd.Species(r, name=key, initial=value)
Beispiel #18
0
mem = rxd.Region(h.allsec(), name="cell_mem", geometry=rxd.membrane())

# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)


# Who?
def init(ics, ecs):
    return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular
                                        ) else ics


# ions
k = rxd.Species([cyt, mem],
                name="k",
                d=1,
                charge=1,
                initial=54.4,
                represents="CHEBI:29103")

kecs = rxd.Parameter([ecs],
                     name="k",
                     value=2.5,
                     charge=1,
                     represents="CHEBI:29103")

na = rxd.Species([cyt, mem],
                 name="na",
                 d=1,
                 charge=1,
                 initial=10.0,
                 represents="CHEBI:29101")
Beispiel #19
0
def _addSpecies(self, params):
    from .. import sim

    for label, param in params.items():
        # regions
        if 'regions' not in param:
            print('  Error creating Species %s: "regions" parameter was missing'%(label))
            continue
        if not isinstance(param['regions'], list):
            param['regions'] = [param['regions']]
        try:
            nrnRegions = [self.rxd['regions'][region]['hObj'] for region in param['regions'] if self.rxd['regions'][region]['hObj'] != None]

        except:
           print('  Error creating Species %s: could not find regions %s'%(label, param['regions']))

        # d
        if 'd' not in param:
            param['d'] = 0

        # charge
        if 'charge' not in param:
            param['charge'] = 0

        # initial
        if 'initial' not in param:
            param['initial'] = None
        if isinstance(param['initial'], basestring):  # string-based func
            funcStr = self._replaceRxDStr(param['initial'], constants=True, regions=True, species=False)

            # create final function dynamically from string
            importStr = ' from neuron import crxd as rxd \n from netpyne import sim'
            afterDefStr = 'sim.net.rxd["species"]["%s"]["initialFunc"] = initial' % (label)
            funcStr = 'def initial (node): \n%s \n return %s \n%s' % (importStr, funcStr, afterDefStr) # convert to lambda function
            try:
                exec(funcStr, {'rxd': rxd}, {'sim': sim})
                initial = sim.net.rxd["species"][label]["initialFunc"]
            except:
                print('  Error creating Species %s: cannot evaluate "initial" expression -- "%s"'%(label, param['initial']))
                continue
        else:
            initial = param['initial']

        # ecs boundary condition 
        if 'ecs_boundary_conditions' not in param:
            param['ecs_boundary_conditions'] = None

        # atolscale
        if 'atolscale' not in param:
            param['atolscale'] = 1

        if 'name' not in param:
            name = label
        else:
            name = param['name']

        # call rxd method to create Species
        if nrnRegions: self.rxd['species'][label]['hObj'] = rxd.Species(regions=nrnRegions, 
                                                            d=param['d'], 
                                                            charge=param['charge'], 
                                                            initial=initial, 
                                                            atolscale=param['atolscale'], 
                                                            name=name,
                                                            ecs_boundary_conditions=param['ecs_boundary_conditions'])
        else: self.rxd['species'][label]['hObj'] = None

        print('  Created Species %s'%(label))
Beispiel #20
0
# Where? -- define the extracellular space
ecs = rxd.Extracellular(-Lx / 2.0,
                        -Ly / 2.0,
                        -Lz / 2.0,
                        Lx / 2.0,
                        Ly / 2.0,
                        Lz / 2.0,
                        dx=10,
                        volume_fraction=alpha,
                        tortuosity=tort)

# What? -- define the species
k = rxd.Species(ecs,
                name='k',
                d=2.62,
                charge=1,
                initial=lambda nd: 40
                if nd.x3d**2 + nd.y3d**2 + nd.z3d**2 < r0**2 else 3.5,
                ecs_boundary_conditions=3.5)

na = rxd.Species(ecs,
                 name='na',
                 d=1.78,
                 charge=1,
                 initial=133.574,
                 ecs_boundary_conditions=133.574)

if args.buffer:
    # Additional species are used for a phenomenological model of astrocytic
    # buffering
    kb = 0.0008
Beispiel #21
0
mem = rxd.Region(h.allsec(), name='cell_mem', geometry=rxd.membrane())

# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)


# Who?
def init(ics, ecs):
    return lambda nd: ecs if isinstance(nd, rxd.node.NodeExtracellular
                                        ) else ics


# ions
k = rxd.Species([cyt, mem],
                name='k',
                d=1,
                charge=1,
                initial=54.4,
                represents='CHEBI:29103')

kecs = rxd.Parameter([ecs],
                     name='k',
                     value=2.5,
                     charge=1,
                     represents='CHEBI:29103')

na = rxd.Species([cyt, mem],
                 name='na',
                 d=1,
                 charge=1,
                 initial=10.0,
                 represents='CHEBI:29101')
Beispiel #22
0
'''
print(3)

ecs = rxd.Extracellular(-Lx / 2.0,
                        -Ly / 2.0,
                        -Lz / 2.0,
                        Lx / 2.0,
                        Ly / 2.0,
                        Lz / 2.0,
                        dx=20,
                        volume_fraction=alpha,
                        tortuosity=tort)

k = rxd.Species(ecs,
                name='k',
                d=2.62,
                charge=1,
                initial=1,
                ecs_boundary_conditions=1)

na = rxd.Species(ecs,
                 name='na',
                 d=1.78,
                 charge=1,
                 initial=145,
                 ecs_boundary_conditions=145)

ca = rxd.Species(ecs,
                 name='ca',
                 d=0.08,
                 charge=2,
                 initial=25,
Beispiel #23
0
name = __main__.__file__
if name[-3 :] == '.py':
    name = name[: -3]

h.load_file('stdrun.hoc')

dend = h.Section()
dend.diam = 2
dend.nseg = 101
dend.L = 100
rxd.set_solve_type(dimension=3)
diff_constant = 1

r = rxd.Region(h.allsec(),dx=0.5)
ca = rxd.Species(r, d=diff_constant, initial=lambda node:
                                                 1 if 0.4 < node.x < 0.6 else 0)

h.finitialize()
initial_amount = (numpy.array(ca.nodes.concentration) * numpy.array(ca.nodes.volume)).sum()

for t in [25, 50, 75, 100, 125]:
    h.continuerun(t)
    pyplot.plot([nd.x for nd in ca.nodes], ca.nodes.concentration)

final_amount = (numpy.array(ca.nodes.concentration) * numpy.array(ca.nodes.volume)).sum()

print("initial {}\tfinal {}\tdiff {}".format(initial_amount, final_amount, initial_amount - final_amount))

pyplot.tight_layout()
pyplot.savefig('{0}.png'.format(name))
pyplot.show()
Beispiel #24
0
# somaB.nseg = 11

# Where?
# intracellular
cyt = rxd.Region(h.allsec(), name='cyt', nrn_region='i')

# membrane
mem = rxd.Region(h.allsec(), name='cell_mem', geometry=rxd.membrane())

# extracellular
ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)

# Who?  ions & gates

# intracellular sodium & potassium
na = rxd.Species([cyt, mem], name='na', d=1, charge=1, initial=10)
k = rxd.Species([cyt, mem], name='k', d=1, charge=1, initial=54.4)

# extracellular parameters provide a constant concentration for the Nernst potential and reactions.
kecs = rxd.Parameter(ecs, name='k_ecs', charge=1, value=2.5)
naecs = rxd.Parameter(ecs, name='na_ecs', charge=1, value=140)

# an undistinguished charged ion for the leak current
x = rxd.Species([cyt, mem, ecs], name='x', charge=1)

# define the various species and parameters on the intracellular and extracellular regions
ki, ko, nai, nao, xi, xo = k[cyt], kecs[ecs], na[cyt], naecs[ecs], x[cyt], x[
    ecs]

# the gating states
ngate = rxd.State([cyt, mem], name='ngate', initial=0.24458654944007166)
Beispiel #25
0
        results['species'] = set(my_species)
        results['name'] = sec.hname()
        results['hoc_internal_name'] = sec.hoc_internal_name()
        results['cell'] = sec.cell()

        #all_active_reactions = [r() for r in rxd_module._all_reactions if r() is not None]

    return results


if __name__ == '__main__':
    from pprint import pprint
    from neuron import h, rxd

    soma = h.Section(name='soma')
    soma.insert('hh')
    soma.insert('pas')
    soma.nseg = 3
    iclamp = h.IClamp(soma(0.3))
    gaba = h.ExpSyn(soma(0.7))
    dend = h.Section(name='dend')
    dend.connect(soma)
    cyt = rxd.Region([dend], name='cyt', nrn_region='i')
    er = rxd.Region([dend], name='er')
    na = rxd.Species(cyt, name='na', charge=1)
    ca = rxd.Species([cyt, er], name='ca', charge=2)
    h.finitialize(-65)
    pprint(psection(soma))
    print('\n')
    pprint(psection(dend))
Beispiel #26
0
from neuron import h, crxd as rxd
h.load_file('stdrun.hoc')
soma = h.Section(name='soma')
r = rxd.Region([soma])
soma.nseg = 5
c = rxd.Species(r, initial=1.0)
assert (len(c.nodes) == 5)
soma.nseg = 3
assert (len(c.nodes) == 3)
soma.nseg = 7
assert (len(c[r].nodes) == 7)
h.tstop = 100
h.run()
# the extracellular space
ecs = rxd.Extracellular(-55,
                        -55,
                        -55,
                        55,
                        55,
                        55,
                        dx=10,
                        volume_fraction=0.2,
                        tortuosity=1.6)

# Who?
x = rxd.Species(
    [cyt, org, cyt_org_membrane, cyt_ecs_membrane, ecs],
    name="x",
    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))
Beispiel #28
0
from neuron import h, crxd as rxd
from matplotlib import pyplot

h.load_file('stdrun.hoc')

cell = h.Section(name='cell')
r = rxd.Region([cell])


def Declare_Parameters(**kwargs):
    '''helper function enabling clean declaration of parameters in top namespace'''
    for key, value in kwargs.items():
        globals()[key] = rxd.Parameter(r, name=key, initial=value)


def Declare_Species(**kwargs):
    '''helper function enabling clean declaration of species in top namespace'''
    for key, value in kwargs.items():
        globals()[key] = rxd.Species(r, name=key, initial=value)


k3 = rxd.Parameter(r, name='k3', initial=1.2)
k4 = rxd.Parameter(r, name='k4', initial=0.6)

P2 = rxd.Species(r, name='P2', initial=0.0614368)
T2 = rxd.Species(r, name='T2', initial=0.0145428)
C = rxd.Species(r, name='C', initial=0.207614)

h.finitialize(-65)
h.continuerun(72)