I have the following code which reads a mitral cell SWC morphology, runs a simulation with injected current, and then plots the morphology with the results of the simulation based on data from NEURON's plotshape mechanism.
Code: Select all
import plotly
from neuron import h, gui
from neuron.units import mV, ms
h.load_file('stdrun.hoc')
h.load_file('import3d.hoc')
cell = h.Import3d_SWC_read()
path_to_file = "mitral-cell-08-SDB20130216pair2_0.CNG.swc"
cell.input(path_to_file)
i3d = h.Import3d_GUI(cell, False)
i3d.instantiate(None)
h.hh.insert(h.allsec()) # inserts hh mech into all of the sections
for sec in h.allsec(): # set the number of segments for consistent spatial discretization and computational accuracy
sec.nseg = 1 + 2 * int(sec.L / 40)
ic = h.IClamp(h.soma[0](0.5))
ic.amp = 10
ic.delay = 1
ic.dur = 1
h.finitialize(-65 * mV)
h.continuerun(2 * ms)
ps = h.PlotShape(False)
ps.variable('v')
ps.scale(-80, 30)
ps.plot(plotly).show()