Page 1 of 1

Reactions only when concentration above a certain limit?

Posted: Sat Mar 16, 2019 12:06 pm
by bremen
Hi.

Is there a way to know the concentration of a species, during the simulation, so that it can be used to automatically start specific reactions?

I have found this command in the help:
https://www.neuron.yale.edu/neuron/stat ... esOnRegion

Code: Select all

class neuron.rxd.species.SpeciesOnRegion(species, region) 
 " concentration - An iterable of the current concentrations"
Tried some combination but with no luck. Is it possible to have an example of how to correctly use it?
Thank you.

Best
Stefano

Re: Reactions only when concentration above a certain limit?

Posted: Mon Mar 18, 2019 11:24 am
by adamjhn
The formulas for rxd.Rate, etc need to be continuous, but you can approximate a threshold function using a sigmoidal shaped curve. For example, you can use rxdmath.tanh to remove calcium at a constant rate when it exceeds a threshold with a narrow transition period:

Code: Select all

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

# NEURON model
dend = h.Section('dend')

# Where -- define the regions
cyt = rxd.Region(h.allsec(), name = 'cyt', nrn_region = 'i')

# Who -- define the species
ca = rxd.Species(cyt, name = 'ca', charge = 2, initial = 1.0)

# What -- define the reactions
# remove calcium at 0.01mM/ms when it is above 0.1mM using a sigmoid function
threshold = 0.1
steepness = 100
ca_removal = rxd.Rate(ca, -0.01 * (1+rxdmath.tanh(steepness*(ca-threshold)))/2)

# record & run the simulation
t_vec = h.Vector()
t_vec.record(h._ref_t)

ca_vec = h.Vector()
ca_vec.record(ca.nodes[0]._ref_concentration)

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

# plot the result
pyplot.plot(t_vec, ca_vec)
pyplot.xlabel('t (ms)')
pyplot.ylabel('Ca$^{2+}$ (mM)')
pyplot.show()
You may also find the rxd tutorial useful; https://www.neuron.yale.edu/neuron/stat ... index.html