|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "tags": [] |
| 7 | + }, |
| 8 | + "source": [ |
| 9 | + "# Interactive Tutorial for Hodgkin Huxley Model on Juypter Lab" |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "markdown", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "<font size=\"5\">HH Model for Single Neuron</font>" |
| 17 | + ] |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "metadata": {}, |
| 22 | + "source": [ |
| 23 | + "This model relies on a basic equivalence between a biological membrane plus embedded ion channels, and an electrical circuit.\n", |
| 24 | + "\n", |
| 25 | + "<font size=\"5\">Basic inputs to the Model</font>\n", |
| 26 | + "\n", |
| 27 | + "1) Membrane capacitance, $\\mu{A}/cm^2$\n", |
| 28 | + "2) Maximum Conductances, $mS/cm^2$\n", |
| 29 | + "3) Nernst Reverasal Potentials, $mV$\n", |
| 30 | + "4) Simulation Parameters (time), $ms$\n", |
| 31 | + "\n", |
| 32 | + "<img src=\"equivalentCircuit.PNG\" width=\"500\"/>\n" |
| 33 | + ] |
| 34 | + }, |
| 35 | + { |
| 36 | + "cell_type": "markdown", |
| 37 | + "metadata": {}, |
| 38 | + "source": [ |
| 39 | + "<font size=\"5\">Execute Hodgkin Huxley Model</font>" |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + "cell_type": "code", |
| 44 | + "execution_count": 1, |
| 45 | + "metadata": {}, |
| 46 | + "outputs": [ |
| 47 | + { |
| 48 | + "data": { |
| 49 | + "application/vnd.jupyter.widget-view+json": { |
| 50 | + "model_id": "0069befeceae4a93a70e238bd4db6770", |
| 51 | + "version_major": 2, |
| 52 | + "version_minor": 0 |
| 53 | + }, |
| 54 | + "text/plain": [ |
| 55 | + "VBox(children=(HBox(children=(HTML(value=\"<b><font color='blue'>Membrane Capacitance, uF/cm^2</b>\"),)), HBox(c…" |
| 56 | + ] |
| 57 | + }, |
| 58 | + "metadata": {}, |
| 59 | + "output_type": "display_data" |
| 60 | + }, |
| 61 | + { |
| 62 | + "data": { |
| 63 | + "application/vnd.jupyter.widget-view+json": { |
| 64 | + "model_id": "f778c8dc95a342e3a889af3c1ce47463", |
| 65 | + "version_major": 2, |
| 66 | + "version_minor": 0 |
| 67 | + }, |
| 68 | + "text/plain": [ |
| 69 | + "interactive(children=(Checkbox(value=False, description=\"<b><font color='blue'>Advanced Input - Incjection Cur…" |
| 70 | + ] |
| 71 | + }, |
| 72 | + "metadata": {}, |
| 73 | + "output_type": "display_data" |
| 74 | + } |
| 75 | + ], |
| 76 | + "source": [ |
| 77 | + "import ipywidgets\n", |
| 78 | + "import ui_widget\n", |
| 79 | + "from importlib.machinery import SourceFileLoader\n", |
| 80 | + "import numpy as np\n", |
| 81 | + "import matplotlib.pyplot as plt\n", |
| 82 | + " \n", |
| 83 | + "# imports the module from the given path\n", |
| 84 | + "HHmodel = SourceFileLoader(\"HodgkinHuxley.py\",\"../Tutorial/Source/HodgkinHuxley.py\").load_module()\n", |
| 85 | + "\n", |
| 86 | + "#function to call python script as a module\n", |
| 87 | + "def runHH(C_m, g_Na, g_K, g_L, E_Na, E_K, E_L, t_0, t_n, delta_t, I_inj_max, I_inj_width, I_inj_trans):\n", |
| 88 | + " runner = HHmodel.HodgkinHuxley(C_m, g_Na, g_K, g_L, E_Na, E_K, E_L, t_0, t_n, delta_t, I_inj_max, I_inj_width, I_inj_trans)\n", |
| 89 | + " runner.Main()\n", |
| 90 | + "\n", |
| 91 | + "#function to handle checkbox event\n", |
| 92 | + "def checkboxEvent(checkboxStatus):\n", |
| 93 | + " if checkboxStatus:\n", |
| 94 | + " wid_inj=ipywidgets.interact(ui_widget.injectorCurrent,amplidute=ui_widget.slider_amplitude,t_width=ui_widget.slider_width,t_translation=ui_widget.slider_translation);\n", |
| 95 | + " display(wid_plotArea)\n", |
| 96 | + " else:\n", |
| 97 | + " display(wid_plotArea)\n", |
| 98 | + "\n", |
| 99 | + "#create checkbox widget\n", |
| 100 | + "wid_checkbox=ipywidgets.interactive(checkboxEvent,checkboxStatus=ui_widget.cb);\n", |
| 101 | + "\n", |
| 102 | + "#create plot area widget and interact with HHmodel\n", |
| 103 | + "wid_plotArea=ipywidgets.interactive_output(runHH,{'C_m':ui_widget.slider_capacitance,\n", |
| 104 | + " 'g_Na':ui_widget.slider_cond_Na, 'g_K':ui_widget.slider_cond_K, 'g_L':ui_widget.slider_cond_L, \n", |
| 105 | + " 'E_Na':ui_widget.slider_pot_Na, 'E_K':ui_widget.slider_pot_K, 'E_L':ui_widget.slider_pot_L,\n", |
| 106 | + " 't_0':ui_widget.time_start, 't_n':ui_widget.time_end, 'delta_t':ui_widget.time_step, \n", |
| 107 | + " 'I_inj_max':ui_widget.slider_amplitude,'I_inj_width':ui_widget.slider_width,'I_inj_trans':ui_widget.slider_translation})\n", |
| 108 | + " \n", |
| 109 | + "display(ui_widget.basicInputs,wid_checkbox)" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "markdown", |
| 114 | + "metadata": {}, |
| 115 | + "source": [ |
| 116 | + "<font size=\"5\">Description of the Plots</font>" |
| 117 | + ] |
| 118 | + }, |
| 119 | + { |
| 120 | + "cell_type": "markdown", |
| 121 | + "metadata": {}, |
| 122 | + "source": [ |
| 123 | + "1) Starting from the bottom, the first (bottom-most) plot shows two currents injected into the cell membrane at times 100ms and 300ms.\n", |
| 124 | + "2) The second plot from the bottom shows the activation/inactivation parameters of the ion channels in the neuron. \n", |
| 125 | + "3) Third plot from the bottom (the current/time plot) makes this more concrete, showing the influx (negative y-axis) and outflux (positive y-axis) of ions passing through each type of ion channel being modeled.\n", |
| 126 | + "4) The top plot, which shows neural membrane voltage activity. The spikes here are called “action potentials” and correspond directly to the current/time plot. " |
| 127 | + ] |
| 128 | + } |
| 129 | + ], |
| 130 | + "metadata": { |
| 131 | + "kernelspec": { |
| 132 | + "display_name": "Python 3 (ipykernel)", |
| 133 | + "language": "python", |
| 134 | + "name": "python3" |
| 135 | + }, |
| 136 | + "language_info": { |
| 137 | + "codemirror_mode": { |
| 138 | + "name": "ipython", |
| 139 | + "version": 3 |
| 140 | + }, |
| 141 | + "file_extension": ".py", |
| 142 | + "mimetype": "text/x-python", |
| 143 | + "name": "python", |
| 144 | + "nbconvert_exporter": "python", |
| 145 | + "pygments_lexer": "ipython3", |
| 146 | + "version": "3.9.7" |
| 147 | + } |
| 148 | + }, |
| 149 | + "nbformat": 4, |
| 150 | + "nbformat_minor": 4 |
| 151 | +} |
0 commit comments