{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Sweep QC Features\n\nEstimate sweep QC features\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import os\nimport pandas as pd\nfrom ipfx.dataset.create import create_ephys_data_set\nfrom ipfx.qc_feature_extractor import sweep_qc_features\n\nimport ipfx.sweep_props as sweep_props\nimport ipfx.qc_feature_evaluator as qcp\nfrom ipfx.stimulus import StimulusOntology\n\n\n# Download and access the experimental data from DANDI archive per instructions in the documentation\n# Example below will use an nwb file provided with the package\n\nnwb_file = os.path.join(\n    os.path.dirname(os.getcwd()),\n    \"data\",\n    \"nwb2_H17.03.008.11.03.05.nwb\"\n)\ndata_set = create_ephys_data_set(nwb_file=nwb_file)\n\n# Compute sweep QC features\nsweep_features = sweep_qc_features(data_set)\n\n# Drop sweeps that failed to compute QC criteria\nsweep_props.drop_tagged_sweeps(sweep_features)\nsweep_props.remove_sweep_feature(\"tags\", sweep_features)\n\nstimulus_ontology = StimulusOntology.default()\nqc_criteria = qcp.load_default_qc_criteria()\n\nsweep_states = qcp.qc_sweeps(\n    stimulus_ontology, sweep_features, qc_criteria\n)\n\n# print a few sweeps and states\nprint(pd.DataFrame(sweep_features).head())\nprint(sweep_states[0:len(pd.DataFrame(sweep_features).head())])"
      ]
    }
  ],
  "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.6.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}