Topology in neuroscience
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1259 lines
3.1 MiB

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import scipy.stats as sts\n",
"import pickle"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"execfile('Stimulus.py')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"data_folder = \"Data/\"\n",
"\n",
"stim_file = \"Stiminfo_PVCre_2021_0012_s06_e14.csv\"\n",
"stim = pd.read_csv(data_folder+stim_file)\n",
"\n",
"spike_times_file = \"Spiketimes_PVCre_2021_0012_s06_e14.npy\"\n",
"spike_times = np.load(data_folder+spike_times_file, allow_pickle=True)\n",
"active = [len(spike_times[i]) > 0 for i in range(len(spike_times))]\n",
"spike_times = spike_times[np.where(active)]\n",
"\n",
"num_unit = len(spike_times)\n",
"num_trial = len(stim)\n",
"\n",
"# sort by firing rate\n",
"\n",
"num_spike = list(map(len, spike_times))\n",
"# num_spike = np.array([len(spike_times[i]) for i in range(len(spike_times))])\n",
"spike_times = spike_times[np.argsort(num_spike)[::-1]]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"stim_data.pkl\n",
"dict_keys(['stim_val', 'trial_stim_id', 'key_list', 'num_trial', 'trial_pair_id', 'pair_val', 'pair_trial_id', 'stim_id_trial', 'num_stim'])\n",
"spike_data.pkl\n",
"dict_keys(['spike_count_rate', 'avg_firing_rate', 'sem_firing_rate', 'firing_rate', 'stim_num_trial', 'C_r_fphi_theta', 'theta_hist', 'phase_hist', 'pair_hist'])\n",
"corr_data.pkl\n",
"dict_keys(['corr_stim_unit', 'optimal_avg_firing_rate', 'stim_hist', 'stim_hist_caution'])\n"
]
}
],
"source": [
"execfile('load.py')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Spike count rate"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"spike_count_rate = np.zeros((num_unit, num_trial))\n",
"for trial_id in range(num_trial):\n",
" t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
" for unit_id in range(num_unit):\n",
" spike_count_rate[unit_id, trial_id] = np.sum((spike_times[unit_id] < t_off) & (spike_times[unit_id] > t_on))\n",
" \n",
" spike_count_rate[:, trial_id] /= t_off-t_on"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Judging by PSTH, try counting the spikes only towards the end of each trial. Each trial is 84 ms long and we count the spikes over (50, 90) for each trial."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"spike_count_rate = np.zeros((num_unit, num_trial))\n",
"for trial_id in range(num_trial):\n",
" t_on, t_off = stim['stim_ontime'][trial_id]+0.050, stim['stim_offtime'][trial_id]+0.084 - 0.084\n",
" for unit_id in range(num_unit):\n",
" spike_count_rate[unit_id, trial_id] = np.sum((spike_times[unit_id] < t_off) & (spike_times[unit_id] > t_on))\n",
" \n",
" spike_count_rate[:, trial_id] /= t_off-t_on"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Average firing rate"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"avg_firing_rate = {}\n",
"sem_firing_rate = {}\n",
"for key in stim_id_trial:\n",
" avg_firing_rate[key] = np.array([np.mean(spike_count_rate[:, stim_id_trial[key][i]], axis=1) for i in range(num_stim[key])]).T\n",
" sem_firing_rate[key] = np.array([np.std(spike_count_rate[:, stim_id_trial[key][i]], axis=1)/np.sqrt(len(stim_id_trial[key][i])) for i in range(num_stim[key])]).T\n",
"\n",
"# for each stim pair, gives the population activity averaged over 50 trials (transpose)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# mean_firing_rate[unit_id, orientation_id, phase_id]\n",
"avg_firing_rate_pair = np.zeros((num_unit, num_stim['orientation'], num_stim['phase']))\n",
"for i in range(num_stim['pair']):\n",
" avg_firing_rate_pair[:, i//20, i%20] = np.mean(spike_count_rate[:, stim_id_trial['pair'][i]], axis=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Firing rate"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# concatenate spike times of all trials with the same stimuli\n",
"# firing rate\n",
"trial_spike_times = np.ndarray((num_unit, num_trial), dtype=object)\n",
"delta_t_on = 0.02 # 20ms\n",
"delta_t_off = 0.2\n",
"for trial_id in range(num_trial):\n",
" t_on, t_off = stim['stim_ontime'][trial_id]-delta_t_on, stim['stim_offtime'][trial_id]+delta_t_off\n",
" for unit_id in range(num_unit):\n",
" trial_spike_times[unit_id, trial_id] = spike_times[unit_id][np.where((spike_times[unit_id] < t_off) & (spike_times[unit_id] > t_on))] - t_on\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"max_dur = max(stim['stim_offtime']-stim['stim_ontime'])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"time_bin = 0.001 # 1ms\n",
"T = delta_t_on + delta_t_off + max_dur\n",
"time_bin_edges = np.arange(0, T+time_bin, time_bin)\n",
"num_bins = len(time_bin_edges)-1\n",
"\n",
"firing_rate = {}\n",
"\n",
"for key in key_list:\n",
" firing_rate[key] = np.zeros((num_unit, num_stim[key], num_bins))\n",
" for stim_id, trials in enumerate(stim_id_trial[key]):\n",
" for unit_id in range(num_unit):\n",
" cumulative_spike_times = np.concatenate(trial_spike_times[unit_id, trials])\n",
" for t in cumulative_spike_times:\n",
" firing_rate[key][unit_id, stim_id, int(t//time_bin)] += 1\n",
" # firing_rate[key][unit_id, stim_id] = np.histogram(cumulative_spike_times, time_bin_edges)\n",
" \n",
" firing_rate[key] /= time_bin*len(trials)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"stim_num_trial = {'pair':50, 'orientation':1000, 'phase':1000}"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"time_bin = 0.001 # 1ms\n",
"delta_t_on = 0.02 # 20ms\n",
"delta_t_off = 0.2\n",
"max_dur = max(stim['stim_offtime']-stim['stim_ontime'])\n",
"\n",
"T = delta_t_on + delta_t_off + max_dur\n",
"time_bin_edges = np.arange(0, T+time_bin, time_bin)\n",
"num_bins = len(time_bin_edges) - 1"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"latest_spike_time = max([np.max(s) for s in spike_times if len(s)])\n",
"latest_stim_offtime = list(stim['stim_offtime'])[-1]\n",
"experiment_dur = max([latest_spike_time, latest_stim_offtime])"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets # interactive display"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "xmin must be a single scalar value, but got g--",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mc:\\Users\\arash\\Documents\\WiSe2022\\Research Project (Topology)\\staticgrating-phasefreq-topology\\01_Firing_Rate.ipynb Cell 20'\u001b[0m in \u001b[0;36m<cell line: 11>\u001b[1;34m()\u001b[0m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/WiSe2022/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000019?line=8'>9</a>\u001b[0m plt\u001b[39m.\u001b[39mplot(time, firing_rate[key][unit_id, stim_id])\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/WiSe2022/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000019?line=9'>10</a>\u001b[0m plt\u001b[39m.\u001b[39maxhline(avg_firing_rate[key][unit_id, stim_id])\n\u001b[1;32m---> <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/WiSe2022/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000019?line=10'>11</a>\u001b[0m plt\u001b[39m.\u001b[39;49maxhline(np\u001b[39m.\u001b[39;49mmean(avg_firing_rate[\u001b[39m'\u001b[39;49m\u001b[39mpair\u001b[39;49m\u001b[39m'\u001b[39;49m][unit_id]), \u001b[39m'\u001b[39;49m\u001b[39mg--\u001b[39;49m\u001b[39m'\u001b[39;49m)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/WiSe2022/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000019?line=11'>12</a>\u001b[0m plt\u001b[39m.\u001b[39maxhline(\u001b[39mlen\u001b[39m(spike_times[unit_id])\u001b[39m/\u001b[39mexperiment_dur, \u001b[39m'\u001b[39m\u001b[39mb--\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/WiSe2022/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000019?line=13'>14</a>\u001b[0m \u001b[39mif\u001b[39;00m key \u001b[39m==\u001b[39m \u001b[39m'\u001b[39m\u001b[39mpair\u001b[39m\u001b[39m'\u001b[39m:\n",
"File \u001b[1;32mc:\\Users\\arash\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\matplotlib\\pyplot.py:2349\u001b[0m, in \u001b[0;36maxhline\u001b[1;34m(y, xmin, xmax, **kwargs)\u001b[0m\n\u001b[0;32m 2347\u001b[0m \u001b[39m@_copy_docstring_and_deprecators\u001b[39m(Axes\u001b[39m.\u001b[39maxhline)\n\u001b[0;32m 2348\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39maxhline\u001b[39m(y\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m, xmin\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m, xmax\u001b[39m=\u001b[39m\u001b[39m1\u001b[39m, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m-> 2349\u001b[0m \u001b[39mreturn\u001b[39;00m gca()\u001b[39m.\u001b[39;49maxhline(y\u001b[39m=\u001b[39;49my, xmin\u001b[39m=\u001b[39;49mxmin, xmax\u001b[39m=\u001b[39;49mxmax, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
"File \u001b[1;32mc:\\Users\\arash\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\matplotlib\\axes\\_axes.py:726\u001b[0m, in \u001b[0;36mAxes.axhline\u001b[1;34m(self, y, xmin, xmax, **kwargs)\u001b[0m\n\u001b[0;32m 675\u001b[0m \u001b[39m@docstring\u001b[39m\u001b[39m.\u001b[39mdedent_interpd\n\u001b[0;32m 676\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39maxhline\u001b[39m(\u001b[39mself\u001b[39m, y\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m, xmin\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m, xmax\u001b[39m=\u001b[39m\u001b[39m1\u001b[39m, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[0;32m 677\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[0;32m 678\u001b[0m \u001b[39m Add a horizontal line across the axis.\u001b[39;00m\n\u001b[0;32m 679\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 724\u001b[0m \u001b[39m >>> axhline(y=.5, xmin=0.25, xmax=0.75)\u001b[39;00m\n\u001b[0;32m 725\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 726\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_check_no_units([xmin, xmax], [\u001b[39m'\u001b[39;49m\u001b[39mxmin\u001b[39;49m\u001b[39m'\u001b[39;49m, \u001b[39m'\u001b[39;49m\u001b[39mxmax\u001b[39;49m\u001b[39m'\u001b[39;49m])\n\u001b[0;32m 727\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mtransform\u001b[39m\u001b[39m\"\u001b[39m \u001b[39min\u001b[39;00m kwargs:\n\u001b[0;32m 728\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39m'\u001b[39m\u001b[39mtransform\u001b[39m\u001b[39m'\u001b[39m\u001b[39m is not allowed as a keyword \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 729\u001b[0m \u001b[39m\"\u001b[39m\u001b[39margument; axhline generates its own transform.\u001b[39m\u001b[39m\"\u001b[39m)\n",
"File \u001b[1;32mc:\\Users\\arash\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\matplotlib\\axes\\_axes.py:814\u001b[0m, in \u001b[0;36mAxes._check_no_units\u001b[1;34m(vals, names)\u001b[0m\n\u001b[0;32m 812\u001b[0m \u001b[39mfor\u001b[39;00m val, name \u001b[39min\u001b[39;00m \u001b[39mzip\u001b[39m(vals, names):\n\u001b[0;32m 813\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m munits\u001b[39m.\u001b[39m_is_natively_supported(val):\n\u001b[1;32m--> 814\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39m{\u001b[39;00mname\u001b[39m}\u001b[39;00m\u001b[39m must be a single scalar value, \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m 815\u001b[0m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mbut got \u001b[39m\u001b[39m{\u001b[39;00mval\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m)\n",
"\u001b[1;31mValueError\u001b[0m: xmin must be a single scalar value, but got g--"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABfUklEQVR4nO29eZwcV30tfm4tvc30bJrRMtrlRfKCV9l4YTWLjSHYJISEJGBeSIAAv5DwSB4JIT/yeGExCYS8YAhrgLCGzYQ1xhvEYGHZluVNtiVZkqUZaUaavdda7vuj6t66VV0900tVL+p7Ph99NNMz0327uurUuee7EUopJCQkJCS6D0q7FyAhISEh0RgkgUtISEh0KSSBS0hISHQpJIFLSEhIdCkkgUtISEh0KbRWvtjo6CjdsmVLK19SQkJCoutx//33n6SUjgUfbymBb9myBbt3727lS0pISEh0PQghh8MelxaKhISERJdCEriEhIREl0ISuISEhESXQhK4hISERJdCEriEhIREl0ISuISEhESXQhK4hISERJdCEriEhETH4cipPO5+crrdy+h4tLSQR0JCQqIWvPhjd6Ns2jj0oZe3eykdDanAJSQkOg5l0wYAyIEzy0MSuISERMei5BK5RDgkgUtUYGqx2O4lnBaYzxsomVa7l9HVyJcrj1/ZtDGbK7dhNZ0HSeASPjxwZBbP/sDtOHwq1+6ldD1uvOUefOqug+1eRldCIc7/uZJZ8bN3f2cvLn7/bTAtqc4lgUv4ML1YAqXAySWpcJrFiYUiTsjdTENI6yqAcAX+8ydPAgAen1xs6Zo6EZLAJXywbSdoZEh10zQMy+bBOIn6kE44BJ4rVyrwizYOAQDuOzTTyiV1JCSBS/hgugRuWjL63wwopTAsKgm8QSQ1V4GXKhX4aH8CALD7sCRwSeASPthu2pZhS+JpBoYldzLNYDkFzo7t7kOzLV1TJ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vqSGQsgEa4lwTMwVsMoN/k4tlPjjvJmV3PavCEopvvbrI/g5I3BT8MBNz0IBgDd/uaEyip4FdZtZ/c7OjXjPy89Bf1JDvmxWZKFIAu8CvO2FZ+KW378UN121BTb1F0Y4Wy0CXSUy2l8jSqaF6cUSto318e8ZbJlGWDPKbrobV94BBS5OiDpzdX9b1titYDvrCzcO4aartkBXiXtcXQXuZqH0+jXfFQTOkNYdRVMsex8aC3YkNUWSTo04Me8o7q2jDoEXhUi+7IVSO9h5yFQgIxfTpigaNnTVGwN23vhA6xfYZRB7gJu2f4xaQlVhUy8lUypwB11J4AUhed90LRSWsvXYxALu2X+yXUvsChxzM1C2jTmqUCzoYUFMm0IO410BRXfn4hG4Rya5sgld9S4v1SWjO/adwP6p8IyqXkdesEBNi0IRCVxzjmXBnVKvqQQJVZUKvN0LqAfpRCWB2y6B66pzN77lrv147/ceadcSuwIsaLl5JAPAX2gikrZU4cuDxVyYdSIer6WiCV1TcPGmIQDezuad33wIn/vvp1u70C7BYtGbQG/aNh/oAIDvZnIl55jrioL+lIZc2ezp87SrCDzlKvBFYUaeRV0F7loohbKFXNms9hQS8Lo2jg+lAfgVuEjgsphneTAhUTb9Vgrg9KdPqAq++9arccZYHyxKYVo25vIG8vL8DIV4XRuWE9tiSLoKPC8o8PHBFCiFL4uq19BVBM4slOlFL2vCtp2KLYfAKYqmJbNRVsBsvgyFAKsHnB4yVRV4j29PVwIncMvvgQPOMWWqUVMUWBbFXMEhKHl+hmOh6L+xhVkozGbRVcIFyMScJPCuALNQphb9aW+qAu43LpUsX1BOwgkOMd8bcBT4cCbhBYVFBS4Ekgw3ZUv8WwkPRZdMjBALBfDOSVUhMG3Ke/UUerwBUzUsBqbP+y0U51iy6TyaonA
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# PSTH\n",
"\n",
"unit_id = 1\n",
"key = 'orientation'\n",
"stim_id = 4\n",
"\n",
"time = (time_bin_edges[:-1] - delta_t_on)/time_bin\n",
"stim_time = np.arange(0, max_dur, time_bin)/time_bin\n",
"plt.plot(time, firing_rate[key][unit_id, stim_id])\n",
"plt.axhline(avg_firing_rate[key][unit_id, stim_id])\n",
"plt.axhline(np.mean(avg_firing_rate['pair'][unit_id]), 'g--')\n",
"plt.axhline(len(spike_times[unit_id])/experiment_dur, 'b--')\n",
"\n",
"if key == 'pair':\n",
" plt.hlines(stim_time, -1*np.ones(len(stim_time)), 'r-', label=' $\\\\theta = %d' %stim_val[key][stim_id][0]+'^\\circ$\\n $\\phi = %d' %stim_val[key][stim_id][1]+'^\\circ$')\n",
"\n",
"else:\n",
" plt.plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label='stimulus: '+key+' = $%d' %stim_val[key][stim_id]+'^\\circ$')\n",
"\n",
"plt.ylabel('firing rate/Hz')\n",
"plt.xlabel('t/ms')\n",
"plt.suptitle('PSTH ' + '%d'%stim_num_trial[key] + ' trials - unit '+'%d'%unit_id)\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 83,
"metadata": {},
"outputs": [],
"source": [
"# sliding window\n",
"n = 80\n",
"kernel = np.ones(n)/n\n",
"smooth_firing_rate = {}\n",
"for key in key_list:\n",
" smooth_firing_rate[key] = np.zeros((num_unit, num_stim[key], num_bins))\n",
" for unit_id in range(num_unit):\n",
" for stim_id in range(num_stim[key]):\n",
" smooth_firing_rate[key][unit_id, stim_id] = np.convolve(firing_rate[key][unit_id, stim_id], kernel)[int(n//2):int(n//2)+num_bins]"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"200.0"
]
},
"execution_count": 84,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"max([np.max(firing_rate[key]) for key in key_list])"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5a1e3d6fdb96409781ab702eb7fd0a49",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(RadioButtons(description='stimulus:', options=('pair', 'orientation', 'phase'), value='p…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# key = 'orientation'\n",
"time = (time_bin_edges[:-1] - delta_t_on)/time_bin\n",
"stim_time = np.arange(0, max_dur, time_bin)/time_bin\n",
"\n",
"# @widgets.interact(stim_id=widgets.FloatSlider(0, min=0, max=1, step=0.01),\n",
"# key=widgets.RadioButtons(\n",
"# options=key_list,\n",
"# # value='pineapple', # Defaults to 'pineapple'\n",
"# # layout={'width': 'max-content'}, # If the items' names are long\n",
"# description='stimulus:',\n",
"# disabled=False\n",
"# ))\n",
"\n",
"@widgets.interact(key=widgets.RadioButtons(\n",
" options=key_list,\n",
"# value='pineapple', # Defaults to 'pineapple'\n",
"# layout={'width': 'max-content'}, # If the items' names are long\n",
" description='stimulus:',\n",
" disabled=False\n",
"))\n",
"\n",
"def PSTH_key(key):\n",
" if key=='pair':\n",
" @widgets.interact(phi=widgets.IntSlider(0, min=0, max=19), theta=widgets.IntSlider(0, min=0, max=19))\n",
" \n",
" def PSTH(phi, theta):\n",
" stim_id = theta*20 + phi\n",
"\n",
" # stim_id = int(np.floor(stim_id * num_stim[key]))\n",
" fig, ax = plt.subplots(1, 4, figsize=(5*4,1*4))\n",
" for unit_id in range(4):\n",
" ax[unit_id%4].plot(time, smooth_firing_rate[key][unit_id, stim_id])\n",
" ax[unit_id%4].plot(time, avg_firing_rate[key][unit_id, stim_id] * np.ones(len(time)))\n",
" ax[unit_id%4].plot(time, np.mean(avg_firing_rate['pair'][unit_id]) * np.ones(len(time)), 'g--')\n",
" ax[unit_id%4].plot(time, len(spike_times[unit_id])/experiment_dur * np.ones(len(time)), 'b--')\n",
"\n",
" if key == 'pair':\n",
" ax[unit_id%4].plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label=' $\\\\theta = %d' %stim_val[key][stim_id][0]+'^\\circ$\\n $\\phi = %d' %stim_val[key][stim_id][1]+'^\\circ$')\n",
"\n",
" else:\n",
" ax[unit_id%4].plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label='stimulus: '+key+' = $%d' %stim_val[key][stim_id]+'^\\circ$')\n",
"\n",
" ax[unit_id%4].set_ylabel('firing rate/Hz')\n",
" ax[unit_id%4].set_xlabel('t/ms')\n",
" ax[unit_id%4].set_ylim([-2,200])\n",
" ax[unit_id%4].set_title('PSTH ' + '%d'%stim_num_trial[key] + ' trials - unit '+'%d'%unit_id)\n",
" ax[unit_id%4].legend(loc='upper center')\n",
" plt.show()\n",
"\n",
" else:\n",
" @widgets.interact(stim_id=widgets.IntSlider(0, min=0, max=19))\n",
" \n",
" def PSTH(stim_id):\n",
"\n",
" # stim_id = int(np.floor(stim_id * num_stim[key]))\n",
" fig, ax = plt.subplots(1, 4, figsize=(5*4,1*4))\n",
" for unit_id in range(4):\n",
" ax[unit_id%4].plot(time, smooth_firing_rate[key][unit_id, stim_id])\n",
" ax[unit_id%4].plot(time, avg_firing_rate[key][unit_id, stim_id] * np.ones(len(time)))\n",
" ax[unit_id%4].plot(time, np.mean(avg_firing_rate['pair'][unit_id]) * np.ones(len(time)), 'g--')\n",
" ax[unit_id%4].plot(time, len(spike_times[unit_id])/experiment_dur * np.ones(len(time)), 'b--')\n",
"\n",
" if key == 'pair':\n",
" ax[unit_id%4].plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label=' $\\\\theta = %d' %stim_val[key][stim_id][0]+'^\\circ$\\n $\\phi = %d' %stim_val[key][stim_id][1]+'^\\circ$')\n",
"\n",
" else:\n",
" ax[unit_id%4].plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label='stimulus: '+key+' = $%d' %stim_val[key][stim_id]+'^\\circ$')\n",
"\n",
" ax[unit_id%4].set_ylabel('firing rate/Hz')\n",
" ax[unit_id%4].set_xlabel('t/ms')\n",
" ax[unit_id%4].set_ylim([-2,200])\n",
" ax[unit_id%4].set_title('PSTH ' + '%d'%stim_num_trial[key] + ' trials - unit '+'%d'%unit_id)\n",
" ax[unit_id%4].legend(loc='upper center')\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "aff3a076e2af43c98ae29831b41297e9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(RadioButtons(description='stimulus:', options=('pair', 'orientation', 'phase'), value='p…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# key = 'orientation'\n",
"time = (time_bin_edges[:-1] - delta_t_on)/time_bin\n",
"stim_time = np.arange(0, max_dur, time_bin)/time_bin\n",
"\n",
"@widgets.interact(stim_id=widgets.FloatSlider(0, min=0, max=1, step=0.01),\n",
" key=widgets.RadioButtons(\n",
" options=key_list,\n",
"# value='pineapple', # Defaults to 'pineapple'\n",
"# layout={'width': 'max-content'}, # If the items' names are long\n",
" description='stimulus:',\n",
" disabled=False\n",
"))\n",
"\n",
"def PSTH(key, stim_id):\n",
" stim_id = int(np.floor(stim_id * num_stim[key]))\n",
" fig, ax = plt.subplots(10, 4, figsize=(5*4,10*4))\n",
" for unit_id in range(num_unit):\n",
" ax[unit_id//4, unit_id%4].plot(time, smooth_firing_rate[key][unit_id, stim_id])\n",
" ax[unit_id//4, unit_id%4].plot(time, avg_firing_rate[key][unit_id, stim_id] * np.ones(len(time)))\n",
" ax[unit_id//4, unit_id%4].plot(time, np.mean(avg_firing_rate['pair'][unit_id]) * np.ones(len(time)), 'g--')\n",
" ax[unit_id//4, unit_id%4].plot(time, len(spike_times[unit_id])/experiment_dur * np.ones(len(time)), 'b--')\n",
"\n",
" if key == 'pair':\n",
" ax[unit_id//4, unit_id%4].plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label=' $\\\\theta = %d' %stim_val[key][stim_id][0]+'^\\circ$\\n $\\phi = %d' %stim_val[key][stim_id][1]+'^\\circ$')\n",
"\n",
" else:\n",
" ax[unit_id//4, unit_id%4].plot(stim_time, -1*np.ones(len(stim_time)), 'r-', label='stimulus: '+key+' = $%d' %stim_val[key][stim_id]+'^\\circ$')\n",
"\n",
" ax[unit_id//4, unit_id%4].set_ylabel('firing rate/Hz')\n",
" ax[unit_id//4, unit_id%4].set_xlabel('t/ms')\n",
" ax[unit_id//4, unit_id%4].set_ylim([-2,200])\n",
" ax[unit_id//4, unit_id%4].set_title('PSTH ' + '%d'%stim_num_trial[key] + ' trials - unit '+'%d'%unit_id)\n",
" ax[unit_id//4, unit_id%4].legend(loc='upper center')\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Subtract average phase response"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"r_fphi = np.copy(spike_count_rate)\n",
"for stim_id, trials in enumerate(stim_id_trial['phase']):\n",
" for unit_id in range(num_unit):\n",
" r_fphi[unit_id, trials] -= avg_firing_rate['phase'][unit_id, stim_id]\n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1.69541249e-03, 3.22163614e+01, 2.03681866e+00, ...,\n",
" 2.90363390e+00, -2.78436986e+01, 3.35952210e+01],\n",
" [ 6.81509867e+01, -2.28685128e+01, -2.80524644e+01, ...,\n",
" -2.65551073e+01, -2.28685128e+01, -2.37690514e+01],\n",
" [ 1.30971358e+01, -1.61529328e+01, -1.69339763e+01, ...,\n",
" -1.60046681e+01, 1.38770972e+01, -1.74139233e+01],\n",
" ...,\n",
" [-6.00600601e-02, -5.97908660e-02, -2.99401198e-02, ...,\n",
" 0.00000000e+00, -5.97908660e-02, 0.00000000e+00],\n",
" [-3.00300300e-02, 0.00000000e+00, 0.00000000e+00, ...,\n",
" 0.00000000e+00, 0.00000000e+00, -2.99401198e-02],\n",
" [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n",
" 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"r_fphi"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"theta = np.copy(stim['grat_orientation'])"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(20000,)"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"theta.shape"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"C_r_fphi_theta = [np.convolve(r_fphi[unit_id], theta[::-1])[::-1] for unit_id in range(num_unit)] # reverse correlation"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x24ae2bd0460>]"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAAEDCAYAAADHmORTAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAuhElEQVR4nO3dd3wUdfoH8M+TkEIJPXQwdKSDAZQmTQRRsXue5w/P3k7PjmLBehwqomc7FM5eELsoTZCqQCihl1CUTgIEAiGkfX9/7CTZzfbdKbuzn/frxcvdmdmZx9nkyXe+VZRSICKi6BZndQBERBQ+JnMiIhtgMicisgEmcyIiG2AyJyKyASZzIiIbsCyZi8g0ETksIhsCPP4aEdkkIhtF5FOj4yMiiiZiVT9zERkI4CSAD5VSnf0c2xbAdABDlFLHRKSBUuqwGXESEUUDy0rmSqlFAI46bxOR1iIyS0RWichiEemg7boVwJtKqWPaZ5nIiYicRFqd+RQA/1BKnQPgIQBvadvbAWgnIktF5HcRGWFZhEREEaiK1QGUEZEaAPoC+FJEyjYnaf+tAqAtgEEAmgF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Y0rtlXXxwU2+37cvGDkGnJtHd4OnPjFV7ve4TrWf9sVOFeHNBVsRWZ3yy/A9MmrsNpwu5ohS5YzK32Mx1B0y93vntUvH29T1dtjWpXdXUGKwwZdFOLM3KKX+v4F7SHfv1Orw0eyt+23nE3OAC9PKcbXj9l+14bqY1XVcpsjGZW+z7zH2mXatsZOfILo0Nv1aVCJw68fr3lpffg5y8MxULZWsb87USb3FJ4CXzQycKcKK
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(C_r_fphi_theta[0])"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([13505, 24614, 24976, 28254, 27733, 13139, 14842, 13004, 13395,\n",
" 13337, 13460, 12405, 26205, 5522, 24844, 13343, 13603, 24607,\n",
" 5545, 27818, 24654, 4900, 12822, 23467, 32994, 24963, 4929,\n",
" 13537, 23406, 32700, 32950, 22641, 33750, 27543, 9353, 25907,\n",
" 27023, 25357, 20291, 33125], dtype=int64)"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.argmax(C_r_fphi_theta, axis=1)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"autocorr_theta = np.convolve(theta, theta[::-1])"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x24ae22ba5b0>]"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEDCAYAAAA7jc+ZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAmlUlEQVR4nO3deZgU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+XHfvVtaA+CLZ9q+NX3Pe3a8mtM0deR7DehwdUkX7jTj3GF6+7pyEtjPGz2LDFp2glepTYdC7+xygzL8v3f1Nd/8iWHyb2CTgIqH4xZMLOOeuVxLa7vzuSRzerHE4BaXRMb8pP+yZ+J9Oj7Evc/uLS0OqSKIu2330lwPx30ZxYIaZzTez4eU90MyGm1mxmRWXlJRkuSypCybMWck/FyVO0j3/pr58/7S2IVVUtrHfOZFXf9M7oe3h11fzdPHa9A8QOQBZC3ozO5dY0P82rvksd+8ODARGmNnZZT3e3Se4e6G7F+bn52erLKkjBv73a9wx5cOEtteuP5fDmjYKqaKKtTusCbOSunGuf3Yx1z61MJyCJLKyEvRmdhLwMDDE3Tfua3f39cG/G4DngR7ZeD2ReAVFk/ngk68S2t6/tT9tWx4cUkWZ65DflCW39k9oe37Bev793tdDqkii6ICD3syOBp4DLnb3j+Lam5hZs333gX5A2it3RKqqrLHkm8RN/ZfrmjaqnzLM8Xvrv9SQCZI1mVxe+STwFnCcma0zs8vN7AozuyLY5GbgMOD+pMsojwBeN7NFwFxgsrtPS3kBkSpwTz+/69Srv1WlYYbDlpdnvDDizJR2hb1kg+Xi8KmFhYV
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(autocorr_theta)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"temporal_kernel = np.fft.ifft(np.fft.fft(C_r_fphi_theta)/np.fft.fft(autocorr_theta))"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x24ae23229d0>]"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD4CAYAAAAO9oqkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zL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gCYBoytdMxY4D1r+VNgmIgIgIhcBWwD1gUhFqWUTfJOF9kdQshtzXHu1XUwkkFbwP0G4W5rm8djjDFFwFGguYg0AH4HPB2EOJQXU/+7jc9X7EbsDiSE8gqc/0UU6T5YstPuEELu3R+3c9KhSc/uBuSngJeNMdUOIxWRCSKSISIZOTk5oY/MQSb+Zz0PTl/t6Hu5N7+zlEVbDvGl25zNKsxiZEKYDfuOUeKUvrNugpEM9gDt3dbbWds8HiMiCUBj4BAwEHhRRLYD9wO/F5F7PL2IMWaKMSbNGJOWkpIShLCd68tVezh6qrDK9nFTFtsQTXhk7DjM9X9bzH3TVtkdinK4a99axOTvtlR/YJQJxgjkZUBXEemE60t/HHBDpWNmAOOBRcC1wHzjmlfuotIDROQp4IQx5vUgxBSzMg8c575pqxh+ViveHp9mdzi2KCgqISnB7ove2DB3/QG2HjxBgzqJIE6+EVnRyp2HK6xnbM+loKiEC7q0sCmiwAWcDIwxRdbZ/GwgHphqjFknIhOBDGPMDOAd4H0RyQJycSUMFQKnCl09OXYccm5DV3X+b34mD43obncYMeG2f2SULd83rKuNkYTXpkpVWa99axFAjcqi5J4soEndROLiIit5BqU2kTFmFjCr0rYn3JbzgeuqeY6nghGLcsm0qnku2nLI5kjCL/uYvXPsxirn3UX3rrbl1HNPFtD3mTncNeRMHhnVI8hRBUavpR3GvQ1v7voDXP8357YTKGWnZdt
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(np.real(temporal_kernel[1]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([58.61796736, 46.68999397, 1.33161805, ..., 10.85536343,\n",
" 21.27754034, 37.21827067])"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"avg_firing_rate['phase'][0, trial_stim_id['phase']] + np.real(np.convolve(temporal_kernel[0], theta, 'valid'))"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([29.93842435, 27.84369865, 27.99321137, ..., 27.12639613,\n",
" 27.84369865, 26.46483905])"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"avg_firing_rate['phase'][0, trial_stim_id['phase']]"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([29.94011976, 60.06006006, 30.03003003, ..., 30.03003003,\n",
" 0. , 60.06006006])"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"spike_count_rate[0]"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJoAAAihCAYAAAC8dJucAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd3wT5R8H8M/TQZll72HZexdQ9p4qbkFFnLhwj19xIOIA98SBgoKKoDhAy957tOxNKYW2FCh0t3Q/vz9ySS/JJU2bpLmkn/fr1VeTy93luY5v7r73PN9HSClBRERERERERETkLD9PN4CIiIiIiIiIiHwDE01EREREREREROQSTDQREREREREREZFLMNFEREREREREREQuwUQTERERERERERG5BBNNRERERERERETkEi5JNAkhRgshTgohooQQYRqvDxRC7BNC5Ash7rB4bbIQ4rTyNVm1vKcQ4rCyzy+EEMIVbSUi38VYRER6wXhERHrAWEREnuB0okkI4Q9gDoAxADoAmCiE6GCx2nkADwBYZLFtLQBvAugDoDeAN4UQNZWXvwHwKIDWytdoZ9tKRL6LsYiI9ILxiIj0gLGIiDzFFT2aegOIklJGSylzASwGMF69gpQyRkp5CEChxbajAKyVUi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Q0N9v+gDEbkDY1Ep9Zi5Fjn5hcgv9Nwhbz2diAGt63rs/b1Rbn4htke5r1i7PVN+jvTI+3oRp+JReY1FRORyjEVEVGqu6NEUD6Cp6nkTZZnmOkKIAADVAVyVUuZIKa8CgJQ
"text/plain": [
"<Figure size 1440x2880 with 40 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(10, 4, figsize=(5*4, 10*4))\n",
"for unit_id in range(40):\n",
" ax[unit_id//4, unit_id%4].plot(np.real(temporal_kernel[unit_id]))\n",
" # ax[unit_id//4, unit_id%4].set_ylabel('avg firing rate / Hz')\n",
" ax[unit_id//4, unit_id%4].set_ylim([-0.1,0.1])\n",
"\n",
"# ax[0,0].set_title('firing rate (Hz) vs. phase')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Perispike Stimulus Histogram"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"19\r"
]
}
],
"source": [
"tau_bin = 0.05\n",
"tau_range = np.arange(0, 0.5+tau_bin, tau_bin)\n",
"theta_hist = np.zeros((num_unit, len(tau_range), num_stim['orientation']))\n",
"for stim_id, trials in enumerate(stim_id_trial['orientation']):\n",
" print(stim_id, end='\\r')\n",
" for trial_id in trials:\n",
" t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
" for i, tau in enumerate(tau_range):\n",
" # how many spikes between t_on + tau and t_off + tau\n",
" for unit_id in range(num_unit):\n",
" theta_hist[unit_id, i, stim_id] += np.sum((spike_times[unit_id] > t_on + tau) & (spike_times[unit_id] < t_off + tau))\n"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABI4AAAidCAYAAADhiX3YAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zL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8vLF6USFhcyZ7Wq6M0rTtLlieNRG58AoOYkTOo66dcdRsHGpcKSUCsNRNHpURJ4yDt8JOD//A47cIpg6mV8n9mvjHt1bx9nOQf7phrIpt6Z4Ynt5Bgdqu+kZHPXac2qa5jsiwq4TbVyyKJU4FzoPTSbF99+/iqiwEL7w+8OMWvWbI83/lFIPKaXalVIVk9z2JaWUKKVSja+vUEr1GsNEjiilvj7hvjuUUqeMgSJf9efPoE2tpn1gfJuaU1R4CFcsSeOFyjbs9uDeKvvSiTbKv/ECP36lGluQr1XTNM05US03KZq02AjCQ0264ygIuTJVTeHoJjopIj+YcFMzcLnx+VVAtfH5M8BHjOlqm4FeEWlBJ/Zrht6hMX74cjVbFqVw1dJ0rz739vIM7AKvnmqf+c6apgXcmQ5HLtlM29QmyoiP5D/fs5KKpj5+sOu0D1enaVN6mElyGpVSeTjOb+ovuGmPiKw2Pr5l3DcE+AmOoSLlwO3G8BEtgEbGbNR1DVKSHnfRbTuWZ9LRb+FgfU8AVuYau134/ounUMD3XzzNnQ+9TXv/SKCXpWmaNiVnnlFOUhQmkyI3KUpnHAUhV1o9tgJ3AFdNuFp2A3A38N9KqaPAf+CYoAawE8doxxrgF8BnAHRiv+b041erMQ+P8c83luGoS3rP8uwEMuIjeEnnHGnanPBCpePf6vYy1wtH4HgDd/vGPH6++wxvndEjsjX/EpHdwGTnMP8DfBnHAJGZbARqROS
"text/plain": [
"<Figure size 1440x2880 with 40 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(10,4, figsize=(5*4, 10*4))\n",
"for unit_id in range(num_unit):\n",
" ax[unit_id//4, unit_id%4].plot(stim_val['orientation'], theta_hist[unit_id, 1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"the range of phases should be restricted to get good orientaiton tuning curves (?)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"delay_orientation_tuning = theta_hist / 0.084"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To carry out topological data analysis, we need 400 data points (number of stimulus pairs) in the neuronal firing rate space."
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"19\r"
]
}
],
"source": [
"key = 'phase'\n",
"tau_bin = 0.05\n",
"tau_range = np.arange(0, 0.5+tau_bin, tau_bin)\n",
"phase_hist = np.zeros((num_unit, len(tau_range), num_stim[key]))\n",
"for stim_id, trials in enumerate(stim_id_trial[key]):\n",
" print(stim_id, end='\\r')\n",
" for trial_id in trials:\n",
" t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
" for i, tau in enumerate(tau_range):\n",
" # how many spikes between t_on + tau and t_off + tau\n",
" for unit_id in range(num_unit):\n",
" phase_hist[unit_id, i, stim_id] += np.sum((spike_times[unit_id] > t_on + tau) & (spike_times[unit_id] < t_off + tau))\n"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABI4AAAidCAYAAADhiX3YAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd3xUdbr48c93ZtJ7rxBIA5LQkSp2ASuubrG7vy3e3dXtt+zeu+u2673bd+8W3aarrt3VFVQE1FVReocECCQBQsqk956Z7++POYMDJKRNMiXP+/XKSzhz5sw3CCfnPOcpSmuNEEIIIYQQQgghhBDnM3l6AUIIIYQQQgghhBDCO0ngSAghhBBCCCGEEEIMSAJHQgghhBBCCCGEEGJAEjgSQgghhBBCCCGEEAOSwJEQQgghhBBCCCGEGJDF0wu4mPj4eD1t2jRPL0MIMUZ79+6t11oneHodYyHnIyF8n5yLhBDeQM5FQghvMJJzkVcHjqZNm8aePXs8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l1EGl1JtKqXxj27AfqMm1kXc7P+MIYEpsKCuy43hp75lRDwRxZht96cos5k91dHcoqmoZ+4LFZCUP94XXOVjRwqmGTm6Zf+FfubToEH79qXkU17Tx0LoLKsMv8MLuMxRWtvLt62cSFmS56L43z02lvr2HHWVjezj62Icn6em3881rc3ni/y1mWlwon3tqD/vKm8Z0XG80rMCRUioAR9DoGa31K8bm+wDnr1/CEa0GR78Q18YZzh4ig20/h782o51MbHbN5qIarpyZSHCA+YLXEyKCuCQjVgJHQky
"text/plain": [
"<Figure size 1440x2880 with 40 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(10,4, figsize=(5*4, 10*4))\n",
"for unit_id in range(num_unit):\n",
" ax[unit_id//4, unit_id%4].plot(stim_val['phase'], phase_hist[unit_id, 1])"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"399\r"
]
}
],
"source": [
"key = 'pair'\n",
"tau_bin = 0.05\n",
"tau_range = np.arange(0, 0.5+tau_bin, tau_bin)\n",
"pair_hist = np.zeros((num_unit, len(tau_range), num_stim[key]))\n",
"for stim_id, trials in enumerate(stim_id_trial[key]):\n",
" print(stim_id, end='\\r')\n",
" for trial_id in trials:\n",
" t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
" for i, tau in enumerate(tau_range):\n",
" # how many spikes between t_on + tau and t_off + tau\n",
" for unit_id in range(num_unit):\n",
" pair_hist[unit_id, i, stim_id] += np.sum((spike_times[unit_id] > t_on + tau) & (spike_times[unit_id] < t_off + tau))\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2D Tuning"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"avg_firing_rate_pair = pair_hist.reshape((num_unit, len(tau_range), num_stim['orientation'], num_stim['phase']))"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "cannot reshape array of size 176000 into shape (40,400)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32mc:\\Users\\arash\\Documents\\Uni\\Research Project (Topology)\\staticgrating-phasefreq-topology\\01_Firing_Rate.ipynb Cell 53'\u001b[0m in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/Uni/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000052?line=0'>1</a>\u001b[0m \u001b[39m# normalize\u001b[39;00m\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/Uni/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000052?line=1'>2</a>\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mscipy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mstats\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39msts\u001b[39;00m\n\u001b[1;32m----> <a href='vscode-notebook-cell:/c%3A/Users/arash/Documents/Uni/Research%20Project%20%28Topology%29/staticgrating-phasefreq-topology/01_Firing_Rate.ipynb#ch0000052?line=2'>3</a>\u001b[0m avg_firing_rate_pair_normalized \u001b[39m=\u001b[39m sts\u001b[39m.\u001b[39mzscore(avg_firing_rate_pair\u001b[39m.\u001b[39;49mreshape(num_unit, \u001b[39m20\u001b[39;49m\u001b[39m*\u001b[39;49m\u001b[39m20\u001b[39;49m), axis \u001b[39m=\u001b[39m \u001b[39m1\u001b[39m)\u001b[39m.\u001b[39mreshape(num_unit, \u001b[39m20\u001b[39m, \u001b[39m20\u001b[39m)\n",
"\u001b[1;31mValueError\u001b[0m: cannot reshape array of size 176000 into shape (40,400)"
]
}
],
"source": [
"# normalize\n",
"import scipy.stats as sts\n",
"avg_firing_rate_pair_normalized = sts.zscore(avg_firing_rate_pair.reshape(num_unit, 20*20), axis = 1).reshape(num_unit, 20, 20)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABGEAAAirCAYAAAD1Q8+UAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9XahtXbcmBj2tjzHXfr+fOtY5QURzCn9QCfFKKPVCxBBBYwyWFwoqgRIMRRDRiCk1IArxB7yx6kaUUkuDCpEEhAoEQkByJ5IKhKAEpfAmVQiiJ0RzzvfuPcfozYv205/WR59rrfc73/u9e509O3vuOdecY/S/0XvrT3ta662LquKZnumZnumZnumZnumZnumZnumZnumZnumZftzUfuoKPNMzPdMzPdMzPdMzPdMzPdMzPdMzPdMzfQvpScI80zM90zM90zM90zM90zM90zM90zM90zP9FtKThHmmZ3qmZ3qmZ3qmZ3qmZ3qmZ3qmZ3qmZ/otpCcJ80zP9EzP9EzP9EzP9EzP9EzP9EzP9EzP9FtITxLmmZ7pmZ7pmZ7pmZ7pmZ7pmZ7pmZ7pmZ7pt5D2n7oCv410e/mFfvfz3718rxKfBBD6QYByZhT/Rr8LMC5U+lsVovF5yke8XJFRzpx/VrDeqvxH5jO9v5bfKtG1l7oIANEsT5pCRNH8JaJ0r0AV6NrQu31G9wbqXMgb9XxHf+Tfpd/99vg+3rt/7jo+q17z47JFRn8IoE2gAmgD0B70+YPy5zpmtykgcTrZXBfPN8cKHj/fz//6H+D4/g9/yFN/pp8obb/8he6/93vrH187qI7HUPyt09/xO49Dukfqn9MYm/7mNP09j8O8v6HIiyhJ4jpdZJL1dVnRr/OntDPuWY32t2TZXHfhtlO9S0dT3fjrdx8qKOtntnh+eNSvM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Ws+JPqv/pt1r0e6WmlEHp/D5ZalPOaPFv+9hqGLThYiiwc5K+kDv9W4vLfqwt+VSSMiGwA/icA/uMA/k4A/zkR+Tuny/6LAP5VVf13AvhLAP5Hb2a8ICCYiKluR3oZwLObama7WKg0PF7a4m9n6gYoGQ++TPR5UMwD91H74jJS4F57FUsCY28abUJEhwLoXXB2s2qfveHQhqPb6+zNSRjKu0fD1mWOzzIK4XaV5ydFIKRORPcXYuS1lAJ2AMMCFOdFYL6dvRPIcjW37TeZxrPTKiCf6TeefruyaLEAvpVHVnS8F4WEwEWSwdN3daGpr5X3S+bNif+e5uvFmzNkSfz2QAl8TyrK0qw4zPVa1PXXAXSS/aO2crY3EMEyk+h/r8dswSsWt8X91FfZvzq2HQGDiHm9HiTwmekrY0jf1bdPxejHTT+aLJrTo6E8rYOznJkVmDEnA9tI3cLrni9wpQvugWq/0T2LvB8SFKC6rOo9X8OykOspoy5ow2BWZaPUv2eM8Apee69xrxLkD/J8gE2Wec/lzHWnsnT5m0x9SH9PyhpjT1b2Zi/GFc66tBfj86tyhsp41dD3TH+s9GPKolz3yJOgeBS8Md4fV7q+j/G2Jn14Z8SMk2Yv9Ffrw9iGPdZmHWHWv6a6v4nB5jJX5efknsonL7vyOZZ+0nNmfe76WhM7qzaVKs9y+0FbeF7PeuBbxNOlH6WOLaW/GS8Xhwmv69I4P9X7h8ifr4qEAfDvB/A3VPX/oapfAPzjAP7cdM2fA/CP+ed/EsB/RGTh2jClcGVP7xff7gNFcXW3B6qXhw5ggF8qbV60ijvaFi+Qa625z/ZJ0MyL+pWlrQNhNWjZNTWJiek1JlF1iX0rRRwBVcHZG+7nhsPf4/PZBefZ0HtLF/7iMtu5LouBykRMColRbykCowqC5WSkZ7ZMbAmLPi3KZwhcQZA2NoZ0EkxI97jiOvyofxfPLst79QGMNiUR8wQbP1b
"text/plain": [
"<Figure size 1440x2880 with 40 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(10, 4, figsize=(5*4, 10*4))\n",
"for unit_id in range(40):\n",
" ax[unit_id//4, unit_id%4].imshow(avg_firing_rate_pair[unit_id, 1], interpolation='gaussian')\n",
"\n",
" ax[unit_id//4, unit_id%4].set_xticks(np.arange(20)[::5])\n",
" ax[unit_id//4, unit_id%4].set_xticklabels(stim_val['phase'][::5])\n",
" ax[unit_id//4, unit_id%4].set_yticks(np.arange(20)[::5])\n",
" ax[unit_id//4, unit_id%4].set_yticklabels(stim_val['orientation'][::5])\n",
" ax[unit_id//4, unit_id%4].set_xlabel('phase')\n",
" ax[unit_id//4, unit_id%4].set_ylabel('orientation')\n",
" \n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "25e7381d29664ebcb827a4a2ac58391f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=0, description='tau_id', max=10), Output()), _dom_classes=('widget-inter…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# klein bottle symmetry\n",
"@widgets.interact(tau_id=widgets.IntSlider(0, min=0, max=len(tau_range)-1))\n",
"\n",
"def klein_bottle(tau_id):\n",
" fig, ax = plt.subplots(1, 4, figsize=(5*4, 1*4))\n",
" klein_bottle_rate = np.zeros((num_unit, 40, 40))\n",
" for unit_id in range(4):\n",
" x = np.hstack((avg_firing_rate_pair[unit_id,tau_id], avg_firing_rate_pair[unit_id,tau_id]))\n",
" klein_bottle_rate[unit_id] = np.vstack((x, x[:,::-1]))\n",
" ax[unit_id%4].imshow(klein_bottle_rate[unit_id], interpolation='gaussian')\n",
" ax[unit_id%4].plot()\n",
" # ax[unit_id//4, unit_id%4].set_xticks(np.arange(40)[::5])\n",
" # ax[unit_id//4, unit_id%4].set_xticklabels(np.concatenate((stim_val['phase'][::5],stim_val['phase'][::5])))\n",
" # ax[unit_id//4, unit_id%4].set_yticks(np.arange(40)[::5])\n",
" # ax[unit_id//4, unit_id%4].set_yticklabels(stim_val['orientation'][::5])\n",
" ax[unit_id%4].set_xticks([])\n",
" ax[unit_id%4].set_yticks([])\n",
" ax[unit_id%4].plot(np.arange(40), 19.5*np.ones(40), 'r', linewidth=0.5)\n",
" ax[unit_id%4].plot(19.5*np.ones(40), np.arange(40), 'r', linewidth=0.5)\n",
"\n",
" ax[unit_id%4].set_xlabel('phase')\n",
" ax[unit_id%4].set_ylabel('orientation')\n",
" \n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Klein bottle"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2e21faa75c3049a58ce37b8e661b0991",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=0, description='tau_id', max=10), Output()), _dom_classes=('widget-inter…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# klein bottle symmetry\n",
"@widgets.interact(tau_id=widgets.IntSlider(0, min=0, max=len(tau_range)-1))\n",
"\n",
"def klein_bottle(tau_id):\n",
" fig, ax = plt.subplots(10, 4, figsize=(5*4, 10*4))\n",
" klein_bottle_rate = np.zeros((num_unit, 40, 40))\n",
" for unit_id in range(40):\n",
" x = np.hstack((avg_firing_rate_pair[unit_id,tau_id], avg_firing_rate_pair[unit_id,tau_id]))\n",
" klein_bottle_rate[unit_id] = np.vstack((x, x[:,::-1]))\n",
" ax[unit_id//4, unit_id%4].imshow(klein_bottle_rate[unit_id], interpolation='gaussian')\n",
" ax[unit_id//4, unit_id%4].plot()\n",
" # ax[unit_id//4, unit_id%4].set_xticks(np.arange(40)[::5])\n",
" # ax[unit_id//4, unit_id%4].set_xticklabels(np.concatenate((stim_val['phase'][::5],stim_val['phase'][::5])))\n",
" # ax[unit_id//4, unit_id%4].set_yticks(np.arange(40)[::5])\n",
" # ax[unit_id//4, unit_id%4].set_yticklabels(stim_val['orientation'][::5])\n",
" ax[unit_id//4, unit_id%4].set_xticks([])\n",
" ax[unit_id//4, unit_id%4].set_yticks([])\n",
" ax[unit_id//4, unit_id%4].plot(np.arange(40), 19.5*np.ones(40), 'r', linewidth=0.5)\n",
" ax[unit_id//4, unit_id%4].plot(19.5*np.ones(40), np.arange(40), 'r', linewidth=0.5)\n",
"\n",
" ax[unit_id//4, unit_id%4].set_xlabel('phase')\n",
" ax[unit_id//4, unit_id%4].set_ylabel('orientation')\n",
" \n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAOpUlEQVR4nO3cf6jd9X3H8eeruTRrEUyi8UeN2bVVGHGDFg5K2QauaoyDNtL6h90fDVtL/lj9Y5VCUxzT2v6hbp2ltNsIbSEIa3SO0kApEm2FMYb1xDrarE1zjS0mVZuaIDipkvW9P+7X7Xg5Mffec+49OX6eDzjc8/1+P/fe98cLeeac742pKiRJ7XrbpAeQJE2WIZCkxhkCSWqcIZCkxhkCSWrczKQHWI7zzz+/ZmdnJz2GJE2VAwcO/LqqNi48P5UhmJ2dpd/vT3oMSZoqSX4x7LxvDUlS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS4wyBJDXOEEhS48YSgiTbkhxKMpdk15Dra5M80F1/PMnsguubk7yc5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IZCkxqWqJj3DkiU5Dvxi0nMs0fnAryc9xCpzz21wz9Pjd6tq48KTUxmCaZSkX1W9Sc+xmtxzG9zz9POtIUlqnCGQpMYZgtWze9IDTIB7boN7nnLeI5CkxvmKQJIaZwgkqXGGYIySbEiyP8nh7uP606zb0a05nGTHkOv7kvx45Sce3Sh7TvLOJN9J8tMkB5PcvbrTL02SbUkOJZlLsmvI9bVJHuiuP55kduDaZ7vzh5LcsKqDj2C5e05yfZI
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot()\n",
"for trial_id in range(num_trial):\n",
" t_on, t_off = stim['stim_ontime'][trial_id]//time_bin, stim['stim_offtime'][trial_id]//time_bin\n",
" if t_off > 0 and t_on < 1:\n",
" stim_time = np.arange(t_on, t_off)\n",
" plt.plot(stim_time, stim_trial[trial_id]*np.ones(len(stim_time)), c=cmap(stim_trial[trial_id]))\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
"# save\n",
"\n",
"spike_data = {'spike_count_rate':spike_count_rate, 'avg_firing_rate': avg_firing_rate, 'sem_firing_rate':sem_firing_rate,\n",
"'firing_rate': firing_rate, 'stim_num_trial':stim_num_trial, 'C_r_fphi_theta':C_r_fphi_theta, 'theta_hist':theta_hist, 'phase_hist':phase_hist, 'pair_hist':pair_hist}\n",
"\n",
"file = open('spike_data.pkl', 'wb')\n",
"pickle.dump(spike_data, file)\n",
"file.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.5 64-bit",
"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.10.5"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}