{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nSpike Train Features\n====================\n\nDetect spike train features\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from __future__ import print_function\n\nimport os\nfrom allensdk.api.queries.cell_types_api import CellTypesApi\nfrom ipfx.data_set_utils import create_data_set\nfrom ipfx.feature_extractor import (\n    SpikeFeatureExtractor, SpikeTrainFeatureExtractor\n)\n\n# Download and access the experimental data\nct = CellTypesApi()\nnwb_file = os.path.join(\n    os.path.dirname(os.getcwd()), \n    \"data\",\n    \"nwb2_H17.03.008.11.03.05.nwb\"\n)\nspecimen_id = 595570553\nsweep_info = ct.get_ephys_sweeps(specimen_id)\n\n# Get the data for the sweep into a format we can use\ndataset = create_data_set(sweep_info=sweep_info, nwb_file=nwb_file)\nsweep_number = 39\nsweep = dataset.sweep(sweep_number)\n\n# Extract information about the spikes\nstart, end = 1.02, 2.02\next = SpikeFeatureExtractor(start=start, end=end)\nspikes_df = ext.process(t=sweep.t, v=sweep.v, i=sweep.i)\n\nst_ext = SpikeTrainFeatureExtractor(start=start, end=end)\nst_results = st_ext.process(\n    t=sweep.t, \n    v=sweep.v, \n    i=sweep.i, \n    spikes_df=spikes_df\n)\n\nprint(st_results)"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "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.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}