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)
(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() s.variable('cai') #s.scale(-70, -50) s.scale(0, 2e-3)
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) # action of IP3 receptor Kip3 = 0.13 Kact = 0.4 minf = ip3[cyt] * 1000. * ca[cyt] / (ip3[cyt] + Kip3) / (1000. * ca[cyt] + Kact) ip3r_gate_state = rxd.State(cyt_er_membrane, initial=0.8) h_gate = ip3r_gate_state[cyt_er_membrane] k = dconf['gip3'] * (minf * h_gate)**3 ip3r = rxd.MultiCompartmentReaction(ca[er] <> ca[cyt], k, k, membrane=cyt_er_membrane)
ecl = 26.64 * log(cli / clo) # ^^^ p = p_max / (1.0 + exp((20.0 - oa_bath * alpha) / 3)) pump = (p / (1.0 + exp((25.0 - nai) / 3))) * (1.0 / (1.0 + exp(3.5 - ko))) gliapump = ((1.0 / 3.0) * (p / (1.0 + exp( (25.0 - gnai) / 3.0))) * (1.0 / (1.0 + exp(3.5 - ko)))) g_glia = g_gliamax / (1.0 + exp(-oa_bath * alpha - 2.5) / 0.2) glia12 = g_glia / 1.0 + exp((18.0 - ko) / 2.5) # RATES-------------------------------------------------------------------------------------------------------------------------- # m_gate = rxd.Rate(mgate, (minf - mgate)/mtau) # h_gate = rxd.Rate(hgate, (hinf - hgate)/htau) # n_gate = rxd.Rate(ngate, (ninf - ngate)/ntau) # dm/dt m_gate = rxd.Rate(mgate, (alpha_m * (1.0 - mgate)) - (beta_m * mgate)) # dh/dt h_gate = rxd.Rate(hgate, (alpha_h * (1.0 - hgate)) - (beta_h * hgate)) # dn/dt n_gate = rxd.Rate(ngate, (alpha_n * (1.0 - ngate)) - (beta_n * ngate)) # d[O2]o/dt o2_ecs = rxd.Rate(o2ecs, (epsilon * (oa_bath - o2ecs))) # CURRENTS/LEAKS ---------------------------------------------------------------------------------------------------------------- # sodium (Na) current na_current = rxd.MultiCompartmentReaction(nai, nao,
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 x = u.nodes.x # convert x from normalized position to microns x = dend.L * numpy.array(x) pyplot.plot(x, y, color)
) declare_species( MP=0.0614368 * nM, P0=0.0169928 * nM, P1=0.0141356 * nM, P2=0.0614368 * nM, MT=0.0860342 * nM, T0=0.0217261 * nM, T1=0.0213384 * nM, T2=0.0145428 * nM, C=0.207614 * nM, CN=1.34728 * nM, ) MTtranscription = rxd.Rate(MT, vsT * KIT**n / (KIT**n + CN**n)) MPtranscription = rxd.Rate(MP, vsP * KIP**n / (KIP**n + CN**n)) MTdegradation = rxd.Rate(MT, -(vmT * MT / (KmT + MT) + kd * MT)) MPdegradation = rxd.Rate(MP, -(vmP * MP / (KmP + MP) + kd * MP)) T0production = rxd.Rate(T0, ksT * MT) T0degradation = rxd.Rate(T0, -kd * T0) T1degradation = rxd.Rate(T1, -kd * T1) T2degradation = rxd.Rate(T2, -kd * T2) T2degradation_due_to_light = rxd.Rate(T2, -vdT * T2 / (KdT + T2)) T0toT1 = rxd.Reaction(T0, T1, V1T * T0 / (K1T + T0), V2T * T1 / (K2T + T1), custom_dynamics=True) T1toT2 = rxd.Reaction(T1, T2,
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
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)
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()
#specs[5] PKAc #specs[6] AMP #specs[7] ATP #specs[8] PDE4 #specs[9] PDE4cAMP reaction1 = rxd.Reaction(specs[3] + specs[0] * 4 <> specs[2], ks[0], ks[1]) reaction3 = rxd.Reaction(specs[2] <> specs[4] + specs[5] * 2, ks[4] * specs[2], ks[5] * specs[4] * specs[5], custom_dynamics=True) reaction4 = rxd.Reaction(specs[6] > specs[7], ks[6]) reaction5 = rxd.Reaction(specs[8] + specs[0] <> specs[9], ks[7], ks[8]) reaction6 = rxd.Reaction(specs[9] > specs[7] + specs[8], ks[9]) reaction_cAMP_flux = rxd.Rate(specs[0], cAMP_flux_rate) # cAMP vec_t = h.Vector() vecs = [] vec_t = h.Vector() vec_t.record(h._ref_t) for ispec in range(0, len(species)): vecs.append(h.Vector()) vecs[ispec].record(specs[ispec].nodes(dend)(0.5)[0]._ref_concentration) cvode = h.CVode() cvode.active(1) hmax = cvode.maxstep(100) hmin = cvode.minstep(1e-10) cvode.atol(tolerance)