{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# _(Brunel & Hakim, 1999)_ Fast Global Oscillation\n", "\n", "[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/brainpy/examples/blob/main/oscillation_synchronization/Brunel_Hakim_1999_fast_oscillation.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/oscillation_synchronization/Brunel_Hakim_1999_fast_oscillation.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Implementation of the paper:\n", "\n", "- Brunel, Nicolas, and Vincent Hakim. \"Fast global oscillations in networks of integrate-and-fire neurons with low firing rates.\" Neural computation 11.7 (1999): 1621-1671.\n", "\n", "Author: [Chaoming Wang](mailto:chao.brain@qq.com)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2023-07-22T03:56:15.697456100Z", "start_time": "2023-07-22T03:56:15.002405500Z" } }, "outputs": [], "source": [ "import brainpy as bp\n", "import brainpy.math as bm\n", "\n", "bm.set_platform('cpu')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2023-07-22T03:59:41.826998400Z", "start_time": "2023-07-22T03:59:41.813010500Z" }, "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'2.4.3'" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bp.__version__" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2023-07-22T03:56:15.713327200Z", "start_time": "2023-07-22T03:56:15.697456100Z" } }, "outputs": [], "source": [ "Vr = 10. # mV\n", "theta = 20. # mV\n", "tau = 20. # ms\n", "delta = 2. # ms\n", "taurefr = 2. # ms\n", "duration = 100. # ms\n", "J = .1 # mV\n", "muext = 25. # mV\n", "sigmaext = 1. # mV\n", "C = 1000\n", "N = 5000\n", "sparseness = float(C) / N" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2023-07-22T03:56:15.731140Z", "start_time": "2023-07-22T03:56:15.715368700Z" } }, "outputs": [], "source": [ "class LIF(bp.dyn.NeuDyn):\n", " def __init__(self, size, **kwargs):\n", " super(LIF, self).__init__(size, **kwargs)\n", "\n", " # variables\n", " self.V = bm.Variable(bm.ones(self.num) * Vr)\n", " self.t_last_spike = bm.Variable(-1e7 * bm.ones(self.num))\n", " self.spike = bm.Variable(bm.zeros(self.num, dtype=bool))\n", " self.refractory = bm.Variable(bm.zeros(self.num, dtype=bool))\n", "\n", " # integration functions\n", " fv = lambda V, t: (-V + muext) / tau\n", " gv = lambda V, t: sigmaext / bm.sqrt(tau)\n", " self.int_v = bp.sdeint(f=fv, g=gv)\n", "\n", " def update(self):\n", " t = bp.share['t']\n", " dt = bp.share['dt']\n", " V = self.int_v(self.V, t, dt)\n", " in_ref = (t - self.t_last_spike) < taurefr\n", " V = bm.where(in_ref, self.V, V)\n", " spike = V >= theta\n", " self.spike.value = spike\n", " self.V.value = bm.where(spike, Vr, V)\n", " self.t_last_spike.value = bm.where(spike, t, self.t_last_spike)\n", " self.refractory.value = bm.logical_or(in_ref, spike)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2023-07-22T03:56:17.174212100Z", "start_time": "2023-07-22T03:56:15.731140Z" } }, "outputs": [], "source": [ "group = LIF(N)\n", "syn = bp.synapses.Delta(group, group,\n", " conn=bp.conn.FixedProb(sparseness),\n", " delay_step=int(delta / bm.get_dt()),\n", " post_ref_key='refractory',\n", " output=bp.synouts.CUBA(target_var='V'),\n", " g_max=-J)\n", "net = bp.Network(syn, group=group)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2023-07-22T03:56:18.353576700Z", "start_time": "2023-07-22T03:56:17.174601900Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b2859cb2332948698bc9a687761a2070", "version_major": 2, "version_minor": 0 }, "text/plain": [ " 0%| | 0/1000 [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "runner = bp.DSRunner(net, monitors=['group.spike'])\n", "runner.run(duration)\n", "bp.visualize.raster_plot(runner.mon.ts, runner.mon['group.spike'],\n", " xlim=(0, duration), show=True)" ] } ], "metadata": { "hide_input": false, "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": false, "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 }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }