{
  "metadata": {
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3",
      "language": "python"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "name": "python",
      "version": "3.5.2",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "file_extension": ".py",
      "mimetype": "text/x-python"
    }
  },
  "nbformat_minor": 0,
  "nbformat": 4,
  "cells": [
    {
      "source": [
        "%matplotlib inline"
      ],
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "metadata": {
        "collapsed": false
      }
    },
    {
      "source": [
        "\n======================================================\n    Neo All - example 5 - Channel Groups / Index\n======================================================\n\nThis example show how to use the channel indexes in the NeoAll class. In NeoAll, channel indexes are defined for each\ntetrode and each electrode **if the signal directory path is given at init**. Otherwise channel indexes are created\nbased on the probe file.\n\n\n"
      ],
      "cell_type": "markdown",
      "metadata": {}
    },
    {
      "source": [
        "from neoStructures import *\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom os.path import isdir, join"
      ],
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "metadata": {
        "collapsed": false
      }
    },
    {
      "source": [
        "Import the data and create the NeoAll instance\n\n"
      ],
      "cell_type": "markdown",
      "metadata": {}
    },
    {
      "source": [
        "data_dir = join('pySpikeAnalysis', 'sample_data') if isdir('pySpikeAnalysis') else join('..', '..', 'pySpikeAnalysis', 'sample_data')\nspykingcircus_dir = r'SpykingCircus_results'\nprobe_filename = r'000_AA.prb'\nresults_filename = r'spykingcircusres'\nartefact_csv_filepath = join(data_dir, r'artefact_free_periods.csv')\n\nneoAll = NeoAll(join(data_dir, spykingcircus_dir), results_filename, join(data_dir, probe_filename), save_fig=0)"
      ],
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "metadata": {
        "collapsed": false
      }
    },
    {
      "source": [
        "See information about NeoAll\n\n"
      ],
      "cell_type": "markdown",
      "metadata": {}
    },
    {
      "source": [
        "print(neoAll)"
      ],
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "metadata": {
        "collapsed": false
      }
    },
    {
      "source": [
        "Let's look at the different channel indexes :\n\n"
      ],
      "cell_type": "markdown",
      "metadata": {}
    },
    {
      "source": [
        "print(neoAll.channel_indexes)"
      ],
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "metadata": {
        "collapsed": false
      }
    },
    {
      "source": [
        "We can see that the first groups or ChannelIndex correpond to individual tetrodes and that the last groups\nWe can see that the first groups or ChannelIndex correpond to individual tetrodes and that the last groups\ncorrepond to the entire electrode (i.e. group of 2 or 3 tetrodes)\n\n"
      ],
      "cell_type": "markdown",
      "metadata": {}
    },
    {
      "source": [
        "We can use the channel indexes for plotting the firing rate evolution of multiple units in the same figure. Channel\nindexes define groups of channel. By default, a channel index is defined for each tetrode.\nLet's plot the firing rate evolution of all units of the tetrode 2 of electrode cp (ChannelIndex number 4,\nthus index 3) :\n\n"
      ],
      "cell_type": "markdown",
      "metadata": {}
    },
    {
      "source": [
        "neoAll.plot_spikerate_evolution_group(grp_index=3)"
      ],
      "execution_count": null,
      "outputs": [],
      "cell_type": "code",
      "metadata": {
        "collapsed": false
      }
    }
  ]
}