{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Nanduri et al. (2012): Frequency vs. amplitude modulation\n\nThis example shows how to use the\n:py:class:`~pulse2percept.models.Nanduri2012Model`.\n\nThe model introduced in [Nanduri2012]_ assumes that electrical stimulation\nleads to percepts that quickly increase in brightness (over the time course\nof ~100ms) and then slowly fade away (over the time course of seconds).\nThe model also assumes that amplitude and frequency modulation have different\neffects on the perceived brightness and size of a phosphene.\n\n## Generating a pulse train\n\nThe first step is to build a pulse train using the\n:py:class:`~pulse2percept.stimuli.PulseTrain` class.\nWe want to generate a 20Hz pulse train (0.45ms pulse duration, cathodic-first)\nat 30uA that lasts for a second:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pulse2percept.stimuli import BiphasicPulseTrain, Stimulus\ntsample = 0.005 # sampling time step (ms)\nphase_dur = 0.45 # duration of the cathodic/anodic phase (ms)\nstim_dur = 1000 # stimulus duration (ms)\namp_th = 30 # threshold current (uA)\nstim = BiphasicPulseTrain(20, amp_th, phase_dur, interphase_dur=phase_dur,\n stim_dur=stim_dur)\n\n# Configure Matplotlib:\nimport matplotlib.pyplot as plt\nplt.style.use('ggplot')\nfrom matplotlib import rc\nrc('font', size=12)\n\n# Plot the stimulus in the range t=[0, 60] ms:\nstim.plot(time=(0, 60))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating an implant\n\nBefore we can run the Nanduri model, we need to create a retinal implant to\nwhich we can assign the above pulse train.\n\nFor the purpose of this exercise, we will create an\n:py:class:`~pulse2percept.implants.ElectrodeArray` consisting of a single\n:py:class:`~pulse2percept.implants.DiskElectrode` with radius=260um centered\nat (x,y) = (0,0); i.e., centered over the fovea:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pulse2percept.implants import DiskElectrode, ElectrodeArray\nearray = ElectrodeArray(DiskElectrode(0, 0, 0, 260))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Usually we would use a predefined retinal implant such as\n:py:class:`~pulse2percept.implants.ArgusII` or\n:py:class:`~pulse2percept.implants.AlphaIMS`. Alternatively, we can wrap the\nelectrode array created above with a\n:py:class:`~pulse2percept.implants.ProsthesisSystem` to create our own\nretinal implant. We will also assign the above created stimulus to it:\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pulse2percept.implants import ProsthesisSystem\nimplant = ProsthesisSystem(earray, stim=stim)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running the model\n\nInteracting with a model always involves three steps:\n\n1. **Initalize** the model by passing the desired parameters.\n2. **Build** the model to perform (sometimes expensive) one-time setup\n computations.\n3. **Predict** the percept for a given stimulus.\n\nIn the following, we will run the Nanduri model on a single pixel, (0, 0):\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from pulse2percept.models import Nanduri2012Model\nmodel = Nanduri2012Model(xrange=(0, 0), yrange=(0, 0))\nmodel.build()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
You can also directly instantiate\n :py:class:`~pulse2percept.models.Nanduri2012Temporal` and pass a stimulus\n to it. However, please note that there might be subtle differences; e.g.,\n :py:class:`~pulse2percept.models.Nanduri2012Model` will pass the stimulus\n through the spatial model first.
In psychophysical experiments, brightness is usually expressed in\n relative terms; i.e., compared to a reference stimulus. In the model,\n brightness has arbitrary units.