{ "cells": [ { "cell_type": "markdown", "id": "334c4067", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# *(Vreeswijk & Sompolinsky, 1996)* E/I balanced network\n", "\n", "[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/examples/blob/main/ei_nets/Vreeswijk_1996_EI_net.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/ei_nets/Vreeswijk_1996_EI_net.ipynb)" ] }, { "cell_type": "markdown", "id": "43b7d35c", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Overviews" ] }, { "cell_type": "markdown", "id": "18c46a51", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Van Vreeswijk and Sompolinsky proposed E-I balanced network in 1996 to explain the temporally irregular spiking patterns. They suggested that the temporal variability may originated from the balance between excitatory and inhibitory inputs.\n", "\n", "There are $N_E$ excitatory neurons and $N_I$ inbibitory neurons.\n", "\n", "An important feature of the network is random and sparse connectivity. Connections between neurons $K$ meets $1 << K << N_E$. " ] }, { "cell_type": "markdown", "id": "5cc50ea2", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Implementations" ] }, { "cell_type": "code", "execution_count": 13, "id": "d92659c5", "metadata": { "ExecuteTime": { "end_time": "2023-08-27T05:11:57.856026200Z", "start_time": "2023-08-27T05:11:57.824834500Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "import brainpy as bp\n", "import brainpy.math as bm\n", "\n", "bm.set_platform('cpu')" ] }, { "cell_type": "code", "execution_count": 14, "id": "240871bd23926e7e", "metadata": { "ExecuteTime": { "end_time": "2023-08-27T05:11:57.899087600Z", "start_time": "2023-08-27T05:11:57.830935500Z" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'2.4.4.post1'" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bp.__version__" ] }, { "cell_type": "markdown", "id": "39d14fd7", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "Dynamic of membrane potential is given as:\n", "\n", "$$ \\tau \\frac {dV_i}{dt} = -(V_i - V_{rest}) + I_i^{ext} + I_i^{net} (t) $$\n", "\n", "where $I_i^{net}(t)$ represents the synaptic current, which describes the sum of excitatory and inhibitory neurons.\n", "\n", "$$ I_i^{net} (t) = J_E \\sum_{j=1}^{pN_e} \\sum_{t_j^\\alpha < t} f(t-t_j^\\alpha ) - J_I \\sum_{j=1}^{pN_i} \\sum_{t_j^\\alpha < t} f(t-t_j^\\alpha )$$\n", "\n", "where \n", "\n", "$$ f(t) = \\begin{cases} {\\rm exp} (-\\frac t {\\tau_s} ), \\quad t \\geq 0 \\\\\n", "0, \\quad t < 0 \\end{cases} $$\n", "\n", "Parameters: $J_E = \\frac 1 {\\sqrt {pN_e}}, J_I = \\frac 1 {\\sqrt {pN_i}}$" ] }, { "cell_type": "markdown", "id": "f96f2b5e", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "We can see from the dynamic that network is based on leaky Integrate-and-Fire neurons, and we can just use `get_LIF` from `bpmodels.neurons` to get this model. " ] }, { "cell_type": "markdown", "id": "03c815de", "metadata": { "lines_to_next_cell": 2, "pycharm": { "name": "#%% md\n" } }, "source": [ "The function of $I_i^{net}(t)$ is actually a synase with single exponential decay, we can also get it by using `get_exponential`." ] }, { "cell_type": "markdown", "id": "971fc04ba1f086b8", "metadata": { "collapsed": false }, "source": [ "### Synapse" ] }, { "cell_type": "code", "execution_count": 15, "id": "b0d5d38dd3af5244", "metadata": { "ExecuteTime": { "end_time": "2023-08-27T05:11:57.901089200Z", "start_time": "2023-08-27T05:11:57.845565600Z" }, "collapsed": false }, "outputs": [], "source": [ "class ExponCUBA(bp.Projection):\n", " def __init__(self, pre, post, prob, g_max, tau):\n", " super().__init__()\n", " self.proj = bp.dyn.ProjAlignPostMg2(\n", " pre=pre,\n", " delay=None, \n", " comm=bp.dnn.EventCSRLinear(bp.conn.FixedProb(prob, pre=pre.num, post=post.num), g_max),\n", " syn=bp.dyn.Expon.desc(post.num, tau=tau),\n", " out=bp.dyn.CUBA.desc(),\n", " post=post,\n", " )" ] }, { "cell_type": "markdown", "id": "3e1c2857", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Network" ] }, { "cell_type": "markdown", "id": "af31fe06", "metadata": { "lines_to_next_cell": 2, "pycharm": { "name": "#%% md\n" } }, "source": [ "Let's create a neuron group with $N_E$ excitatory neurons and $N_I$ inbibitory neurons. Use `conn=bp.connect.FixedProb(p)` to implement the random and sparse connections." ] }, { "cell_type": "code", "execution_count": 16, "id": "3803f676", "metadata": { "ExecuteTime": { "end_time": "2023-08-27T05:11:57.901089200Z", "start_time": "2023-08-27T05:11:57.866107200Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "class EINet(bp.DynSysGroup):\n", " def __init__(self, num_exc, num_inh, prob, JE, JI):\n", " # neurons\n", " pars = dict(V_rest=-52., V_th=-50., V_reset=-60., tau=10., tau_ref=0.,\n", " V_initializer=bp.init.Normal(-60., 10.))\n", " E = bp.neurons.LIF(num_exc, **pars)\n", " I = bp.neurons.LIF(num_inh, **pars)\n", "\n", " # synapses\n", " E2E = ExponCUBA(E, E, prob, g_max=JE, tau=2.)\n", " E2I = ExponCUBA(E, I, prob, g_max=JE, tau=2.)\n", " I2E = ExponCUBA(I, E, prob, g_max=JI, tau=2.)\n", " I2I = ExponCUBA(I, I, prob, g_max=JI, tau=2.)\n", "\n", " super(EINet, self).__init__(E2E, E2I, I2E, I2I, E=E, I=I)" ] }, { "cell_type": "code", "execution_count": 17, "id": "166b30a3", "metadata": { "ExecuteTime": { "end_time": "2023-08-27T05:11:57.902087400Z", "start_time": "2023-08-27T05:11:57.878746300Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "num_exc = 500\n", "num_inh = 500\n", "prob = 0.1\n", "\n", "Ib = 3.\n", "JE = 1 / bp.math.sqrt(prob * num_exc)\n", "JI = -1 / bp.math.sqrt(prob * num_inh)" ] }, { "cell_type": "code", "execution_count": 18, "id": "044a6297", "metadata": { "ExecuteTime": { "end_time": "2023-08-27T05:11:59.600134100Z", "start_time": "2023-08-27T05:11:57.893047900Z" }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "67050dd746544ad49dc21ffa69b6d68d", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/10000 [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import matplotlib.pyplot as plt\n", "\n", "fig, gs = bp.visualize.get_figure(4, 1, 2, 10)\n", "\n", "fig.add_subplot(gs[:3, 0])\n", "bp.visualize.raster_plot(runner.mon.ts, runner.mon['E.spike'], xlim=(50, 950))\n", "\n", "fig.add_subplot(gs[3, 0])\n", "rates = bp.measure.firing_rate(runner.mon['E.spike'], 5.)\n", "plt.plot(runner.mon.ts, rates)\n", "plt.xlim(50, 950)\n", "plt.show()" ] }, { "cell_type": "markdown", "id": "f5a1389d", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Reference" ] }, { "cell_type": "markdown", "id": "c455520c", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "[1] Van Vreeswijk, Carl, and Haim Sompolinsky. \"Chaos in neuronal networks with balanced excitatory and inhibitory activity.\" Science 274.5293 (1996): 1724-1726." ] } ], "metadata": { "jupytext": { "formats": "ipynb,py:percent" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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": 5 }