Skip to content

Commit

Permalink
Add 'docs/tutorials/' from commit 'a5661a04ca6804aef66b83cd6ddef08efd…
Browse files Browse the repository at this point in the history
…dcf1a7'

git-subtree-dir: docs/tutorials
git-subtree-mainline: 1b18b2e
git-subtree-split: a5661a0
  • Loading branch information
alexsavulescu authored and nrnhines committed Feb 9, 2021
1 parent ee38461 commit 58a6f19
Show file tree
Hide file tree
Showing 11 changed files with 6,004 additions and 0 deletions.
1,301 changes: 1,301 additions & 0 deletions docs/tutorials/ball-and-stick-1.ipynb

Large diffs are not rendered by default.

759 changes: 759 additions & 0 deletions docs/tutorials/ball-and-stick-2.ipynb

Large diffs are not rendered by default.

400 changes: 400 additions & 0 deletions docs/tutorials/ball-and-stick-3.ipynb

Large diffs are not rendered by default.

440 changes: 440 additions & 0 deletions docs/tutorials/ball-and-stick-4.ipynb

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions docs/tutorials/ballandstick.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
from neuron import h, gui
from neuron.units import ms, mV
h.load_file('stdrun.hoc')

class Cell:
def __init__(self, gid, x, y, z, theta):
self._gid = gid
self._setup_morphology()
self.all = self.soma.wholetree()
self._setup_biophysics()
self.x = self.y = self.z = 0
h.define_shape()
self._rotate_z(theta)
self._set_position(x, y, z)

# everything below here in this method is NEW
self._spike_detector = h.NetCon(self.soma(0.5)._ref_v, None, sec=self.soma)
self.spike_times = h.Vector()
self._spike_detector.record(self.spike_times)

self._ncs = []

self.soma_v = h.Vector().record(self.soma(0.5)._ref_v)


def __repr__(self):
return '{}[{}]'.format(self.name, self._gid)

def _set_position(self, x, y, z):
for sec in self.all:
for i in range(sec.n3d()):
sec.pt3dchange(i,
x - self.x + sec.x3d(i),
y - self.y + sec.y3d(i),
z - self.z + sec.z3d(i),
sec.diam3d(i))
self.x, self.y, self.z = x, y, z

def _rotate_z(self, theta):
"""Rotate the cell about the Z axis."""
for sec in self.all:
for i in range(sec.n3d()):
x = sec.x3d(i)
y = sec.y3d(i)
c = h.cos(theta)
s = h.sin(theta)
xprime = x * c - y * s
yprime = x * s + y * c
sec.pt3dchange(i, xprime, yprime, sec.z3d(i), sec.diam3d(i))


class BallAndStick(Cell):
name = 'BallAndStick'

def _setup_morphology(self):
self.soma = h.Section(name='soma', cell=self)
self.dend = h.Section(name='dend', cell=self)
self.dend.connect(self.soma)
self.soma.L = self.soma.diam = 12.6157
self.dend.L = 200
self.dend.diam = 1

def _setup_biophysics(self):
for sec in self.all:
sec.Ra = 100 # Axial resistance in Ohm * cm
sec.cm = 1 # Membrane capacitance in micro Farads / cm^2
self.soma.insert('hh')
for seg in self.soma:
seg.hh.gnabar = 0.12 # Sodium conductance in S/cm2
seg.hh.gkbar = 0.036 # Potassium conductance in S/cm2
seg.hh.gl = 0.0003 # Leak conductance in S/cm2
seg.hh.el = -54.3 # Reversal potential in mV
# Insert passive current in the dendrite
self.dend.insert('pas')
for seg in self.dend:
seg.pas.g = 0.001 # Passive conductance in S/cm2
seg.pas.e = -65 # Leak reversal potential mV

# NEW: the synapse
self.syn = h.ExpSyn(self.dend(0.5))
self.syn.tau = 2 * ms

Loading

0 comments on commit 58a6f19

Please sign in to comment.