Parallelizing sections within a single cell in python without using GUI
Posted: Fri Mar 25, 2022 3:05 pm
As a proof-of-concept prior to applying to single cell with more than 2500 compartments, we started with parallelizing a single cell with 3-sections - soma, axon1 and axon2 to understand the process. Here is the code:
from math import pi
from neuron import h
h.load_file('stdrun.hoc')
#h.load_file("parcom.hoc")
import multiprocessing
# Simulation parameters
h.dt = 0.025 # time step (resolution) of the simulation in ms
h.v_init= -50 # initial membrane potential in mV
# Create the soma section and define the parameters
soma = h.Section(name='soma')
soma.diam = 1000; # micrometers
soma.L = 1e5/pi # micrometers
soma.cm = 9e-3 # membrane capacitance uF/cm2
soma.Ra = 10000 # ohm-cm
soma.insert('leak'); soma.insert('cas'); soma.insert('cat')
soma.insert('kA'); soma.insert('kca'); soma.insert('kdr')
soma.insert('capool')
soma.el_leak=-50; soma.eca = 120; soma.ek = -80 # mV
soma.cainf_capool = 500e-6; soma.casi = soma.cainf_capool # mM
# Create the axon section and define the parameters
axon1 = h.Section(name='axon1')
axon1.diam = 1000 # micrometers
axon1.L = 1e5/pi # micrometers
axon1.cm = 1.5e-3 # uF/cm2
axon1.Ra = 10000 # ohm-cm
axon1.insert('leak'); axon1.insert('na'); axon1.insert('kdr')
axon1.el_leak = -60; axon1.ena = 50; axon1.ek = -80 # mV
#Create second axon for parallelization
axon2 = h.Section(name='axon2')
axon2.diam = 1000 # micrometers
axon2.L = 1e5/pi # micrometers
axon2.cm = 1.5e-3 # uF/cm2
axon2.Ra = 10000 # ohm-cm
axon2.insert('leak'); axon2.insert('na'); axon2.insert('kdr')
axon2.el_leak = -60; axon2.ena = 50; axon2.ek = -80 # mV
# Connect axon to the soma
axon1.connect(soma(1),0)
axon2.connect(axon1(1),0)
h.topology()
# Current clamp
ccl = h.IClamp(soma(0.5))
h.nrnmpi_init()
pc = h.ParallelContext()
#cpu = multiprocessing.cpu_count()
#h.load_file("parcom.hoc")
#p = h.ParallelComputeTool()
def activemodel(tstop,soma_gl,gcas,gcat,gkA,gkca,soma_gkdr,taucas,axon_gl,axon_gna,axon_gkdr,amp,dur,delay):
soma.glbar_leak = soma_gl
soma.gcasbar_cas = gcas
soma.gcatbar_cat = gcat
soma.gkAbar_kA = gkA
soma.gkcabar_kca = gkca
soma.gkdrbar_kdr = soma_gkdr
soma.taucas_capool = taucas
axon1.glbar_leak = axon_gl
axon1.gnabar_na = axon_gna
axon1.gkdrbar_kdr = axon_gkdr
axon2.glbar_leak = axon_gl
axon2.gnabar_na = axon_gna
axon2.gkdrbar_kdr = axon_gkdr
ccl.amp = amp
ccl.dur = dur
ccl.delay = delay
h.tstop = tstop
pc.runworker()
#axon1.disconnect()
#axon2.disconnect()
pc.multisplit(soma(1), 1)
pc.multisplit(axon1(0), 1)
pc.multisplit(axon1(1), 2)
pc.multisplit(axon2(0), 2)
pc.multisplit()
h.run()
pc.done()
h.quit()
# default setting
tstop = 1000 # how long to run the simulation in ms
soma_gl = 0.000045e-3 # S/cm2
gcas = 0.055e-3 # S/cm2
gcat = 0.0552e-3 # S/cm2
gkA = 0.200e-3 # S/cm2
gkca = 0.500e-3 # S/cm2
soma_gkdr = 1.890e-3 # S/cm2
taucas = 303 # ms
axon_gl = 0.0000018e-3 # S/cm2
axon_gna = 0.300e-3 # S/cm2
axon_gkdr = 0.0525e-3 # S/cm2
amp = 0 # amplitude in nA
dur = 600 # duration in ms
delay = 200 # delay in ms
activemodel(tstop,soma_gl,gcas,gcat,gkA,gkca,soma_gkdr,taucas,axon_gl,axon_gna,axon_gkdr,amp,dur,delay)
Our logic is based on there theoretically being two split nodes, one connecting the end of the soma to the axon1, and two connecting the end of axon1 to the beginning of axon2. However, we are unsure of how we should implement multisplit with respect to the splitnodes.
Would help if someone can help with the logic in the code above or point us to simple implementations of this type to parallelize single cell sections.
If you would like to reach out:
Atul Krishnadas: akyvv@unsystem.edu
Matthew Carroll: mjc6r9@umsystem.edu
from math import pi
from neuron import h
h.load_file('stdrun.hoc')
#h.load_file("parcom.hoc")
import multiprocessing
# Simulation parameters
h.dt = 0.025 # time step (resolution) of the simulation in ms
h.v_init= -50 # initial membrane potential in mV
# Create the soma section and define the parameters
soma = h.Section(name='soma')
soma.diam = 1000; # micrometers
soma.L = 1e5/pi # micrometers
soma.cm = 9e-3 # membrane capacitance uF/cm2
soma.Ra = 10000 # ohm-cm
soma.insert('leak'); soma.insert('cas'); soma.insert('cat')
soma.insert('kA'); soma.insert('kca'); soma.insert('kdr')
soma.insert('capool')
soma.el_leak=-50; soma.eca = 120; soma.ek = -80 # mV
soma.cainf_capool = 500e-6; soma.casi = soma.cainf_capool # mM
# Create the axon section and define the parameters
axon1 = h.Section(name='axon1')
axon1.diam = 1000 # micrometers
axon1.L = 1e5/pi # micrometers
axon1.cm = 1.5e-3 # uF/cm2
axon1.Ra = 10000 # ohm-cm
axon1.insert('leak'); axon1.insert('na'); axon1.insert('kdr')
axon1.el_leak = -60; axon1.ena = 50; axon1.ek = -80 # mV
#Create second axon for parallelization
axon2 = h.Section(name='axon2')
axon2.diam = 1000 # micrometers
axon2.L = 1e5/pi # micrometers
axon2.cm = 1.5e-3 # uF/cm2
axon2.Ra = 10000 # ohm-cm
axon2.insert('leak'); axon2.insert('na'); axon2.insert('kdr')
axon2.el_leak = -60; axon2.ena = 50; axon2.ek = -80 # mV
# Connect axon to the soma
axon1.connect(soma(1),0)
axon2.connect(axon1(1),0)
h.topology()
# Current clamp
ccl = h.IClamp(soma(0.5))
h.nrnmpi_init()
pc = h.ParallelContext()
#cpu = multiprocessing.cpu_count()
#h.load_file("parcom.hoc")
#p = h.ParallelComputeTool()
def activemodel(tstop,soma_gl,gcas,gcat,gkA,gkca,soma_gkdr,taucas,axon_gl,axon_gna,axon_gkdr,amp,dur,delay):
soma.glbar_leak = soma_gl
soma.gcasbar_cas = gcas
soma.gcatbar_cat = gcat
soma.gkAbar_kA = gkA
soma.gkcabar_kca = gkca
soma.gkdrbar_kdr = soma_gkdr
soma.taucas_capool = taucas
axon1.glbar_leak = axon_gl
axon1.gnabar_na = axon_gna
axon1.gkdrbar_kdr = axon_gkdr
axon2.glbar_leak = axon_gl
axon2.gnabar_na = axon_gna
axon2.gkdrbar_kdr = axon_gkdr
ccl.amp = amp
ccl.dur = dur
ccl.delay = delay
h.tstop = tstop
pc.runworker()
#axon1.disconnect()
#axon2.disconnect()
pc.multisplit(soma(1), 1)
pc.multisplit(axon1(0), 1)
pc.multisplit(axon1(1), 2)
pc.multisplit(axon2(0), 2)
pc.multisplit()
h.run()
pc.done()
h.quit()
# default setting
tstop = 1000 # how long to run the simulation in ms
soma_gl = 0.000045e-3 # S/cm2
gcas = 0.055e-3 # S/cm2
gcat = 0.0552e-3 # S/cm2
gkA = 0.200e-3 # S/cm2
gkca = 0.500e-3 # S/cm2
soma_gkdr = 1.890e-3 # S/cm2
taucas = 303 # ms
axon_gl = 0.0000018e-3 # S/cm2
axon_gna = 0.300e-3 # S/cm2
axon_gkdr = 0.0525e-3 # S/cm2
amp = 0 # amplitude in nA
dur = 600 # duration in ms
delay = 200 # delay in ms
activemodel(tstop,soma_gl,gcas,gcat,gkA,gkca,soma_gkdr,taucas,axon_gl,axon_gna,axon_gkdr,amp,dur,delay)
Our logic is based on there theoretically being two split nodes, one connecting the end of the soma to the axon1, and two connecting the end of axon1 to the beginning of axon2. However, we are unsure of how we should implement multisplit with respect to the splitnodes.
Would help if someone can help with the logic in the code above or point us to simple implementations of this type to parallelize single cell sections.
If you would like to reach out:
Atul Krishnadas: akyvv@unsystem.edu
Matthew Carroll: mjc6r9@umsystem.edu