{
  "nbformat_minor": 0,
  "cells": [
    {
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "source": [
        "%matplotlib inline"
      ],
      "metadata": {
        "collapsed": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "\n# Cochlea Creation \n\n\nCreate a simple cochlea model and test it on a sinusoidal input signal\n\n\n"
      ],
      "metadata": {}
    },
    {
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "source": [
        "# import matplotlib\n# matplotlib.use('TkAgg')\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\nfrom simplecochlea import Cochlea\nsns.set_context('paper')"
      ],
      "metadata": {
        "collapsed": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Create the cochlea\n\n"
      ],
      "metadata": {}
    },
    {
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "source": [
        "fs, fmin, fmax, freq_scale, n_channels = 44100, 200, 8000, 'erbscale', 100\ncomp_factor, comp_gain = 0.3, 1.5\ntau, v_thresh, v_spike = np.linspace(0.001, 0.0004, n_channels), np.linspace(0.3, 0.17, n_channels), 0.5\n\ncochlea_simp = Cochlea(n_channels, fs, fmin, fmax, freq_scale, comp_factor=comp_factor, comp_gain=comp_gain,\n                       lif_tau=tau, lif_v_thresh=v_thresh, lif_v_spike=v_spike)"
      ],
      "metadata": {
        "collapsed": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Print the description\n\n"
      ],
      "metadata": {}
    },
    {
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "source": [
        "print(cochlea_simp)"
      ],
      "metadata": {
        "collapsed": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Process a sin input signal\n\n"
      ],
      "metadata": {}
    },
    {
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "source": [
        "spikelist_sin, _ = cochlea_simp.process_test_signal('sin', f_sin=400, t_offset=0, t_max=0.1)"
      ],
      "metadata": {
        "collapsed": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Plot the output spikelist\n\n"
      ],
      "metadata": {}
    },
    {
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "source": [
        "spikelist_sin.plot()"
      ],
      "metadata": {
        "collapsed": false
      }
    }
  ],
  "nbformat": 4,
  "metadata": {
    "language_info": {
      "codemirror_mode": {
        "version": 3,
        "name": "ipython"
      },
      "mimetype": "text/x-python",
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "version": "3.5.2",
      "name": "python",
      "file_extension": ".py"
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3",
      "language": "python"
    }
  }
}