Skip to content

Commit

Permalink
Update plotshapeclass.rst (#2412)
Browse files Browse the repository at this point in the history
Co-authored-by: Rickeim Gourdine <rickeim.gourdine@yale.edu>
  • Loading branch information
sgamiye and rgourdine committed Oct 21, 2023
1 parent 728ae2f commit 878be2b
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 2 deletions.
86 changes: 85 additions & 1 deletion docs/python/visualization/plotshapeclass.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ PlotShape
``ps.plot(graphics_object)``

Description:

In NEURON 7.7+, PlotShape.plot works both with and without Interviews support.
Variables, sectionlists, and scale are supported.
Clicking on a segment displays the value and the segment id.
Expand Down Expand Up @@ -58,6 +59,7 @@ PlotShape
or use plotly instead.

Example:

You can also pass in a SectionList argument to only plot specific sections


Expand All @@ -75,7 +77,89 @@ PlotShape
ps.variable('v')
ax = ps.plot(pyplot, cmap=cm.jet)
pyplot.show()
Example:

Line width across the neuron morphology is able to be altered depending on different modes. ``ps.show(0)`` allows for visualizing diameters for each segment across the cell. Additionally, when ``mode = 1`` or ``mode = 2`` , line_width argument can be passed in to specify fixed width across cell.

For plotting on matplotlib:

.. code-block::
python
from neuron import h, gui
from neuron.units import mV, ms
from matplotlib.pyplot import cm
from matplotlib import pyplot
h.load_file("c91662.ses")
for sec in h.allsec():
sec.nseg = int(1 + 2 * (sec.L // 40))
sec.insert(h.hh)
ic = h.IClamp(h.soma(0.5))
ic.delay = 1 * ms
ic.dur = 1 * ms
ic.amp = 10
h.finitialize(-65 * mV)
h.continuerun(2 * ms)
ps = h.PlotShape(False)
ps.variable("v")
ps.show(1)
ps.plot(pyplot, cmap=cm.magma, line_width=10, color="red")
pyplot.show()
For plotting on plotly:

.. code-block::
python
import plotly
import matplotlib
from neuron import h
from neuron.units import mV, ms
h.load_file("c91662.ses")
for sec in h.allsec():
sec.nseg = int(1 + 2 * (sec.L // 40))
sec.insert(h.hh)
ic = h.IClamp(h.soma(0.5))
ic.delay = 1 * ms
ic.dur = 1 * ms
ic.amp = 10
h.finitialize(-65 * mV)
h.continuerun(2 * ms)
ps = h.PlotShape(False)
ps.variable("v")
ps.show(1)
ps.plot(plotly, width=7, cmap=matplotlib.colormaps["viridis"]).show()
Example:
Color argument can also be passed in when consistent color across cell is preferred. When not specified, the morphology will be plotted in color gradient passed as ``cmap`` in accordance with voltage values of each segment after simulation is initiated. To specifiy cmap,

.. code-block::
python
from neuron import h
from matplotlib import pyplot, cm
h.load_file("c91662.ses")
sl = h.SectionList([sec for sec in h.allsec() if "apic" in str(sec)])
for sec in sl:
sec.v = 0
ps = h.PlotShape(False)
ps.scale(-80, 40)
ps.variable("v")
ax = ps.plot(pyplot, line_width=3, color="red")
pyplot.show()
----

.. method:: PlotShape.scale
Expand Down
32 changes: 31 additions & 1 deletion docs/python/visualization/shape.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Shape

Description:


Mode for ``shape.show()`` can be adjusted for different way to display the cell, and can be adjusted as the following example (available from NEURON 9.0:

mode = 0
displays diameters

Expand All @@ -88,7 +89,36 @@ Shape
mode = 2
displays schematic. ie line through 1st and last 2d points of each
section.
.. code-block::
python
import plotly
from neuron import h, gui
from neuron.units import mV, ms
import matplotlib
h.load_file("c91662.ses")
for sec in h.allsec():
sec.nseg = int(1 + 2 * (sec.L // 40))
sec.insert(h.hh)
ic = h.IClamp(h.soma(0.5))
ic.delay = 1 * ms
ic.dur = 1 * ms
ic.amp = 10
h.finitialize(-65 * mV)
h.continuerun(2 * ms)
ps = h.PlotShape(False)
ps.variable("v")
print(ps.show()) # prints the current mode
ps.show(0) # alters the mode to 0 that displays diameters for each segment
print(ps.show()) # should print 0 as the mode set
ps.plot(plotly, width=7, cmap=matplotlib.colormaps["viridis"]).show()
----
Expand Down

0 comments on commit 878be2b

Please sign in to comment.