Exemple #1
0
def scalar_bistable(rxdstr):
    if rxdstr == 'rxd':
        from neuron import rxd
    else:
        from neuron import crxd as rxd
    h.load_file('stdrun.hoc')
    s = h.Section(name='s')
    s.nseg = 101
    cyt = rxd.Region(h.allsec())
    c = rxd.Species(cyt,
                    name='c',
                    initial=lambda node: 1 if 0.4 < node.x < 0.6 else 0,
                    d=1)
    r = rxd.Rate(c, -c * (1 - c) * (0.3 - c))
    h.finitialize()
    h.run()

    #check the results
    result = h.Vector(c.nodes.concentration)
    cmpV = h.Vector(scalar_bistable_data[rxdstr])
    cmpV.sub(result)
    cmpV.abs()
    if cmpV.sum() < 1e-6:
        sys.exit(0)
    sys.exit(-1)
Exemple #2
0
def do_sim(simulation, sim_control=None):
    """setup a simulation"""
    global na, cell

    # hide the simulation control panel, if there was one
    if sim_control:
        sim_control.unmap()

    cell = FleidervishNeuron()

    # add sodium diffusion everywhere
    allsec = rxd.Region(h.allsec(), nrn_region='i')
    na = rxd.Species(allsec, d=0.6, name='na', charge=1)

    # create a current clamp and add it to the cell
    cell.ic = h.IClamp(cell.soma(0.5))
    cell.ic.dur = 3       # ms
    cell.ic.amp = 1.5     # nA

    # setup graphs needed by both simulations
    concentration_graph = h.Graph(False)
    concentration_graph.size(0, 3000, 4, 4.4)
    voltage_graph = h.Graph(False)
    voltage_graph.size(0, 3000, -90, 60)
    h.graphList[0].append(voltage_graph)
    h.graphList[1].append(concentration_graph)

    # pop up the run control
    h.nrncontrolmenu()

    # call the funciton which actually sets up the specific simulation
    simulation(cell, voltage_graph, concentration_graph)
Exemple #3
0
    def load(self, secs, dx_3d_size, rxds=None):
        """
        Must be called after all secs are set.
        :param secs:
            List of sections (real HOC objects)
        :param dx_3d_size:
            If 3D geometry is True, define the size of the single compartment size.
        :param rxds:
            dictionary which contains previously added RxDTool objects
        """
        self.cyt = rxd.Region(secs=secs, nrn_region='i', dx=dx_3d_size)

        # 1/nM = 1 × 1/10^-9M = 10^3/10^3 × 1/10^-9M = 1000/(10^3×10^-9M) = 1000/10^-6M = 1000/uM

        # Ca2+
        self.ca = rxd.Species(regions=self.cyt,
                              initial=75 * nM,
                              name='ca',
                              charge=2,
                              d=174.3 / sec)

        # Calbindin buffer
        self.calbindin = rxd.Species(regions=self.cyt,
                                     initial=159982 * nM,
                                     name='calbindin',
                                     charge=0,
                                     d=9.3 / sec)
        self.calbindin_ca = rxd.Species(regions=self.cyt,
                                        initial=18 * nM,
                                        name='calbindin_ca',
                                        charge=0,
                                        d=9.3 / sec)
        self.calbindin_ca_reaction = rxd.Reaction(self.ca + self.calbindin,
                                                  self.calbindin_ca,
                                                  0.028e-3 / (nM * ms),
                                                  19.6 / (nM * ms))

        # Calmodulin buffer
        self.calmodulin = rxd.Species(regions=self.cyt,
                                      initial=12600 * nM,
                                      name='calmodulin',
                                      charge=0,
                                      d=4 / sec)
        self.calmodulin_ca2 = rxd.Species(regions=self.cyt,
                                          initial=200 * nM,
                                          name='calmodulin_ca2',
                                          charge=0,
                                          d=4 / sec)
        self.calmodulin_ca4 = rxd.Species(regions=self.cyt,
                                          initial=3 * nM,
                                          name='calmodulin_ca4',
                                          charge=0,
                                          d=4 / sec)
        self.calmodulin_ca2_reaction = rxd.Reaction(
            2 * self.ca + self.calmodulin, self.calmodulin_ca2,
            6e-6 / (nM * ms), 9.1e-3 / (nM * ms))
        self.calmodulin_ca4_reaction = rxd.Reaction(
            2 * self.ca + self.calmodulin_ca2, self.calmodulin_ca4,
            0.1e-3 / (nM * ms), 1000e-3 / (nM * ms))
Exemple #4
0
def basicRxD3D():
    from neuron import h, rxd
    s = h.Section(name='s')
    s.L = s.diam = 1
    cyt = rxd.Region([s])
    ca = rxd.Species(cyt)
    rxd.set_solve_type(dimension=3)
    h.finitialize(-65)
    h.fadvance()
    return 1
Exemple #5
0
lncrec, ltimevec, lidvec = [], [], []  # spike recorders
lX, lY, lZ, lctyID = [0], [0], [0], [
    E2
]  # E2 pyramidal cell - nothing particular about the E2
timevec, idvec = h.Vector(), h.Vector()
ncrec = h.NetCon(ce[-1].soma(0.5)._ref_v, None, sec=ce[-1].soma)
ncrec.record(timevec, idvec, 0)
ncrec.threshold = 0  # 10 mV is default, lower it
ltimevec.append(timevec)
lidvec.append(idvec)
lncrec.append(ncrec)  # record the spikes at soma

rxd.options.use_reaction_contribution_to_jacobian = False  # faster (checked a few days before 10/16/13)
fc, fe = 0.83, 0.17  # cytoplasmic, er volume fractions
cyt = rxd.Region(rxdsec,
                 nrn_region='i',
                 geometry=rxd.FractionalVolume(fc, surface_fraction=1))
er = rxd.Region(rxdsec, geometry=rxd.FractionalVolume(fe))
cyt_er_membrane = rxd.Region(rxdsec, geometry=rxd.ScalableBorder(1))
caDiff = 0.233
ca = rxd.Species([cyt, er],
                 d=caDiff,
                 name='ca',
                 charge=2,
                 initial=dconf['cacytinit'])
caexinit = dconf['caexinit']
caextrude = rxd.Rate(ca, (caexinit - ca[cyt]) / taurcada,
                     regions=cyt,
                     membrane_flux=False)

ip3 = rxd.Species(cyt, d=0.283, name='ip3', initial=0.0)
Exemple #6
0
# nai = 10 nao = 147
# ki = 125 ko = 2.9

# In[6]:


def concentration(i, o):
    return lambda nd: i if isinstance(nd, rxd.node.Node1D) else o


# In[7]:

# REGIONS------------------------------------------------------------------------------------------------------------------------

# intracellular/extracellular regions
cyt = rxd.Region(soma, name="cyt", nrn_region="i")
mem = rxd.Region(soma, name="cell_mem", geometry=rxd.membrane())
gcyt = rxd.Region(glia, name="cyt", nrn_region="i")
gmem = rxd.Region(glia, name="cell_mem", geometry=rxd.membrane())
dx = vo**(1.0 / 3.0)
ecs = rxd.Extracellular(-2 * dx,
                        -2 * dx,
                        -2 * dx,
                        2 * dx,
                        2 * dx,
                        2 * dx,
                        dx=dx)
# ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)
# SPECIES/PARAMETERS------------------------------------------------------------------------------------------------------------------------

# intracellular/extracellular species (Na+, K+, Cl-)
Exemple #7
0
from neuron import h, rxd
h.load_file("stdrun.hoc")

sec = h.Section(name="sec")
sec.L = 10
sec.nseg = 11
sec.diam = 5
rxd.set_solve_type(dimension=3)

cyt = rxd.Region(h.allsec(), name="cyt", nrn_region="i")
ip3 = rxd.Species(cyt,
                  name="ip3",
                  initial=lambda nd: 1000 if nd.segment == sec(0.3) else 0)


def callbackfun():
    return 1000


for nd in ip3.nodes(sec(0.1)):
    nd.include_flux(1000)

for nd in ip3.nodes(sec(0.5)):
    nd.include_flux(callbackfun)

for nd in ip3.nodes(sec(0.9)):
    nd.include_flux(sec(0.3)._ref_ip3i)

h.finitialize(-70)
h.continuerun(10)
import numpy
gip3r = 12040
gserca = 0.3913
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000.0

#These parameters where missing in the tutorial so arbitrary values were chosen
#any resemblance to experimental values is purely coincidental.
fc = 0.7
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] * 1000. * ca[cyt] / (ip3[cyt] + kip3) / (1000. * ca[cyt] +
Exemple #9
0
gserca = 0.3913
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000.0

# These parameters where missing in the tutorial so arbitrary values were chosen
# any resemblance to experimental values is purely coincidental.
fc = 0.7
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.0))

cyt_er_membrane = rxd.Region(h.allsec(),
                             name="mem",
                             geometry=rxd.DistributedBoundary(1))

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] * 1000.0 * ca[cyt] / (ip3[cyt] + kip3) / (1000.0 * ca[cyt] +
Exemple #10
0
#cp model_nrn_altered_template.py model_nrn_testPKA.py
#Based on Model C in https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2719611/
from neuron import h, rxd
from pylab import *
from matplotlib import pyplot
import scipy.io
import time
import re
import mytools

h.load_file('stdrun.hoc')

dend = h.Section(name='dend')
dend.L = 1
dend.diam = 0.79788
cyt = rxd.Region([dend], name='cyt', nrn_region='i')

mesh_input_file = open('mesh_general.out', 'r')
mesh_firstline = mesh_input_file.readline()
mesh_secondline = mesh_input_file.readline()
mesh_values = mesh_secondline.split()
my_volume = float(mesh_values[-2]) * 1e-15  #litres
mesh_input_file.close()

Duration = 3000
tolerance = 1e-6
cAMP_input_onset = 800
cAMP_input_N = 100
cAMP_input_freq = 100
cAMP_input_dur = 0.005
cAMP_input_flux = 600.0
Exemple #11
0
import matplotlib.pyplot as plt
from neuron import h, rxd
from neuron.units import mV, ms
h.load_file('stdrun.hoc')

soma = h.Section(name='soma')
soma.diam = soma.L = 10

ecs = rxd.Extracellular(-20, -20, -20, 20, 20, 20, dx=10)
cyt = rxd.Region([soma], name='cyt', nrn_region='i')
mem = rxd.Region([soma], name='mem', geometry=rxd.membrane())

ca = rxd.Species([cyt, ecs],
                 d=1,  # with single section and nseg=1 only affects extracellular
                 name='ca',
                 charge=2,
                 initial=lambda node: 1e-3 if node.region==cyt else 0)

e = 1.60217662e-19
scale = 1e-14 / e

# rate constant is in terms of molecules/um2 ms
ca_pump = rxd.MultiCompartmentReaction(ca[cyt], ca[ecs], ca[cyt] * scale,
                                       custom_dynamics=True,
                                       membrane_flux=True,
                                       membrane=mem)

t = h.Vector().record(h._ref_t)
ca_vec = h.Vector().record(soma(0.5)._ref_cai)
ca_vec2 = h.Vector().record(ca[ecs].node_by_location(5, 0, 0)._ref_value)
v = h.Vector().record(soma(0.5)._ref_v)
Exemple #12
0
# nai = 10 nao = 147
# ki = 125 ko = 2.9

# In[6]:


def concentration(i, o):
    return lambda nd: i if isinstance(nd, rxd.node.Node1D) else o


# In[7]:

#REGIONS------------------------------------------------------------------------------------------------------------------------

#intracellular/extracellular regions
cyt = rxd.Region(soma, name='cyt', nrn_region='i')
mem = rxd.Region(soma, name='cell_mem', geometry=rxd.membrane())
gcyt = rxd.Region(glia, name='cyt', nrn_region='i')
gmem = rxd.Region(glia, name='cell_mem', geometry=rxd.membrane())
dx = vo**(1.0 / 3.0)
ecs = rxd.Extracellular(-2 * dx,
                        -2 * dx,
                        -2 * dx,
                        2 * dx,
                        2 * dx,
                        2 * dx,
                        dx=dx)
#ecs = rxd.Extracellular(-100, -100, -100, 100, 100, 100, dx=33)
#SPECIES/PARAMETERS------------------------------------------------------------------------------------------------------------------------

#intracellular/extracellular species (Na+, K+, Cl-)
Exemple #13
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))
Exemple #14
0
import matplotlib.pyplot as plt
from neuron import h, rxd
from neuron.units import mV, ms
h.load_file('stdrun.hoc')

soma = h.Section(name='soma')
soma.diam = soma.L = 10

# the geometry of the ecs doesn't matter in the constant case
ecs = rxd.Region([soma], name='ecs', nrn_region='o', geometry=rxd.Shell(1, 2))
cyt = rxd.Region([soma], name='cyt', nrn_region='i')
mem = rxd.Region([soma], name='mem', geometry=rxd.membrane())

cao = rxd.Parameter(ecs, charge=2)

ca = rxd.Species(
    [cyt],
    d=1,  # with single section and nseg=1 only affects extracellular
    name='ca',
    charge=2,
    initial=lambda node: 1e-3 if node.region == cyt else 0)

e = 1.60217662e-19
scale = 1e-14 / e

# rate constant is in terms of molecules/um2 ms
ca_pump = rxd.MultiCompartmentReaction(ca[cyt],
                                       cao[ecs],
                                       ca[cyt] * scale,
                                       custom_dynamics=True,
                                       membrane_flux=True,
from neuron import h, rxd

h.load_file("stdrun.hoc")

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

Ca = rxd.Species(r, name="ca", charge=2, initial=60e-3)

reaction_decay = rxd.Reaction(Ca, 0 * Ca, 1e-8)
tvec = h.Vector().record(h._ref_t)
cavec = h.Vector().record(Ca.nodes[0]._ref_concentration)
h.finitialize(-70)
h.continuerun(10)

if __name__ == "__main__":
    from matplotlib import pyplot

    pyplot.plot(tvec, cavec)
    pyplot.show()
Exemple #16
0

cell_1 = Cell()
cell_2 = Cell()
ecs = rxd.Extracellular(-55,
                        -55,
                        -55,
                        55,
                        55,
                        55,
                        dx=10,
                        volume_fraction=0.2,
                        tortuosity=1.6)

soma_cell_1 = rxd.Region([cell_1.soma],
                         nrn_region="i",
                         geometry=rxd.Shell(0.8, 1))
soma_cell_2 = rxd.Region([cell_2.soma],
                         nrn_region="i",
                         geometry=rxd.Shell(0.8, 1))
species_x = rxd.Species(
    [ecs, soma_cell_1, soma_cell_2],
    name="species_x",
    d=1,
    charge=1,
    initial=1,
    ecs_boundary_conditions=0,
)
Species_y = rxd.Species(
    [soma_cell_1, ecs],
    name="species_y",
Exemple #17
0
                                     name=key,
                                     initial=kwargs[key],
                                     atolscale=1 * nM)


def recorder(ptr):
    """return a vector that records the pointer"""
    vec = h.Vector()
    vec.record(ptr)
    return vec


rxd.set_solve_type(dimension=3)
cell = h.Section(name="cell")
cell.diam = cell.L = 5
r = rxd.Region(h.allsec())
rxd.nthread(4)

declare_parameters(
    vsP=1.1 * nM / hour,
    vmP=1.0 * nM / hour,
    KmP=0.2 * nM,
    KIP=1.0 * nM,
    ksP=0.9 / hour,
    vdP=2.2 * nM / hour,
    KdP=0.2 * nM,
    vsT=1.0 * nM / hour,
    vmT=0.7 * nM / hour,
    KmT=0.2 * nM,
    KIT=1.0 * nM,
    ksT=0.9 / hour,
Exemple #18
0
#!/usr/bin/env python
# coding: utf-8

# In[1]:

from neuron import h, rxd
from matplotlib import pyplot
h.load_file('stdrun.hoc')

# In[2]:

axon = h.Section(name='s1')
axon_terminal = h.Section(name='s')
axon.connect(axon_terminal)

axon_terminal_region = rxd.Region([axon_terminal], nrn_region='i')
synaptic_cleft = rxd.Region([axon_terminal], nrn_region='o')
terminal_membrane = rxd.Region(h.allsec(), geometry=rxd.DistributedBoundary(1))

# In[3]:

VA = rxd.Species([axon_terminal_region], name="VA", initial=10, charge=1)
T = rxd.Species([synaptic_cleft], name="T", initial=10, charge=1)

# In[4]:

# if you comment the exocytosis line below, the error will go away
exocytosis = rxd.MultiCompartmentReaction(VA[axon_terminal_region],
                                          T[synaptic_cleft],
                                          500,
                                          0,
Exemple #19
0
from neuron import h, rxd
from matplotlib import pyplot
h.load_file('stdrun.hoc')

from neuron.units import mM, ms
sim_time = 100

axon_terminal = h.Section(name="axon_terminal")
#synaptic_cleft = rxd.Region([axon_terminal], nrn_region='o')
axon_terminal_region = rxd.Region([axon_terminal], nrn_region='i')

ca_intra = rxd.Species(axon_terminal_region,
                       name="ca",
                       charge=2,
                       d=0,
                       initial=5e-4,
                       atolscale=1e-6)
F = rxd.Species(axon_terminal_region, name="F", initial=0.001)
FA = rxd.Species(axon_terminal_region, name="FA", initial=0)

kb = rxd.Parameter(axon_terminal_region, name="kb", value=1e16 / (mM**4 * ms))
ku = rxd.Parameter(axon_terminal_region, name="ku", value=0.1 / ms)

myreaction = rxd.Reaction(F + 4 * ca_intra, FA, kb,
                          ku)  #, regions=axon_terminal_region)

tvec = h.Vector().record(h._ref_t)
Fvec = h.Vector().record(F.nodes._ref_concentration)
FAvec = h.Vector().record(FA.nodes._ref_concentration)
h.finitialize(-65)
h.continuerun(10)
from neuron import h, rxd, gui
from neuron.rxd 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()
Exemple #21
0
gip3r = 12040
gserca = 0.3913
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000.0

#These parameters where missing in the tutorial so arbitrary values were chosen
#any resemblance to experimental values is purely coincidental.
fc = 0.7
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.DistributedBoundary(1))

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] * 1000. * ca[cyt] / (ip3[cyt] + kip3) / (1000. * ca[cyt] +
                                                         kact)
Exemple #22
0
    def __init__(self, x, y, z, rec=False):
        self.x = x
        self.y = y
        self.z = z

        self.soma = h.Section(name="soma", cell=self)
        # add 3D points to locate the neuron in the ECS
        self.soma.pt3dadd(x, y, z + somaR, 2.0 * somaR)
        self.soma.pt3dadd(x, y, z - somaR, 2.0 * somaR)

        # Where? -- define the intracellular space and membrane
        self.cyt = rxd.Region(self.soma, name="cyt", nrn_region="i")
        self.mem = rxd.Region(self.soma, name="mem", geometry=rxd.membrane())
        cell = [self.cyt, self.mem]

        # Who? -- the relevant ions and gates
        self.k = rxd.Species(cell, name="k", d=2.62, charge=1, initial=125)
        self.na = rxd.Species(cell, name="na", d=1.78, charge=1, initial=10)
        self.n = rxd.State(cell, name="n", initial=0.25512)
        self.ki, self.nai = self.k[self.cyt], self.na[self.cyt]

        # What? -- gating variables and ion currents
        self.n_gate = rxd.Rate(self.n, phin * (ninf - self.n) / taun)

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

        # Persistent Na current
        self.nap_current = rxd.MultiCompartmentReaction(
            self.nai,
            nao,
            gnap * nap_minf * nap_hinf * (v - ena),
            mass_action=False,
            membrane=self.mem,
            membrane_flux=True,
        )
        # Na current
        self.na_current = rxd.MultiCompartmentReaction(
            self.nai,
            nao,
            gna * minf**3 * (1.0 - self.n) * (v - ena),
            mass_action=False,
            membrane=self.mem,
            membrane_flux=True,
        )
        # K current
        self.k_current = rxd.MultiCompartmentReaction(
            self.ki,
            ko,
            gk * self.n**4 * (v - ek),
            mass_action=False,
            membrane=self.mem,
            membrane_flux=True,
        )
        # K leak
        self.k_leak = rxd.MultiCompartmentReaction(
            self.ki,
            ko,
            gl * (v - ek),
            mass_action=False,
            membrane=self.mem,
            membrane_flux=True,
        )
        # passive leak
        self.soma.insert("pas")
        self.soma(0.5).pas.g = pas_gl
        self.soma(0.5).pas.e = pas_el

        if rec:  # record membrane potential (shown in figure 1C)
            self.somaV = h.Vector()
            self.somaV.record(self.soma(0.5)._ref_v, rec)
except ImportError as e:
    print("[INFO ] Failed to import neuron. Quitting ...")
    quit()

import numpy
from matplotlib import pyplot
import time

# needed for standard run system
h.load_file('stdrun.hoc')

dend = h.Section()
dend.nseg = 501

# WHERE the dynamics will take place
where = rxd.Region(h.allsec())

# WHO the actors are
u = rxd.Species(where, d=1, initial=0)

# HOW they act
bistable_reaction = rxd.Rate(u, -u * (1 - u) * (0.3 - u))

# initial conditions
h.finitialize()
for node in u.nodes:
    if node.x < .2: node.concentration = 1


def plot_it(color='k'):
    y = u.nodes.concentration
Exemple #24
0
def wave_search(size, size_segments, time_period, times, au, Du):
    # needed for standard run system
    h.load_file('stdrun.hoc')

    global dend

    dend = h.Section()
    dend.L = size
    dend.nseg = size_segments

    # WHERE the dynamics will take place
    where = rxd.Region(h.allsec())

    # WHO the actors are
    global u
    global z
    global v

    u = rxd.Species(where, d=Du, initial=0.5)  # activator
    z = rxd.Species(where, d=20, initial=0.5)  # inhibitor
    v = rxd.Species(where, d=0, initial=(1 / dend.L) * 30)  # modulator

    # HOW they act

    a = au
    b = -0.4
    c = 0.6
    d = -0.8
    u0 = 0.5
    z0 = 0.5
    av = 5.0
    kz = 0.001

    bistable_reaction1 = rxd.Rate(u, (a * (u - u0) + b * (z - z0) - av *
                                      (u - u0)**3) * (v**-2))
    bistable_reaction2 = rxd.Rate(z, (c * (u - u0) + d * (z - z0)) * (v**-2))

    # initial conditions
    h.finitialize()
    for node in u.nodes:
        if node.x < .2: node.concentration = 0.6
        if node.x > .8: node.concentration = 0.6
    for node in z.nodes:
        if node.x < .2: node.concentration = 0.6
        if node.x > .8: node.concentration = 0.6

    # Setting up time frame
    global u_timespace

    T_d = times
    T = time_period
    u_timespace = []

    for i in np.arange(0, T_d):
        h.continuerun(i * T)
        u_timespace.append(u.nodes.concentration)

    # activator FFT source files
    u_fft_y = u.nodes.concentration
    u_fft_y = u_fft_y - np.mean(u_fft_y)
    u_fft_x = u.nodes.x
    global u_fft_x_norm
    u_fft_x_norm = dend.L * np.array(u_fft_x)

    # inhibitor FFT source files
    z_fft_y = z.nodes.concentration
    z_fft_y = z_fft_y - np.mean(z_fft_y)
    z_fft_x = z.nodes.x
    z_fft_x_norm = dend.L * np.array(u_fft_x)

    # activator FFT
    Y1 = np.fft.fft(u_fft_y)
    N = len(Y1) / 2 + 1
    dt = dend.L / dend.nseg
    fa = 1.0 / dt
    X = np.linspace(0, fa / 2, N, endpoint=True)

    # inhibitor FFT
    Y2 = np.fft.fft(z_fft_y)
    X2 = np.linspace(0, fa / 2, N, endpoint=True)
    #
    # if ((np.amax(Y1) - np.amin(Y1) < .01) or (np.amax(Y2) - np.amin(Y2) < .01)):
    #     return 0

    if (len(X) == len(2.0 * np.abs(Y1[:N] / N))):
        u_maxx = (np.argmax(2.0 * np.abs(Y1[:N] / N)))
        wavelen = np.around(1 / X[u_maxx])

    plot_it(time_period, times, u_timespace)
    plt.savefig('results/plots/{0}_{1}_{2}_{3}_{4}_{5}.png'.format(
        size, size_segments, time_period, times, au, Du))

    return wavelen
Exemple #25
0
from neuron import h, rxd
from neuron.units import mV, ms

h.load_file("stdrun.hoc")

soma = h.Section(name="soma")
soma.diam = soma.L = 10

# the geometry of the ecs doesn't matter in the constant case
ecs = rxd.Region([soma], name="ecs", nrn_region="o", geometry=rxd.Shell(1, 2))
cyt = rxd.Region([soma], name="cyt", nrn_region="i")
mem = rxd.Region([soma], name="mem", geometry=rxd.membrane())

cao = rxd.Parameter(ecs, charge=2)

ca = rxd.Species(
    [cyt],
    d=1,  # with single section and nseg=1 only affects extracellular
    name="ca",
    charge=2,
    initial=lambda node: 1e-3 if node.region == cyt else 0,
)

e = 1.60217662e-19
scale = 1e-14 / e

# rate constant is in terms of molecules/um2 ms
ca_pump = rxd.MultiCompartmentReaction(
    ca[cyt],
    cao[ecs],
    ca[cyt] * scale,
Exemple #26
0
gserca = 0.3913
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000.0

# These parameters where missing in the tutorial so arbitrary values were chosen
# any resemblance to experimental values is purely coincidental.
fc = 0.7
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.0))

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]
Exemple #27
0
#ip3Diff = 0
cac_init = 1.e-4
ip3_init = 0.1
gip3r = 12040
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),
gserca = 0.3913
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4

sec = h.Section(name='sec')
sec.L = 101
sec.diam = 1
# By chunking the neuron into a large number of segments
# we increase the resolution of the output at the expense of processing power.
sec.nseg = 101

# Where
cyt = rxd.Region(h.allsec(),
                 nrn_region='i',
                 geometry=rxd.FractionalVolume(0.8, surface_fraction=1))
er = rxd.Region(h.allsec(), geometry=rxd.FractionalVolume(0.2))
cyt_er_membrane = rxd.Region(h.allsec(), geometry=rxd.DistributedBoundary(1))

# What
ca = rxd.Species(regions=[cyt, er],
                 d=0.08,
                 name='ca',
                 charge=2,
                 initial=1e-4,
                 atolscale=1e-6)
ip3 = rxd.Species(regions=cyt, d=1.41, initial=0.1)

# What: ??
ip3r_gate_stage = rxd.State(cyt_er_membrane, initial=0.8)