Skip to content
Snippets Groups Projects
09_eeg_use_case.ipynb 2.83 KiB
Newer Older
  • Learn to ignore specific revisions
  • {
     "cells": [
      {
       "cell_type": "code",
       "execution_count": 29,
       "metadata": {},
       "outputs": [],
       "source": [
        "import numpy as np\n",
        "import os\n",
        "import pandas as pd\n",
        "from scipy.signal import resample\n",
        "import matplotlib.pyplot as plt"
       ]
      },
      {
       "cell_type": "markdown",
       "metadata": {},
       "source": [
        "#### Load daat"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 7,
       "metadata": {},
       "outputs": [],
       "source": [
        "train_path = 'data/eeg_use_case/train/'\n",
        "test_path = 'data/eeg_use_case/test/'\n",
        "all_files = os.listdir(train_path)"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 15,
       "metadata": {},
       "outputs": [],
       "source": [
        "vals = pd.read_csv(train_path + all_files[0]).drop('id', axis = 1).values"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 46,
       "metadata": {},
       "outputs": [
        {
         "name": "stderr",
         "output_type": "stream",
         "text": [
          "/cluster/apps/python/3.6.1/x86_64/lib64/python3.6/site-packages/scipy/signal/signaltools.py:2236: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.\n",
          "  Y[sl] = X[sl]\n",
          "/cluster/apps/python/3.6.1/x86_64/lib64/python3.6/site-packages/scipy/signal/signaltools.py:2238: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.\n",
          "  Y[sl] = X[sl]\n"
         ]
        }
       ],
       "source": [
        "for file in all_files[:1]:\n",
        "    data = pd.read_csv(train_path + file).drop('id', axis = 1)\n",
        "    vals = data.values\n",
        "    cols = data.columns\n",
        "    downs_length = int(vals.shape[0]/10)\n",
        "    downs = resample(vals, downs_length, axis = 0)\n",
        "    data_downs = pd.DataFrame(downs, columns=cols)\n",
        "    data_downs.to_csv(train_path + file)"
       ]
      },
      {
       "cell_type": "code",
       "execution_count": 49,
       "metadata": {},
       "outputs": [],
       "source": []
      },
      {
       "cell_type": "code",
       "execution_count": null,
       "metadata": {},
       "outputs": [],
       "source": []
      }
     ],
     "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.1"
      }
     },
     "nbformat": 4,
     "nbformat_minor": 2
    }