Setting ion specifications in rxd leads to region overlap error

Extending NEURON to handle reaction-diffusion problems.

Moderators: hines, wwlytton, ramcdougal

Post Reply
bril27
Posts: 8
Joined: Sun Mar 20, 2022 4:08 am

Setting ion specifications in rxd leads to region overlap error

Post by bril27 »

I am trying to build a model in which the channel mechanisms are all written in rxd instead of NMODL. I use NEURON 8.2.2 with Python 3.8.10 in visual studio Code.

Here's what I have so far (mostly taken from a NEURON rxd tutorial:

Code: Select all

import math
from neuron import h, rxd, gui
from neuron.units import mV, ms, cm, mM
from neuron.crxd import v
from matplotlib import pyplot
h.load_file('stdrun.hoc')

# Create soma section
soma = h.Section(name='soma')

# Define the voltage and time step
v = h.Vector().record(soma(0.5)._ref_v)
t = h.Vector().record(h._ref_t)
h.dt = 0.025 # ms

# Define the rxd model following the standard specification

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


When I then run the next lines of code to specify the ion species:

Code: Select all

# Define intracellular sodium and potassium species on the 'cyt' region
na = rxd.Species(cyt, name='na', d=1, charge=1, initial=10 * mM)
k = rxd.Species(cyt, name='k', d=1, charge=1, initial=140 * mM)
I get the error message that there seems to be an overlap in the usage of a region:

RxDException: Species "na" previously defined on a region Region(..., nrn_region='i', geometry=, dx=0.25, name='cyt') that overlaps with regions: [Region(..., nrn_region='i', geometry=, dx=0.25, name='cyt')]

Could someone please explain what is happening here? Is this perhaps a version issue?
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Setting ion specifications in rxd leads to region overlap error

Post by ramcdougal »

Perhaps there was a Python session where code was ran and then those lines were reran in the same session?

If you run as a script or just restart your session everything should just work.

For parameter sweeps, the model doesn't need to be redefined each time, only the parameter needs to be changed.
bril27
Posts: 8
Joined: Sun Mar 20, 2022 4:08 am

Re: Setting ion specifications in rxd leads to region overlap error

Post by bril27 »

Yes, thank you, indeed it was ran in the same session, and now I know how to fix this.

I do have additional questions related to running a voltage clamp to see if my channel mechanisms work as expected. I'd appreciate any pointers on how to go about this when the code is written in the rxd framework. So far, I am running into a problem with RuntimeError: hocobj_call error on finitialize when I try to run the following:

Code: Select all

import plotly
import plotly.graph_objects as go
vclamp = h.SEClamp(soma(0.5))
vclamp.amp1 = -65 * mV
vclamp.dur1 = 5 * ms
vclamp.dur2 = 20 * ms
vclamp.amp2 = 20 * mV
vclamp.amp3 = -65 * mV
vclamp.dur3 = 10000 * ms

t = h.Vector().record(h._ref_t)
ina = h.Vector().record(soma(0.5)._ref_ina)
ik = h.Vector().record(soma(0.5)._ref_ik)

h.finitialize(-65 * mV)
h.continuerun(30 * ms)

fig = go.Figure()
fig.add_trace(go.Scatter(x=t, y=ina, name="ina"))
fig.add_trace(go.Scatter(x=t, y=ik, name="ik"))
I hope you could enlighten me on what I am missing here.
Post Reply