def trivial_ecs(self, scale): from neuron import h, crxd as rxd import numpy import warnings warnings.simplefilter("ignore", UserWarning) h.load_file('stdrun.hoc') tstop = 10 if scale: #variable step case h.CVode().active(True) h.CVode().event(tstop) else: #fixed step case h.dt = 0.1 sec = h.Section() #NEURON requires at least 1 section # 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=1.6) # define the extracellular species k_rxd = rxd.Species(extracellular, name='k', d=2.62, charge=1, atolscale=scale, 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) # 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) h.finitialize() h.continuerun(tstop) #run the simulation # compare with previous solution ecs_vec.sub(h.Vector(trivial_ecs_data[scale])) ecs_vec.abs() if ecs_vec.sum() > 1e-9: return -1 return 0
# 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-) na = rxd.Species([cyt, mem, ecs], name="na", d=1, charge=1, initial=concentration(15.5, 161.5)) k = rxd.Species([cyt, mem, ecs], name="k", d=1,
from neuron import h, rxd from matplotlib import pyplot from math import pi h.load_file('stdrun.hoc') h.CVode().active(True) sec = h.Section() # 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([ecs], name='x', d=0.0, charge=1, initial=0) def callbackfun(): return 1000 x[ecs].node_by_location(-20, 0, 0).include_flux(1000) x[ecs].node_by_location(0, 0, 0).include_flux(callbackfun) x[ecs].node_by_location(20, 0, 0).include_flux(sec(0.5)._ref_v)
pas_gl = 0.3 pas_el = -70 # Simulation parameters Lx, Ly, Lz = 500, 500, 100 # size of the extracellular space mu m^3 Ncell = 2 # number of neurons somaR = 40 # Extracellular rxd # 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=0.2, tortuosity=1.6, ) # Who? -- 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 < 50**2 else 3.5, )
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)