{ "cells": [ { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# *(Gerstner, 2005)*: Adaptive Exponential Integrate-and-Fire model\n", "\n", "[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/examples/blob/main/neurons/Gerstner_2005_AdExIF_model.ipynb)\n", "[![Open in Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://kaggle.com/kernels/welcome?src=https://github.com/brainpy/examples/blob/main/neurons/Gerstner_2005_AdExIF_model.ipynb)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Adaptive Exponential Integrate-and-Fire neuron model is a spiking model, describes single neuron behavior and can generate many kinds of firing patterns by tuning parameters." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "import brainpy as bp\n", "\n", "bp.math.set_dt(0.01)\n", "bp.math.enable_x64()\n", "bp.math.set_platform('cpu')" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Tonic" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e2965fe000bf48108552859577b63a44", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/50000 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "group = bp.neurons.AdExIF(size=1, a=0., b=60., R=.5, delta_T=2., tau=20., tau_w=30.,\n", " V_reset=-55., V_rest=-70, V_th=-30, V_T=-50)\n", "\n", "runner = bp.DSRunner(group, monitors=['V', 'w'], inputs=('input', 65.))\n", "runner.run(500.)\n", "fig, gs = bp.visualize.get_figure(2, 1, 3, 8)\n", "fig.add_subplot(gs[0, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.V, ylabel='V', title='tonic')\n", "fig.add_subplot(gs[1, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.w, ylabel='w', show=True)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Adapting" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "f2f1af984c1e4e53b566ad51fc999ad3", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/20000 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "group = bp.neurons.AdExIF(size=1, a=0., b=5., R=.5, tau=20., tau_w=100., delta_T=2.,\n", " V_reset=-55., V_rest=-70, V_th=-30, V_T=-50)\n", "\n", "runner = bp.DSRunner(group, monitors=['V', 'w'], inputs=('input', 65.))\n", "runner.run(200.)\n", "fig, gs = bp.visualize.get_figure(2, 1, 3, 8)\n", "fig.add_subplot(gs[0, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.V, ylabel='V', title='adapting')\n", "fig.add_subplot(gs[1, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.w, ylabel='w', show=True)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Init Bursting" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8c9b72ba1fd74961b43326ec89968585", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/30000 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "group = bp.neurons.AdExIF(size=1, a=.5, b=7., R=.5, tau=5., tau_w=100., delta_T=2.,\n", " V_reset=-51, V_rest=-70, V_th=-30, V_T=-50)\n", "\n", "runner = bp.DSRunner(group, monitors=['V', 'w'], inputs=('input', 65.))\n", "runner.run(300.)\n", "fig, gs = bp.visualize.get_figure(2, 1, 3, 8)\n", "fig.add_subplot(gs[0, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.V, ylabel='V', ylim=(-55., -35.), title='init_bursting')\n", "fig.add_subplot(gs[1, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.w, ylabel='w', show=True)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Bursting" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d247642931764aa8825de46f5f83b7df", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/50000 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "group = bp.neurons.AdExIF(size=1, a=-0.5, b=7., R=.5, delta_T=2., tau=5, tau_w=100,\n", " V_reset=-46, V_rest=-70, V_th=-30, V_T=-50)\n", "\n", "runner = bp.DSRunner(group, monitors=['V', 'w'], inputs=('input', 65.))\n", "runner.run(500.)\n", "fig, gs = bp.visualize.get_figure(2, 1, 3, 8)\n", "fig.add_subplot(gs[0, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.V, ylabel='V', ylim=(-60., -35.), title='bursting')\n", "fig.add_subplot(gs[1, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.w, ylabel='w', show=True)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Transient" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "09bbc2d49f984cb398204a73540e4841", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/50000 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "group = bp.neurons.AdExIF(size=1, a=1., b=10., R=.5, tau=10, tau_w=100, delta_T=2.,\n", " V_reset=-60, V_rest=-70, V_th=-30, V_T=-50)\n", "\n", "runner = bp.DSRunner(group, monitors=['V', 'w'], inputs=('input', 55.))\n", "runner.run(500.)\n", "fig, gs = bp.visualize.get_figure(2, 1, 3, 8)\n", "fig.add_subplot(gs[0, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.V, ylabel='V', ylim=(-60., -35.), title='transient')\n", "fig.add_subplot(gs[1, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.w, ylabel='w', show=True)" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Delayed" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1e0521e5541846f4a721b46b5945f019", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/50000 [00:00" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "group = bp.neurons.AdExIF(size=1, a=-1., b=10., R=.5, delta_T=2., tau=5., tau_w=100.,\n", " V_reset=-60, V_rest=-70, V_th=-30, V_T=-50)\n", "\n", "runner = bp.DSRunner(group, monitors=['V', 'w'], inputs=('input', 20.))\n", "runner.run(500.)\n", "fig, gs = bp.visualize.get_figure(2, 1, 3, 8)\n", "fig.add_subplot(gs[0, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.V, ylabel='V', ylim=(-60., -35.), title='delayed')\n", "fig.add_subplot(gs[1, 0])\n", "bp.visualize.line_plot(runner.mon.ts, runner.mon.w, ylabel='w', show=True)" ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent" }, "kernelspec": { "display_name": "brainpy", "language": "python", "name": "brainpy" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" }, "latex_envs": { "LaTeX_envs_menu_present": true, "autoclose": false, "autocomplete": true, "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 1, "hotkeys": { "equation": "Ctrl-E", "itemize": "Ctrl-I" }, "labels_anchors": false, "latex_user_defs": false, "report_style_numbering": false, "user_envs_cfg": false }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }