{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `spudtr` epochs dataframe format\n", "\n", "`spudtr` epochs are `pandas.DataFrame` objects.\n", "\n", "There are three key elements:\n", "\n", " 1. `epoch_id` an index-like integer column, where each value designates a unique epoch\n", " 2. `time` an index-like column of integer timestamps, the same in each epoch\n", " 3. the rest of the data columns\n", " \n", "There must be at least one epoch.\n", "\n", "There must be at least one timepoint.\n", "\n", "All the epochs must be timestamped exactly the same way.\n", "\n", "> NOTE: timestamps are positive and negative integers, the units are unspecified: milliseconds, months, nanoseconds, hours." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from matplotlib import pyplot as plt\n", "\n", "from spudtr import get_demo_df, P3_1500_FEATHER\n", "from spudtr import epf\n", "import spudtr.fake_epochs_data as fake_data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Example: simulated categorical and continuous data**\n", "\n", "The `epoch_id` column is \"epoch_id\", there are four epochs: 0, 1, 2, 3.\n", "\n", "The `time` column is \"days\", there are 31 days in each epoch, 0, 1, 2, ..., 31.\n", "\n", "The rest of the columns are the data recorded in each epoch at each time stamp." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
epoch_iddayscategoricalcontinuouschannel0channel1channel2channel3
000cat00.771321-13.170787-30.19705719.60986943.177612
101cat00.0207524.233125-7.726009-65.29825941.464399
202cat00.6336488.19148021.91522318.56846827.639613
303cat00.748804-48.557122-50.95204514.317029-17.186617
404cat00.498507-17.19340150.2222660.78289638.251473
...........................
123327cat10.74460333.167254-7.65841414.63087814.329468
124328cat10.469785-60.5315600.7742281.6894420.882024
125329cat10.59825616.21622166.02899316.3735344.854384
126330cat10.147620-43.26896626.531028-20.493672-12.327708
127331cat10.184035-48.265511-41.604676-19.77051927.925069
\n", "

128 rows × 8 columns

\n", "
" ], "text/plain": [ " epoch_id days categorical continuous channel0 channel1 channel2 \\\n", "0 0 0 cat0 0.771321 -13.170787 -30.197057 19.609869 \n", "1 0 1 cat0 0.020752 4.233125 -7.726009 -65.298259 \n", "2 0 2 cat0 0.633648 8.191480 21.915223 18.568468 \n", "3 0 3 cat0 0.748804 -48.557122 -50.952045 14.317029 \n", "4 0 4 cat0 0.498507 -17.193401 50.222266 0.782896 \n", ".. ... ... ... ... ... ... ... \n", "123 3 27 cat1 0.744603 33.167254 -7.658414 14.630878 \n", "124 3 28 cat1 0.469785 -60.531560 0.774228 1.689442 \n", "125 3 29 cat1 0.598256 16.216221 66.028993 16.373534 \n", "126 3 30 cat1 0.147620 -43.268966 26.531028 -20.493672 \n", "127 3 31 cat1 0.184035 -48.265511 -41.604676 -19.770519 \n", "\n", " channel3 \n", "0 43.177612 \n", "1 41.464399 \n", "2 27.639613 \n", "3 -17.186617 \n", "4 38.251473 \n", ".. ... \n", "123 14.329468 \n", "124 0.882024 \n", "125 4.854384 \n", "126 -12.327708 \n", "127 27.925069 \n", "\n", "[128 rows x 8 columns]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "n_epochs_per_category = 2\n", "sim_epochs_df, channels = fake_data._generate(\n", " n_epochs=n_epochs_per_category,\n", " n_samples=32,\n", " n_categories=2,\n", " n_channels=4,\n", " time=\"days\",\n", " epoch_id=\"epoch_id\",\n", " seed=10,\n", ")\n", "display(sim_epochs_df)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Example: EEG data**\n", "\n", "The epoch index column is `epoch_id`, there are 600 epochs numbered: 0, 1, 2, ..., 600. There are 600 not 601 epochs here because `epoch_id` 392 was excluded: the relevant event marked a pause in the recording not a stimulus. The epoch ids must be unique but they can be gappy and out of order.\n", "\n", "The time column is `time_ms`, there are 375 digital samples in each epoch at 4 ms intervals, -748, -744, ..., 744, 748\n", "\n", "The rest of the columns are the data recorded in each epoch at each time stamp." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/turbach/miniconda3/envs/mckonda_spudtr_dev/lib/python3.6/site-packages/pyarrow/pandas_compat.py:752: FutureWarning: .labels was deprecated in version 0.24.0. Use .codes instead.\n", " labels, = index.labels\n" ] }, { "data": { "text/plain": [ "600" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
epoch_idtime_mssub_ideeg_artifactdblock_pathlog_evcodeslog_ccodesdblock_srateccodeinstrument...RMOcLLTeRLTeLLOcRLOcMiOcA2HEOGrlerhz
00-748sub0000sub000/dblock_000250.01eeg...-25.093750-0.7539061.480469-13.414062-18.937500-17.7343755.66015698.875000-39.50000038.375000
10-744sub0000sub000/dblock_000250.01eeg...-24.5937500.502441-2.466797-17.640625-17.468750-15.3046881.968750104.750000-38.03125041.281250
20-740sub0000sub000/dblock_000250.01eeg...-16.484375-1.5078123.947266-15.648438-10.085938-11.1718758.367188102.062500-33.65625043.718750
30-736sub0000sub000/dblock_000250.01eeg...-11.804688-15.0703129.867188-14.906250-7.378906-8.7421889.351562100.562500-42.90625037.406250
40-732sub0000sub000/dblock_000250.01eeg...-6.394531-4.0195319.125000-10.679688-6.886719-8.0156258.12500098.375000-43.87500037.906250
..................................................................
224995600732sub0000sub000/dblock_400250.00cal...-4.671875-3.517578-4.441406-4.718750-4.671875-3.400391-4.429688-4.406250-3.900391-4.371094
224996600736sub0000sub000/dblock_400250.00cal...-4.179688-4.019531-4.195312-4.222656-4.425781-3.644531-4.429688-4.160156-3.412109-4.371094
224997600740sub0000sub000/dblock_400250.00cal...-4.425781-3.767578-4.441406-3.974609-4.425781-3.400391-4.429688-4.160156-3.900391-4.859375
224998600744sub0000sub000/dblock_400250.00cal...-4.425781-4.269531-4.195312-4.222656-4.425781-3.886719-4.429688-4.406250-3.900391-4.371094
224999600748sub0000sub000/dblock_400250.00cal...-4.179688-4.019531-3.947266-4.222656-4.179688-3.400391-4.183594-4.406250-3.412109-4.371094
\n", "

225000 rows × 47 columns

\n", "
" ], "text/plain": [ " epoch_id time_ms sub_id eeg_artifact dblock_path log_evcodes \\\n", "0 0 -748 sub000 0 sub000/dblock_0 0 \n", "1 0 -744 sub000 0 sub000/dblock_0 0 \n", "2 0 -740 sub000 0 sub000/dblock_0 0 \n", "3 0 -736 sub000 0 sub000/dblock_0 0 \n", "4 0 -732 sub000 0 sub000/dblock_0 0 \n", "... ... ... ... ... ... ... \n", "224995 600 732 sub000 0 sub000/dblock_4 0 \n", "224996 600 736 sub000 0 sub000/dblock_4 0 \n", "224997 600 740 sub000 0 sub000/dblock_4 0 \n", "224998 600 744 sub000 0 sub000/dblock_4 0 \n", "224999 600 748 sub000 0 sub000/dblock_4 0 \n", "\n", " log_ccodes dblock_srate ccode instrument ... RMOc LLTe \\\n", "0 0 250.0 1 eeg ... -25.093750 -0.753906 \n", "1 0 250.0 1 eeg ... -24.593750 0.502441 \n", "2 0 250.0 1 eeg ... -16.484375 -1.507812 \n", "3 0 250.0 1 eeg ... -11.804688 -15.070312 \n", "4 0 250.0 1 eeg ... -6.394531 -4.019531 \n", "... ... ... ... ... ... ... ... \n", "224995 0 250.0 0 cal ... -4.671875 -3.517578 \n", "224996 0 250.0 0 cal ... -4.179688 -4.019531 \n", "224997 0 250.0 0 cal ... -4.425781 -3.767578 \n", "224998 0 250.0 0 cal ... -4.425781 -4.269531 \n", "224999 0 250.0 0 cal ... -4.179688 -4.019531 \n", "\n", " RLTe LLOc RLOc MiOc A2 HEOG \\\n", "0 1.480469 -13.414062 -18.937500 -17.734375 5.660156 98.875000 \n", "1 -2.466797 -17.640625 -17.468750 -15.304688 1.968750 104.750000 \n", "2 3.947266 -15.648438 -10.085938 -11.171875 8.367188 102.062500 \n", "3 9.867188 -14.906250 -7.378906 -8.742188 9.351562 100.562500 \n", "4 9.125000 -10.679688 -6.886719 -8.015625 8.125000 98.375000 \n", "... ... ... ... ... ... ... \n", "224995 -4.441406 -4.718750 -4.671875 -3.400391 -4.429688 -4.406250 \n", "224996 -4.195312 -4.222656 -4.425781 -3.644531 -4.429688 -4.160156 \n", "224997 -4.441406 -3.974609 -4.425781 -3.400391 -4.429688 -4.160156 \n", "224998 -4.195312 -4.222656 -4.425781 -3.886719 -4.429688 -4.406250 \n", "224999 -3.947266 -4.222656 -4.179688 -3.400391 -4.183594 -4.406250 \n", "\n", " rle rhz \n", "0 -39.500000 38.375000 \n", "1 -38.031250 41.281250 \n", "2 -33.656250 43.718750 \n", "3 -42.906250 37.406250 \n", "4 -43.875000 37.906250 \n", "... ... ... \n", "224995 -3.900391 -4.371094 \n", "224996 -3.412109 -4.371094 \n", "224997 -3.900391 -4.859375 \n", "224998 -3.900391 -4.371094 \n", "224999 -3.412109 -4.371094 \n", "\n", "[225000 rows x 47 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eeg_epochs_df = get_demo_df(P3_1500_FEATHER)\n", "display(len(eeg_epochs_df[\"epoch_id\"].unique()))\n", "eeg_epochs_df" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
epoch_idtime_mssub_ideeg_artifactdblock_pathlog_evcodeslog_ccodesdblock_srateccodeinstrument...RMOcLLTeRLTeLLOcRLOcMiOcA2HEOGrlerhz
\n", "

0 rows × 47 columns

\n", "
" ], "text/plain": [ "Empty DataFrame\n", "Columns: [epoch_id, time_ms, sub_id, eeg_artifact, dblock_path, log_evcodes, log_ccodes, dblock_srate, ccode, instrument, bin, tone, stim, accuracy, acc_type, lle, lhz, MiPf, LLPf, RLPf, LMPf, RMPf, LDFr, RDFr, LLFr, RLFr, LMFr, RMFr, LMCe, RMCe, MiCe, MiPa, LDCe, RDCe, LDPa, RDPa, LMOc, RMOc, LLTe, RLTe, LLOc, RLOc, MiOc, A2, HEOG, rle, rhz]\n", "Index: []\n", "\n", "[0 rows x 47 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "eeg_epochs_df.query(\"epoch_id == 392\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Always check the epoch x time format**\n", "\n", "When things go well the check quietly succeeds.\n", "\n", "When they don't the reason appears at the bottom of the messages." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: This check of the simulated data **SUCCEEDS**." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "epf.check_epochs(sim_epochs_df, ['channel0', 'channel1'], epoch_id=\"epoch_id\", time=\"days\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: this checks **FAILS** because the data column named \"bogus_channel0\" doesn't exist in the data." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "tags": [ "raises-exception" ] }, "outputs": [ { "ename": "ValueError", "evalue": "data_streams should all be present in the epochs dataframe, the following are missing: ['bogus_channel0']", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mepf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcheck_epochs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim_epochs_df\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'bogus_channel0'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'channel1'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mepoch_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"epoch_id\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"days\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/mnt/cube/home/turbach/TPU_Projects/spudtr/spudtr/epf.py\u001b[0m in \u001b[0;36mcheck_epochs\u001b[0;34m(epochs_df, data_streams, epoch_id, time)\u001b[0m\n\u001b[1;32m 183\u001b[0m \"\"\"\n\u001b[1;32m 184\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 185\u001b[0;31m \u001b[0m_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_epochs_QC\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mepochs_df\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata_streams\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mepoch_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mepoch_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtime\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 186\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/mnt/cube/home/turbach/TPU_Projects/spudtr/spudtr/epf.py\u001b[0m in \u001b[0;36m_epochs_QC\u001b[0;34m(epochs_df, data_streams, epoch_id, time)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmissing_channels\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 49\u001b[0m raise ValueError(\n\u001b[0;32m---> 50\u001b[0;31m \u001b[0;34m\"data_streams should all be present in the epochs dataframe, \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 51\u001b[0m \u001b[0;34mf\"the following are missing: {list(missing_channels)}\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 52\u001b[0m )\n", "\u001b[0;31mValueError\u001b[0m: data_streams should all be present in the epochs dataframe, the following are missing: ['bogus_channel0']" ] } ], "source": [ "epf.check_epochs(sim_epochs_df, ['bogus_channel0', 'channel1'], epoch_id=\"epoch_id\", time=\"days\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Example: this checks **FAILS** because the `time` column named \"hours\" doesn't exist." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "tags": [ "raises-exception" ] }, "outputs": [ { "ename": "ValueError", "evalue": "time column not found: hours", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mepf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcheck_epochs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msim_epochs_df\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m'channel0'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'channel1'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mepoch_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"epoch_id\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"hours\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/mnt/cube/home/turbach/TPU_Projects/spudtr/spudtr/epf.py\u001b[0m in \u001b[0;36mcheck_epochs\u001b[0;34m(epochs_df, data_streams, epoch_id, time)\u001b[0m\n\u001b[1;32m 183\u001b[0m \"\"\"\n\u001b[1;32m 184\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 185\u001b[0;31m \u001b[0m_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_epochs_QC\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mepochs_df\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata_streams\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mepoch_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mepoch_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtime\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 186\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/mnt/cube/home/turbach/TPU_Projects/spudtr/spudtr/epf.py\u001b[0m in \u001b[0;36m_epochs_QC\u001b[0;34m(epochs_df, data_streams, epoch_id, time)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 59\u001b[0m \u001b[0;31m# epoch_id and time must be the columns in the epochs_df\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 60\u001b[0;31m \u001b[0m_validate_epochs_df\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mepochs_df\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mepoch_id\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mepoch_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtime\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 61\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 62\u001b[0m \u001b[0;31m# check values of epoch_id in every time group are the same, and\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/mnt/cube/home/turbach/TPU_Projects/spudtr/spudtr/epf.py\u001b[0m in \u001b[0;36m_validate_epochs_df\u001b[0;34m(epochs_df, epoch_id, time)\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mval\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m\"epoch_id\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mepoch_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"time\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mval\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mepochs_df\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 30\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"{key} column not found: {val}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: time column not found: hours" ] } ], "source": [ "epf.check_epochs(sim_epochs_df, ['channel0', 'channel1'], epoch_id=\"epoch_id\", time=\"hours\")" ] } ], "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.10" } }, "nbformat": 4, "nbformat_minor": 2 }