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
cell1.pt3dclear()
cell1.pt3dadd(-20, 0, 0, 10)
cell1.pt3dadd(-10, 0, 0, 10)
cell1.nseg = 11

# create cell2 where `x` will be pumped in and accumulate
cell2 = h.Section("cell2")
cell2.pt3dclear()
cell2.pt3dadd(10, 0, 0, 10)
cell2.pt3dadd(20, 0, 0, 10)
cell2.nseg = 11
# Where?
# the intracellular spaces
cyt = rxd.Region(
    h.allsec(),
    name="cyt",
    nrn_region="i",
    geometry=rxd.FractionalVolume(0.9, surface_fraction=1.0),
)

org = rxd.Region(h.allsec(), name="org", geometry=rxd.FractionalVolume(0.1))

cyt_org_membrane = rxd.Region(h.allsec(),
                              name="mem",
                              geometry=rxd.ScalableBorder(
                                  pi / 2.0, on_cell_surface=False))
cyt_ecs_membrane = rxd.Region(h.allsec(),
                              name="cell_mem",
                              geometry=rxd.membrane())

# the extracellular space
ecs = rxd.Extracellular(-55,
Beispiel #3
0
ip3Diff = 0.283
#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), membrane=cyt_er_membrane, custom_dynamics=True)
leak = rxd.MultiCompartmentReaction(ca[er]!=ca[cyt], gleak, gleak, membrane=cyt_er_membrane)
Beispiel #4
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 #5
0
Datei: hh.py Projekt: vogdb/nrn
somaA.nseg = 11

somaB = h.Section('somaB')
somaB.pt3dclear()
somaB.pt3dadd(60, 0, 0, 1)
somaB.pt3dadd(90, 0, 0, 1)
somaB.nseg = 11

# mod version
somaB.insert('hh')

# rxd version

# 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=100)


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


# ions
Beispiel #6
0
import __main__

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()
Beispiel #7
0
gleak = 6.020
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000.0

rescale_v = 1000 / -65.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] * rescale_v * v * ca[cyt] / (ip3[cyt] + kip3) / (
Beispiel #8
0
def _addRegions(self, params):
    from .. import sim

    for label, param in params.items():

        if 'extracellular' in param and param['extracellular'] == True:
            self._addExtracellularRegion(label, param)
            continue

        # cells
        if 'cells' not in param:
            param['cells'] = ['all']

        # secs
        if 'secs' not in param:
            param['secs'] = ['all']
        if not isinstance(param['secs'], list):
            param['secs'] = [param['secs']]

        # nrn_region
        if 'nrn_region' not in param:
            param['nrn_region'] = None

        # geomery
        if 'geometry' not in param:
            param['geometry'] = None
        geometry = param['geometry']
        # import IPython; IPython.embed()
        if isinstance(geometry, dict):
            try:
                if 'args' in geometry:
                    geometry['hObj'] = getattr(rxd, param['geometry']['class'])(**param['geometry']['args'])
                    geometry = geometry['hObj']
            except:
                print('  Error creating %s Region geometry using %s class'%(label, param['geometry']['class']))
        elif isinstance(param['geometry'], str):
            geometry = getattr(rxd, param['geometry'])()

            # List of allowed geometry classes: 
            # class neuron.rxd.geometry.FixedCrossSection(cross_area, surface_area=0) 
            # class neuron.rxd.geometry.FractionalVolume(volume_fraction=1, surface_fraction=0, neighbor_areas_fraction=None) 
            # class neuron.rxd.geometry.FixedPerimeter(perimeter, on_cell_surface=False) 
            # class neuron.rxd.geometry.Shell(lo=None, hi=None) 
        
        # geomery
        if 'dimension' not in param:
            param['dimension'] = None

        # geomery
        if 'dx' not in param:
            param['dx'] = None

        # get list of h.Sections() based on cells and secs
        if 'all' in param['cells'] and 'all' in param['secs']:
            nrnSecs = list(sim.h.allsec())
        else:
            cells = sim.getCellsList(param['cells'])
            nrnSecs = []
            for cell in cells:
                for secName,sec in cell.secs.items():
                    if 'all' in param['secs'] or secName in param['secs']:
                        nrnSecs.append(sec['hObj'])

        # call rxd method to create Region
        if nrnSecs: self.rxd['regions'][label]['hObj'] = rxd.Region(secs=nrnSecs,
                                                                   nrn_region=param['nrn_region'],
                                                                   geometry=geometry,
                                                                   dimension=param['dimension'],
                                                                   dx=param['dx'],
                                                                   name=label)
        else: self.rxd['regions'][label]['hObj'] = None

        print('  Created Region %s'%(label))
Beispiel #9
0
Datei: hh.py Projekt: pramodk/nrn
somaA.nseg = 11

somaB = h.Section("somaB")
somaB.pt3dclear()
somaB.pt3dadd(60, 0, 0, 1)
somaB.pt3dadd(90, 0, 0, 1)
somaB.nseg = 11

# mod version
somaB.insert("hh")

# rxd version

# 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=100)


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


# ions
Beispiel #10
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 #11
0
from matplotlib import pyplot
import numpy
import __main__

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

diff_constant = 1

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

h.finitialize()

for t in [25, 50, 75, 100, 125]:
    h.continuerun(t)
    pyplot.plot([seg.x for seg in dend], ca.states)

pyplot.tight_layout()
pyplot.savefig('{0}.png'.format(name))
Beispiel #12
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()
Beispiel #13
0
kserca = 0.1
kip3 = 0.15
kact = 0.4
ip3rtau = 2000.0

rescale_v = 1000 / -65.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]
Beispiel #14
0
cell1 = h.Section('cell1')
cell1.pt3dclear()
cell1.pt3dadd(-20, 0, 0, 10)
cell1.pt3dadd(-10, 0, 0, 10)
cell1.nseg = 11

# create cell2 where `x` will be pumped in and accumulate
cell2 = h.Section('cell2')
cell2.pt3dclear()
cell2.pt3dadd(10, 0, 0, 10)
cell2.pt3dadd(20, 0, 0, 10)
cell2.nseg = 11
# Where?
# the intracellular spaces
cyt = rxd.Region(h.allsec(),
                 name='cyt',
                 nrn_region='i',
                 geometry=rxd.FractionalVolume(0.9, surface_fraction=1.0))

org = rxd.Region(h.allsec(), name='org', geometry=rxd.FractionalVolume(0.1))

cyt_org_membrane = rxd.Region(h.allsec(),
                              name='mem',
                              geometry=rxd.ScalableBorder(
                                  pi / 2.0, on_cell_surface=False))
cyt_ecs_membrane = rxd.Region(h.allsec(),
                              name='cell_mem',
                              geometry=rxd.membrane())

# the extracellular space
ecs = rxd.Extracellular(-55,
                        -55,
Beispiel #15
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 #16
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]