Skip to content

Commit

Permalink
fix & clean-up for nrn embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsavulescu committed Feb 4, 2021
1 parent 14d11dd commit a5661a0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 36 deletions.
20 changes: 18 additions & 2 deletions ball-and-stick-1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
"As good practice, we'll load some unit definitions:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from neuron.units import ms, mV"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We'll load the standard run library to give us high-level simulation control functions (e.g. running a simulation for a given period of time):"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1207,7 +1223,7 @@
" h.continuerun(25)\n",
" f.line(t, list(soma_v),\n",
" line_width=width,\n",
" legend_label='amp=%g' % amp if my_cell.dend.nseg == 1 else None,\n",
" legend_label='amp={:.3g}'.format(amp) if my_cell.dend.nseg == 1 else '',\n",
" color=color)\n",
" f.line(t, list(dend_v),\n",
" line_width=width,\n",
Expand Down Expand Up @@ -1277,7 +1293,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
37 changes: 35 additions & 2 deletions ball-and-stick-2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,40 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If you are writing a script to do this, and revising the classes as we make changes, everything should be good. If you are following along in a Jupyter notebook, you will need to rerun the definition of BallAndStick above for the changes to take effect."
"If you are writing a script to do this, and revising the classes as we make changes, everything should be good. If you are following along in a Jupyter notebook, you will need to rerun the definition of BallAndStick above for the changes to take effect:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Run only for jupyter\n",
"class BallAndStick(Cell):\n",
" name = 'BallAndStick'\n",
" def _setup_morphology(self):\n",
" self.soma = h.Section(name='soma', cell=self)\n",
" self.dend = h.Section(name='dend', cell=self)\n",
" self.dend.connect(self.soma)\n",
" self.soma.L = self.soma.diam = 12.6157\n",
" self.dend.L = 200\n",
" self.dend.diam = 1\n",
" def _setup_biophysics(self):\n",
" for sec in self.all:\n",
" sec.Ra = 100 # Axial resistance in Ohm * cm\n",
" sec.cm = 1 # Membrane capacitance in micro Farads / cm^2\n",
" self.soma.insert('hh') \n",
" for seg in self.soma:\n",
" seg.hh.gnabar = 0.12 # Sodium conductance in S/cm2\n",
" seg.hh.gkbar = 0.036 # Potassium conductance in S/cm2\n",
" seg.hh.gl = 0.0003 # Leak conductance in S/cm2\n",
" seg.hh.el = -54.3 # Reversal potential in mV\n",
" # Insert passive current in the dendrite\n",
" self.dend.insert('pas') \n",
" for seg in self.dend:\n",
" seg.pas.g = 0.001 # Passive conductance in S/cm2\n",
" seg.pas.e = -65 # Leak reversal potential mV\n"
]
},
{
Expand Down Expand Up @@ -718,7 +751,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion ball-and-stick-3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.7"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit a5661a0

Please sign in to comment.