{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "

Quickstart

\n", "To run the code below:\n", "
    \n", "
  1. Click on the cell to select it.
  2. \n", "
  3. Press SHIFT+ENTER on your keyboard or press the play button\n", " () in the toolbar above
  4. \n", "
\n", "Feel free to create new cells using the plus button\n", "(), or pressing SHIFT+ENTER while this cell\n", "is selected.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One of the great advantages of using Brian is that defining new non-standard model types is easy. In this article, we will build a highly simplified model of the pyloric circuit of the crustacean stomatogastric ganglion. This circuit generates a tri-phasic rhythmic pattern with alternating bursts of action potentials in different types of motor neurons. Here, we follow previous work (e.g. Golowasch et al., 1999) by modeling the circuit as consisting of three populations: AB/PD (anterior buster and pyloric dilator neurons), LP (lateral pyloric neurons), and PY (pyloric neurons). This model has a number of non-standard properties that will be described in the following annotated version of the code.\n", "\n", "> Golowasch, J., Casey, M., Abbott, L. F., & Marder, E. (1999). \n", "> Network Stability from Activity-Dependent Regulation of Neuronal Conductances. \n", "> Neural Computation, 11(5), 1079-1096. \n", "> https://doi.org/10.1162/089976699300016359\n", " \n", "This article was based on one of the examples from our eLife paper [(Stimberg et al. 2019)](https://elifesciences.org/articles/47314).\n", "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before describing a model, we set up the Brian simulator:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from brian2 import *\n", "%matplotlib notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now enable the high-performance \"standalone-mode\". By default, the first run statement the code encounters will trigger the automatic compilation and execution. We disable this feature here (`build_on_run=False`) because our model consists of a sequence of runs. Only after all runs have been defined, we will ask Brian to build and execute the simulation code." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "set_device('cpp_standalone', build_on_run=False, directory=None)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To make simulation runs reproducible, we set the seed of the random number generator." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "seed(123456)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All operations in Brian take place on \"clocks\" that step forward with given time steps. If not defined otherwise (as in this script), operations use the \"default clock\". We set its time step to 0.01ms:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "defaultclock.dt = 0.01*ms" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The neuron's membrane potential in the pyloric network shows slow oscillations with burst of action potentials at its peak. Here, we use a variant of the Hindmarsh-Rose model, reformulated to use physical dimensions instead of unitless variables. This model defines the dynamics of the membrane potential $v$, and of the adaptation variables $w$ and $x$ as follows:\n", "$$\n", "\\frac{\\mathrm{d}v}{\\mathrm{d}t} = \\left(\\Delta_Tg\\left(-a\\left(v - v_T\\right)^3 + b\\left(v - v_T\\right)^2\\right) + w - x - I_\\mathrm{fast} - I_\\mathrm{slow}\\right)\\frac{1}{C} \\\\\n", "\\frac{\\mathrm{d}w}{\\mathrm{d}t} = \\left(c - d\\left(v - v_T\\right)^2 - w\\right)\\frac{1}{\\tau} \\\\\n", "\\frac{\\mathrm{d}x}{\\mathrm{d}t} = \\left(s\\left(v - v_r\\right) - x\\right)\\frac{1}{\\tau_x}\n", "$$\n", "\n", "In Brian, such equations can be specified as a string, following mathematical notation as closely as possible. The physical dimensions of the variable defined in the respective line has to be specified after a colon; this allows Brian to check for the consistency of the dimensions and therefore avoid the use of incorrect equations:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "eqs = '''\n", "dv/dt = (Delta_T*g*(-a*(v - v_T)**3 + b*(v - v_T)**2) + w - x - I_fast - I_slow)/C : volt\n", "dw/dt = (c - d*(v - v_T)**2 - w)/tau : amp\n", "dx/dt = (s*(v - v_r) - x)/tau_x : amp\n", "'''" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One particular feature of the pyloric network model in Golowasch et al. (1999) is that not all intrinsic conductances are constant, but some are activity-dependent via the Calcium current. Here, we simplify this dependency by having a Calcium signal that exponentially decays in the absence of spikes (it increases with each spike, see definition later in the script):\n", "$$\n", "\\frac{\\mathrm{d}Ca}{\\mathrm{d}t} = -\\frac{Ca}{\\tau_{Ca}}\n", "$$" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "eqs += '''\n", "dCa/dt = -Ca/tau_Ca : 1\n", "'''" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that this Calcium signal is normalized and therefore dimensionless. We now follow the model of Golowasch et al. (1999) to describe the dependency of two conductances, $s$ and $g$ in our case, on the difference of this Calcium current to a target current via the dynamic variable $z$:\n", "$$\n", "\\frac{\\mathrm{d}z}{\\mathrm{d}t} = \\tanh\\left(Ca - Ca_\\mathrm{target}\\right)\\frac{1}{\\tau_z}\\\\\n", "s = S\\left(1 - \\tanh(z)\\right)\\\\\n", "g = G\\left(1 + \\tanh(z)\\right)\n", "$$" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "eqs += '''\n", "s = S*(1 - tanh(z)) : siemens\n", "g = G*(1 + tanh(z)) : siemens\n", "dz/dt = tanh(Ca - Ca_target)/tau_z : 1\n", "'''" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we note that $I_\\mathrm{fast}$ and $I_\\mathrm{slow}$ are neuron-specific state variables (set by the Synapses later), and that $Ca_\\mathrm{target}$ is a neuron-specific constant. We also add a special integer constant called `label` that will be used to label AB/PD, LP, and PY neurons." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "eqs += '''\n", "I_fast : amp\n", "I_slow : amp\n", "Ca_target : 1 (constant)\n", "label : integer (constant)\n", "'''" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Our equations refer to a number of constants that are shared across all neurons, we define them as standard Python variables. " ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "init_time = 2.5*second\n", "observe_time = 4*second\n", "adapt_time = 49 * second\n", "Delta_T = 17.5*mV\n", "v_T = -40*mV\n", "tau = 2*ms\n", "tau_adapt = .02*second\n", "tau_Ca = 150*ms\n", "tau_x = 2*second\n", "v_r = -68*mV\n", "a = 1/Delta_T**3\n", "b = 3/Delta_T**2\n", "d = 2.5*nA/Delta_T**2\n", "C = 60*pF\n", "S = 2*nA/Delta_T\n", "G = 28.5*nS\n", "tau_z = 5*second\n", "c = 1.2*nA\n", "ABPD, LP, PY = 0, 1, 2 # Arbitrary numbers" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, we create the neurons that follow the previously defined model, and additionally define what should count as a threshold crossing (`threshold`) and what should happen when it is crossed (`reset`). Note that this model describes the trajectory of the membrane potential during an action potential as part of its equations, it therefore does not reset the membrane potential after a spike as an integrate-and-fire model would. To prevent repeatedly triggering \"spikes\" due to the fact that the membrane potential is above the threshold all the time during the action potential, we state that while the neuron is still above the threshold, it should be considered not able to elicit any more spikes (`refractory`). Finally, we define the numerical integration method to use (`method`), here, a 2nd order Runge-Kutta method." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "circuit = NeuronGroup(3, eqs, threshold='v>-20*mV', refractory='v>-20*mV', method='rk2',\n", " reset='Ca += 0.1')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We've defined a group of three neurons, each one being of a different type. We set the neurons' label accordingly and set the initial conditions for the variables $v$, $w$, and $z$, as well as the neuron-type dependent values for the constant $Ca_\\mathrm{target}$:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "circuit.label = [ABPD, LP, PY]\n", "circuit.v = v_r\n", "circuit.w = '-5*nA*rand()'\n", "circuit.z = 'rand()*0.2 - 0.1'\n", "circuit.Ca_target = [0.048, 0.0384, 0.06]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The predefined `rand()` function returns random number from a uniform distribution between 0 and 1, i.e. $w$ is initialized to be between 0nA and -5nA, and $z$ between -0.1 and 0.1.\n", "\n", "For this model, we want to describe two classes of synapses, \"fast\" and \"slow\". Both synaptic currents are graded functions of the presynaptic membrane potential. For the fast synapses, the current is an instantaneous function of both the pre-synaptic and the post-synaptic membrane potential:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "# Synapses\n", "eqs_fast = '''\n", "g_fast : siemens (constant)\n", "I_fast_post = g_fast*(v_post - E_syn)/(1+exp(s_fast*(V_fast-v_pre))) : amp (summed)\n", "'''\n", "fast_synapses = Synapses(circuit, circuit, model=eqs_fast)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `(summed)` here means that the post-synaptic current will be summed over all currents from synapses targetting the same post-synaptic target. As for neurons, we then define general constants as Python variables:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "s_fast = 0.2/mV\n", "V_fast = -50*mV\n", "s_slow = 1/mV\n", "V_slow = -55*mV\n", "E_syn = -75*mV\n", "k_1 = 1/ms" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To establish synapses between the neurons, we can provide a logical condition detailing whether a connection should be created for a specific pair of neurons. This condition can refer to arbitrary pre- and post-synaptic variables or constants. In the following, we make use of the `label` constant that defines the type of each neuron. Given that our simple model only includes one neuron of each type, we could have used the neuron indices instead. However, using a label has the advantage of clearly showing the intent behind the connection pattern and would automatically generalize to a network with multiple neurons per type. Here, we want to establish connections with fast synapses for all pairs of neurons with different type (i.e., don't connect neurons of the same type to each other), but not from PY to AB/PD neurons: " ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "fast_synapses.connect('label_pre != label_post and not (label_pre == PY and label_post == ABPD)')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The maximum conductance of each synapse depends on the pre- and post-synaptic neuron types, we assign them accordingly:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "fast_synapses.g_fast['label_pre == ABPD and label_post == LP'] = 0.015*uS\n", "fast_synapses.g_fast['label_pre == ABPD and label_post == PY'] = 0.005*uS\n", "fast_synapses.g_fast['label_pre == LP and label_post == ABPD'] = 0.01*uS\n", "fast_synapses.g_fast['label_pre == LP and label_post == PY'] = 0.02*uS\n", "fast_synapses.g_fast['label_pre == PY and label_post == LP'] = 0.005*uS" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the slow synapses, the post-synaptic current depends on the pre-synaptic membrane potential indirectly via the variable $m_\\mathrm{slow}$ (its differential equation is solved via its analytical solution, requested by chosing `method='exact'`):" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "eqs_slow = '''\n", "k_2 : 1/second (constant)\n", "g_slow : siemens (constant)\n", "I_slow_post = g_slow*m_slow*(v_post-E_syn) : amp (summed)\n", "dm_slow/dt = k_1*(1-m_slow)/(1+exp(s_slow*(V_slow-v_pre))) - k_2*m_slow : 1 (clock-driven)\n", "'''\n", "slow_synapses = Synapses(circuit, circuit, model=eqs_slow, method='exact')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Slow synapses are only arising from AB/PD units, and target neurons of all other types:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "slow_synapses.connect('label_pre == ABPD and label_post != ABPD')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Their maximum conductance depends on the type of the target cell:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "slow_synapses.g_slow['label_post == LP'] = 0.025*uS\n", "slow_synapses.k_2['label_post == LP'] = 0.03/ms\n", "slow_synapses.g_slow['label_post == PY'] = 0.015*uS\n", "slow_synapses.k_2['label_post == PY'] = 0.008/ms" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before we start the simulation, we state what data we want to record during the simulation. In addition to the spiking activity, we record the membrane potential $v$ for all cells (`record=True`). By default, this monitor would use the same time resolution as the rest of the simulation (0.01 ms), but we reduce the resolution to 0.1ms:" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "M = StateMonitor(circuit, ['v'], record=True, dt=.1*ms)\n", "spikes = SpikeMonitor(circuit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To make analysis and plotting easier, we run the simulations in separate parts with the recording initally switched off (`M.active = false`). After a short period (`init_time`) we record the activity for a fixed period (`observe_time`). We then let the network adapt its conductances for a long time (`adapt_time`), without recording its activity. Finally, we record the activity in the adaptated network." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "M.active = False\n", "run(init_time, report='text')\n", "M.active = True\n", "run(observe_time, report='text')\n", "M.active = False\n", "run(adapt_time, report='text')\n", "M.active = True\n", "run(observe_time, report='text')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the computationally efficient \"standalone mode\", the above statements describe the simulation protocol without actually launching the compilation and execution process. We do this now:" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "device.build(directory=None)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "After the simulation finished, we extract the spike trains from the monitor (spiking activity for each neuron) and plot the membrane potential and the spike trains of the three cell types before and after the adaption." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "spike_trains = spikes.spike_trains()" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
');\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('