Revision 74dd6553270f3414107798f04ad927168d2dbbae authored by gviejo on 17 December 2021, 20:06:22 UTC, committed by gviejo on 17 December 2021, 20:06:22 UTC
1 parent 026b303
SleepReplay.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 22,
"id": "7ed11c8d",
"metadata": {},
"outputs": [],
"source": [
"import pynapple as nap\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "c41269ae",
"metadata": {},
"outputs": [],
"source": [
"sessionEpoch = nap.IntervalSet(start = 0, end = 3000)\n",
"spikes = {}\n",
"for s in range(50):\n",
" random_times = np.random.uniform(0, 15, 10)\n",
" random_times = np.sort(random_times)\n",
" my_spike = nap.Ts(random_times, time_units = 's')\n",
" spikes[s] = my_spike\n",
" \n",
"##spikeGrp = nap.TsGroup(data = spikes)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "df8475f6",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'TsGroup' object has no attribute '_update_time_support'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_22320/1822310322.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mspikeGrp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnap\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTsGroup\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mspikes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtime_support\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msessionEpoch\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32mc:\\users\\apeyra4\\documents\\toolbox\\pynapple\\pynapple\\core\\ts_group.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, data, time_support, *args, **kwargs)\u001b[0m\n\u001b[0;32m 31\u001b[0m \t\t\t\t\t\t -1 * np.ones(len(time)//2, dtype=np.int32)))\n\u001b[0;32m 32\u001b[0m \u001b[0mdf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDataFrame\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m{\u001b[0m\u001b[1;34m'time'\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mtime\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'start_end'\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mstart_end\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 33\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msort_values\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mby\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'time'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0minplace\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 34\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mreset_index\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0minplace\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdrop\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 35\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'cumsum'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'start_end'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcumsum\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'TsGroup' object has no attribute '_update_time_support'"
]
}
],
"source": [
"spikeGrp = nap.TsGroup(data = spikes, time_support = sessionEpoch)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "8d8d17b7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>start</th>\n",
" <th>end</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>481080</td>\n",
" <td>14015002</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" start end\n",
"0 0.48108 14.015002"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"spikes[0].time_support"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14c6f3e3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.8.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

Computing file changes ...