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.

2655 lines
1.8 MiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Experiment: Flashed gratings"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Initialization"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import scipy\n",
"import scipy.stats as sts\n",
"import pickle as pkl\n",
"import ipywidgets as widgets\n",
"from mpl_toolkits import mplot3d\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"from scipy import sparse\n",
"import sys\n",
"from matplotlib import cm\n",
"sys.path.insert(0, '../model/')\n",
"\n",
"# color maps\n",
"cmap_hot = cm.get_cmap('hot')\n",
"cmap_viridis = cm.get_cmap('viridis')\n",
"cmap_jet = cm.get_cmap('jet')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"\n",
"data_folder = \"../data/\"\n",
"stim_file = \"Stiminfo_PVCre_2021_0012_s06_e14.csv\"\n",
"spike_times_file = \"Spiketimes_PVCre_2021_0012_s06_e14.npy\"\n",
"\n",
"key_symbol = {'pair':'$(\\\\theta,\\phi)$', 'orientation':'$\\\\theta$', 'phase':'$\\phi$'}"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dict_keys(['data_folder', 'stim_file', 'spike_times_file', 'key_symbol', 'stim', 'num_trial', 'stim_val', 'trial_stim_id', 'key_list', 'stim_id_trial', 'num_stim', 'key', 'pair_id', 'trial_pair_id', 'pair_val', 'pair_trial_id', 'spike_times', 'num_unit', 'num_spike', 'spike_count_rate', 'avg_firing_rate', 'firing_rate', 'stim_num_trial', 'stim_hist', 'optimal_avg_firing_rate', 'latest_spike_time', 'dt', 'exp_time', 'B_stim', 'trials', 't_on', 't_off', 'B_spike', 'trial_range', 'units', 'orientation', 'phase', 'trial_spike_times', 'delta_t_on', 'delta_t_off', 'subseq_trials', 'subseq_spike_times', 'subseq_spike_times_locked', 'time_range', 'unit_id_2', 'p1', 'p2', 'delta_t', 'time_range_smoothing', 'period_1_dist', 'period_2_dist', 'period_3_dist', 'num_units', 'max_p_1', 'max_p_2', 'max_p_3', 'delta_2', 'delta_3', 't_p1', 't_p2', 'subseq_spike_times_locked_2', 'B_spike_fixed', 'B_stim_original', 'B_spike_smooth', 'B_stim_total', 'R', 'R_pair_smoothed', 'Rp', 'firing_rates_noise_red', 'firing_rates_flat', 'firing_rates_in_trials', 'avg_firing_rates', 'avg_fr_blur', 'avg_firing_rates_pca', 'param_corr', 'avg_firing_rates_pca_', 'embed'])\n"
]
}
],
"source": [
"file = open(\"dump.pkl\", 'rb')\n",
"pair_id = None\n",
"data = pkl.load(file)\n",
"print(data.keys())\n",
"for key, value in data.items():\n",
" globals()[key] = value\n",
"file.close()"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"with open('dump.pkl', 'wb') as f:\n",
" pickle.dump({k: globals()[k] for k in [\n",
" 'data_folder', 'stim_file', 'spike_times_file', 'key_symbol', \n",
" 'stim', 'num_trial', 'stim_val', 'trial_stim_id', 'key_list', 'stim_id_trial', 'num_stim', 'key', 'pair_id', 'trial_pair_id', 'pair_val', 'pair_trial_id',\n",
" 'spike_times', 'num_unit', 'num_spike', 'spike_count_rate', 'avg_firing_rate', 'firing_rate', 'stim_num_trial', 'stim_hist', 'optimal_avg_firing_rate',\n",
" 'latest_spike_time', 'dt', 'exp_time', 'B_stim', 'trials', 't_on', 't_off', 'B_spike', 'trial_range', 'units', 'orientation', 'phase', 'trial_spike_times',\n",
" 'delta_t_on', 'delta_t_off', 'subseq_trials', 'subseq_spike_times', 'subseq_spike_times_locked', 'time_range', 'unit_id_2', 'p1', 'p2', 'delta_t', 'time_range_smoothing',\n",
" 'period_1_dist', 'period_2_dist', 'period_3_dist', 'num_units', 'max_p_1', 'max_p_2', 'max_p_3', 'delta_2', 'delta_3', 't_p1', 't_p2', 'subseq_spike_times_locked_2',\n",
" 'B_spike_fixed', 'B_stim_original', 'B_spike_smooth', 'B_stim_total', 'R', 'R_pair_smoothed', 'Rp', 'firing_rates_noise_red', 'firing_rates_flat', 'firing_rates_in_trials', 'avg_firing_rates',\n",
" 'avg_fr_blur', 'avg_firing_rates', 'avg_firing_rates_pca', 'param_corr', 'avg_firing_rates_pca_', 'embed'\n",
" ]}, f)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Load the stimulus data\n",
"**Stimulus data layout:**\n",
"```\n",
"stim_val = {'pair': [(or1, ph1), (or2, ph2), ...], 'orientation': [...], 'phase': [...]}\n",
"stim_id_trial = {'pair': [id1, id2, ...], 'phase': [..], ...} # corresponding trials\n",
"pair_trial_id[orientation_id][phase_id] = [Trial ids]\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Stimulus DataFrame\n",
"stim = pd.read_csv(data_folder + stim_file)\n",
"num_trial = len(stim)\n",
"stim_val = {}\n",
"trial_stim_id = {}\n",
"# 50 trials per orientation-phase pair\n",
"stim_val['pair'], trial_stim_id['pair'] = np.unique(stim[['grat_orientation', 'grat_phase']], return_inverse=True, axis=0) \n",
"# 1000 trials per orientation\n",
"stim_val['orientation'], trial_stim_id['orientation'] = np.unique(stim['grat_orientation'], return_inverse=True) \n",
"# 1000 trials per phase\n",
"stim_val['phase'], trial_stim_id['phase'] = np.unique(stim['grat_phase'], return_inverse=True) \n",
"key_list = ['pair', 'orientation', 'phase']\n",
"stim_id_trial = {}\n",
"num_stim = {}\n",
"for key in key_list:\n",
" stim_id_trial[key] = [np.where(trial_stim_id[key] == i)[0] for i in range(len(stim_val[key]))]\n",
" num_stim[key] = len(stim_val[key])\n",
"\n",
"def pair_id(i):\n",
" return (int(i//num_stim['orientation']), i%num_stim['orientation'])\n",
"\n",
"trial_pair_id = np.array([pair_id(i) for i in trial_stim_id['pair']], dtype=object)\n",
"pair_val = stim_val['pair'].reshape(num_stim['orientation'], num_stim['phase'],2)\n",
"\n",
"# for each (orientation_id = i, phase_id = j) find the trial indices\n",
"pair_trial_id = np.ndarray((num_stim['orientation'], num_stim['phase']), dtype=object)\n",
"for i in range(num_stim['pair']):\n",
" pair_trial_id[pair_id(i)] = stim_id_trial['pair'][i]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"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>Unnamed: 0</th>\n",
" <th>grat_orientation</th>\n",
" <th>grat_phase</th>\n",
" <th>stimvals</th>\n",
" <th>stim_ontime</th>\n",
" <th>stim_offtime</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>45.0</td>\n",
" <td>36.0</td>\n",
" <td>102</td>\n",
" <td>2.5005</td>\n",
" <td>2.5839</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>18.0</td>\n",
" <td>1</td>\n",
" <td>2.6195</td>\n",
" <td>2.7028</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>162.0</td>\n",
" <td>288.0</td>\n",
" <td>376</td>\n",
" <td>2.7030</td>\n",
" <td>2.7863</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>0.0</td>\n",
" <td>54.0</td>\n",
" <td>3</td>\n",
" <td>2.7865</td>\n",
" <td>2.8699</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>108.0</td>\n",
" <td>36.0</td>\n",
" <td>242</td>\n",
" <td>2.8700</td>\n",
" <td>2.9534</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Unnamed: 0 grat_orientation grat_phase stimvals stim_ontime \\\n",
"0 0 45.0 36.0 102 2.5005 \n",
"1 1 0.0 18.0 1 2.6195 \n",
"2 2 162.0 288.0 376 2.7030 \n",
"3 3 0.0 54.0 3 2.7865 \n",
"4 4 108.0 36.0 242 2.8700 \n",
"\n",
" stim_offtime \n",
"0 2.5839 \n",
"1 2.7028 \n",
"2 2.7863 \n",
"3 2.8699 \n",
"4 2.9534 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stim.head()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pair, orientation, phase\n",
"(400, 2)\n",
"(20,) (20,)\n"
]
}
],
"source": [
"print(', '.join(stim_val.keys()))\n",
"print(stim_val['pair'].shape)\n",
"print(stim_val['orientation'].shape, stim_val['phase'].shape)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 82 482 1021 1421 1821 2183 2645 3045 3445 3643 4357 4757\n",
" 5014 5493 5893 6293 6693 6965 7365 7652 8052 8513 9116 9203\n",
" 9603 10003 10628 10849 11512 11912 12312 12535 12947 13347 13666 14248\n",
" 14682 14857 15257 15657 16393 16793 17193 17262 17906 18146 18546 19050\n",
" 19450 19904]\n"
]
}
],
"source": [
"print(stim_id_trial['pair'][0])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 82, 482, 1021, 1421, 1821, 2183, 2645, 3045, 3445,\n",
" 3643, 4357, 4757, 5014, 5493, 5893, 6293, 6693, 6965,\n",
" 7365, 7652, 8052, 8513, 9116, 9203, 9603, 10003, 10628,\n",
" 10849, 11512, 11912, 12312, 12535, 12947, 13347, 13666, 14248,\n",
" 14682, 14857, 15257, 15657, 16393, 16793, 17193, 17262, 17906,\n",
" 18146, 18546, 19050, 19450, 19904])"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pair_trial_id[0][0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Stimulus data layout:**\n",
"```\n",
"stim_val = {'pair': [(or1, ph1), (or2, ph2), ...], 'orientation': [...], 'phase': [...]}\n",
"stim_id_trial = {'pair': [id1, id2, ...], 'phase': [..], ...} # corresponding trials\n",
"pair_trial_id[orientation_id][phase_id] = [Trial ids]\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Load the spike data and correlations\n",
"```\n",
"Loaded: 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",
"Loaded: corr_stim_unit, optimal_avg_firing_rate, stim_hist, stim_hist_caution\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(40,)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"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",
"num_unit = len(spike_times)\n",
"spike_times.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Sort spikes by firing rate**"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"\n",
"num_spike = list(map(len, spike_times))\n",
"spike_times = spike_times[np.argsort(num_spike)[::-1]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Load a lot of variables out of a `.pkl` file**"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loaded: 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",
"Loaded: corr_stim_unit, optimal_avg_firing_rate, stim_hist, stim_hist_caution\n"
]
}
],
"source": [
"# yeah...\n",
"files = ['spike_data.pkl', 'corr_data.pkl']\n",
"for file_name in files:\n",
" file = open(file_name, 'rb')\n",
" data = pkl.load(file)\n",
" print('Loaded:', ', '.join(data.keys()))\n",
" for key, value in data.items():\n",
" globals()[key] = value\n",
"\n",
" file.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Spike and stimulus preprocessing\n",
"\n",
"```\n",
"B_stim = {'pair': [mat_stim_1, mat_stim_2, ..], 'orientation': .., ...}\n",
"```\n",
"\n",
"`mat_stim_i` is a matrix of shape `(1, M)` such that `mat[0][t] = 1` if there was stimuli at time $t$ and $0$ if not\n",
"\n",
"```\n",
"B_spike = [unit_1_spikes, unit_2_spikes, ..]\n",
"unit_1_spikes[t] = 1 if there was a spike, 0 if not\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Read the data"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"# reverse correlation time offset range \n",
"max_delay = 300 # dt\n",
"tau_id_range = np.arange(max_delay)\n",
"\n",
"# experiment duration\n",
"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])\n",
"\n",
"dt = 0.001 # 1 ms\n",
"exp_time = np.arange(0, experiment_dur, dt)\n",
"M = len(exp_time)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"B_stim = {}\n",
"for key in key_list:\n",
" B_stim[key] = []\n",
" for stim_id, trials in enumerate(stim_id_trial[key]):\n",
" B_stim[key].append([])\n",
" s = []\n",
" for trial_id in trials:\n",
" t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
" s += list(np.arange(int(t_on//dt), int(t_off//dt)))\n",
"\n",
" B_stim[key][stim_id] = sparse.coo_matrix((np.ones(len(s)), (np.zeros(len(s), dtype=int), s)), shape=(1, M))\n",
"s = spike_times//dt\n",
"B_spike = []\n",
"for unit_id in range(num_unit):\n",
" B_spike.append(sparse.coo_matrix((np.ones(len(s[unit_id])), (np.zeros(len(s[unit_id]), dtype=int), np.int0(s[unit_id]))), shape=(1, M)))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"sorted_spike_num = np.sort(num_spike)[::-1]\n",
"cutoff_num_spike = 1000\n",
"num_unit = np.sum(sorted_spike_num > cutoff_num_spike)\n",
"for key in key_list:\n",
" stim_hist[key] = stim_hist[key][:num_unit]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Some plots"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This graph shows for unit 0 at a particular moment:\n",
"- One stimulus duration (blue)\n",
"- The second stimulus (red)\n",
"\n",
"And spike events"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEWCAYAAACAOivfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZJUlEQVR4nO3df5xddX3n8de7IcAqIsGMFhMgiNSCIqAjSmUV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/7fVDZSVSurariqhoeGhvpQliRpMtMOgaq6t6rua6bXAHOTzAc2Avt2dV3YtEmSZolph0CSX0+SZvrIZpt3AtcBByU5IMmuwDJg9XSfT5LUP5OeE0hyIXAMMD/JBuAMYC5AVZ0LnAC8Nclm4EFgWVUVsDnJqcBlwBxgVXOuQJI0S0waAlV14iTLPw58fIJla4A1UytNkjTT/MSwJLWYISBJLWYISFKLGQKS1GKGgCS1mCEgSS1mCEhSixkCktRihoAktZghIEktZghIUosZApLUYoaAJLWYISBJLWYISFKLTRoCSVYluSPJtydY/ntJbkpyc5KvJTmsa9mPmvYbkoz0s3BJ0vT1sidwPrBkG8t/CLy8qg4FzgJWjln+iqo6vKqGp1aiJGmm9HJnsauSLNrG8q91zV5D54bykqQngH6fEzgZuKRrvoAvJbk+yYptrZhkRZKRJCOjo6N9LkuSNJ5J9wR6leQVdELg6K7mo6tqY5KnA5cn+W5VXTXe+lW1kuZQ0vDwcPWrLknSxPqyJ5Dk+cCngKVVdeeW9qra2Py8A/gicGQ/nk+S1B/TDoEk+wFfAP6gqr7X1f7kJE/ZMg0sBsa9wkiSNBiTHg5KciFwDDA
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"stim_id = 10\n",
"trial_id = stim_id_trial['phase'][stim_id][0]\n",
"unit_id = 0\n",
"t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
"t0, t1 = t_off-0.2, t_off+0.1\n",
"stim_prev_id = trial_stim_id['phase'][trial_id-1]\n",
"t_prev_on, t_prev_off = stim['stim_ontime'][trial_id-1], stim['stim_offtime'][trial_id-1]\n",
"spikes = spike_times[unit_id][np.where((t0 < spike_times[unit_id]) & (spike_times[unit_id] < t1))]\n",
"plt.axvspan(t_on, t_off, color=cmap_jet(1-np.abs(stim_id-10)/10), alpha=0.3)\n",
"plt.axvspan(t_prev_on, t_prev_off, color=cmap_jet(1-np.abs(stim_prev_id-10)/10), alpha=0.3)\n",
"plt.eventplot(spikes)\n",
"plt.xlim([t0, t1])\n",
"plt.title('Spikes for unit 0')\n",
"plt.xlabel('Time')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAfAAAAIUCAYAAADlkX7vAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAABGYElEQVR4nO3dd3hUZfrG8e+TDqFX6aGDgCCEqmLvvWLBgoqKrrrquuq667quvaxlV5G1V1Qsa8deUEAISJPepJdQU0h/f3/MgV+MSQhJZs6c5P5cVy5mzpzznuedM8w9p5tzDhEREQmWGL8LEBERkX2nABcREQkgBbiIiEgAKcBFREQCSAEuIiISQApwERGRAFKAS1iZmTOzu/2uQ6QsZvatmX1biekOM7M7zSymxPAU73N/SXXVKFIaBbiISOUcBvyd33+PrgeGAh9HuiCpXeL8LkCktjCzROdcrt91AJhZLGDOuQK/a6msst5Pv/vm1TTVj3lL7aI1cPkdM+tmZu+Z2SYzyzGzVWY2wczivNcv8TYRppSY7k4zK+3SfmZmt5vZGjPbZWbfm1m/EiMca2aTzWyHmWWa2SIzu6Nk22bWx8y+MbNsM1tvZncV34RpZklm9qiZzfPa2WBmH5pZj1KK6mhmr3jj5JrZcjN7vMQ4h5rZV2aWYWZZZvaZmfWuwHv4otffoV6/dgEPeq81N7OnzWytN9+FZnZFsWkHen09pZR2nzKzzWYWX2zYFWY221tW6Wb2nJk1KTGdM7N7zOxWM1sB5AF9zKyemf3bW8a53jL/svj7ZWZxZnabV2euma0zs0fMLKkC70Ocmd1iZvO9+jab2cQS7Xf3Pm/bvc/HVDM7rkQ7u5d/b28ZZAJvldc377V9Xn4V+QyZ2Z2E1r4B8r0anPdaqZvQzWxkieX0ipm1Kj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7sGeN87+vstQmuULYFhhAL4X2W+kWV7lFA4TfJqXEToh0oP4BDn3Km7R3TO7TSz9wkdld0KGF28IefcMjN7APiPmXUnFIY5QDtCu0Ge9bZslMnMphA60n0uoR9ChxLa6vKSN49vzWw8oX3g/yJ05H4RoQO1TgBucc4tLq1t59w3ZvYO8C8za0fo8xNPaFl/7Jz71ns/LgG+MLO/E/pcXA10I7TLoFKquPwq+hma7/17k5l9ChQ659JKqaXQQqdEjjOzVwltRWkD3EPoyP/nK9tPqeX8PopOf9H1R2jf4UvAYkIH/GwlFAzHlhivF6E1h0xCp4jdSNlHod9D6DSlNYQCZhLFjl4mdDDb+4TCO5fQvsIJQPdi49zptdUb+IbQj4INhE6xiSk2Xgyh03/WefV/BxxIaG3sxRK1dSZ0sFS6V9cyShyR7dX2EaFNuTleO28AQ/fyPr4IrCnjtcaEgmv3OcubvPfkj6WMe6LX798ckV5inAsJHRSY5S2PBcB/gLYllsPdpUz7APAzodO3sggF+XUlxokhtMl/tvce7PAeP1hWTcWmjSN0RP1ir6+bCf1QK75suxM6PXCH1/5UQj+kireze/nHlTKPUvtW0eVHiaPQK/oZIvTj9klv+RWx5xCS3x6FXmz8kd77lktoE/8rQKsS46wEXi2jj3f6/f2gv+j6M+fK2qUkEj2KXTgj3gX46mEiItVF+8BFREQCSAEuIiISQNqELiIiEkBaAxcREQkgBbiIiEgAKcBFREQCSAEuIiISQApwERGRAFKAi4iIBJACXEREJIAU4CIiIgGkABcREQkgBbiIiEgAKcBFREQCSAEuIiISQApwERGRAFKAi4iIBJACXEREJIAU4CIiIgGkABcREQkgBbiIiEgAKcBFREQCSAEuIiISQApwEREJLDNzZtalktNeYGafV3dNkWLOOb9rEBERqRQzc0BX59zSvYyXAqwA4p1zBZG
"text/plain": [
"<Figure size 504x504 with 7 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"from matplotlib import gridspec\n",
"\n",
"fig, ax = plt.subplots(3,1,figsize=(7,7))\n",
"gs0 = gridspec.GridSpec(3, 3, figure=fig, hspace=0, wspace=0)\n",
"\n",
"stim_id = 10\n",
"trial_id = stim_id_trial['phase'][stim_id][0]\n",
"unit_id = 0\n",
"t_on, t_off = stim['stim_ontime'][trial_id], stim['stim_offtime'][trial_id]\n",
"t0, t1 = t_off-0.2, t_off+0.1\n",
"stim_prev_id = trial_stim_id['phase'][trial_id-1]\n",
"t_prev_on, t_prev_off = stim['stim_ontime'][trial_id-1], stim['stim_offtime'][trial_id-1]\n",
"spikes = spike_times[unit_id][np.where((t0 < spike_times[unit_id]) & (spike_times[unit_id] < t1))]\n",
"\n",
"ax0 = fig.add_subplot(gs0[0, :-1])\n",
"ax1 = fig.add_subplot(gs0[1, :-1])\n",
"ax2 = fig.add_subplot(gs0[2, :-1])\n",
"ax3 = fig.add_subplot(gs0[:, -1])\n",
"\n",
"ax0.axvspan(t_on, t_off, color=cmap_jet(1-np.abs(stim_id-10)/10), alpha=0.3, label='preferred')\n",
"ax0.axvspan(t_prev_on, t_prev_off, color=cmap_jet(1-np.abs(stim_prev_id-10)/10), alpha=0.3, label='non-preferred')\n",
"ax0.eventplot(spikes)\n",
"ax0.set_xlim([t0, t1])\n",
"ax0.legend(loc='upper left')\n",
"\n",
"ax1.axvspan(t_on, t_off, color=cmap_jet(1-np.abs(stim_id-10)/10), alpha=0.3)\n",
"ax1.axvspan(t_prev_on, t_prev_off, color=cmap_jet(1-np.abs(stim_prev_id-10)/10), alpha=0.3)\n",
"ax1.eventplot(spikes-0.05)\n",
"ax1.set_xlim([t0, t1])\n",
"\n",
"ax2.axvspan(t_on, t_off, color=cmap_jet(1-np.abs(stim_id-10)/10), alpha=0.3)\n",
"ax2.axvspan(t_prev_on, t_prev_off, color=cmap_jet(1-np.abs(stim_prev_id-10)/10), alpha=0.3)\n",
"ax2.eventplot(spikes-0.15)\n",
"ax2.set_xlim([t0, t1])\n",
"\n",
"ax3.plot(np.sin(np.pi*tau_id_range/300), np.arange(300))\n",
"ax3.set_xticks([])\n",
"ax3.set_yticks([])\n",
"ax3.set_title('reverse correlation')\n",
"# ax2.legend()\n",
"for ax in fig.get_axes():\n",
" ax.tick_params(bottom=False, labelbottom=False, left=False, labelleft=False)\n",
"\n",
"ax2.tick_params(bottom=True, labelbottom=True)\n",
"ax2.set_xlabel('t/s')\n",
"plt.tight_layout()\n",
"fig.suptitle('subspace reverse correlation', size=16, y=1.05)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeUAAAG5CAYAAACwfCzuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAA+h0lEQVR4nO3de5xd873/8de7JhFyRyRpEkncpVIhiUQpyqlbnVIHpUhSKtrS8jtOUbQc5RxtlVbr0hASTtzqXrcWx7V1OUmohFBBQshIlNxEyMTn98daM90ZM5M9l73Xmtnv5+OxH7PXd90+a82e/Zm11md9lyICMzMzy97nsg7AzMzMEk7KZmZmOeGkbGZmlhNOymZmZjnhpGxmZpYTTspmZmY54aRsViKS7pc0Pn0/QdKTJVzXZpJWSFqvVOtoYt0rJG1e7vWadUROymZNkLSbpL9KWirpfUl/kTS6mHkjYv+ImFrqGNN1vRkR3SJiTTnWV2/d3SLidQBJUySdX+4YzDqKqqwDMMsrST2Ae4DvAbcAnYEvAx9nGZeZdVw+UjZr3NYAEXFjRKyJiI8i4s8R8QLUnZL+i6TfpUfSL0vau3ZmSY9K+k5DC5b0S0lPSuqZviZLWijpbUnn156GlrSlpMfS5b8n6eZGljdEUkiqKlj3z9L4lkv6s6RNGpn3M6fW02Vtmb6fIukySfemy3pG0hb1p5U0ETgKOC09pf3HdPzp6XYtl/RK4T4ys7U5KZs17u/AGklTJe0vqXcD04wBXgM2Ac4Bbpe0UWMLlPQ5SV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VUgZmZmlc59X+eEK1mtrZXqM1Wuz2pHrFp
"text/plain": [
"<Figure size 504x504 with 3 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# subspace reverese correlation\n",
"stim_id = 13\n",
"ref_trial_id = stim_id_trial['phase'][stim_id][0]\n",
"stim_prev_id = trial_stim_id['phase'][ref_trial_id-1]\n",
"past_trials = 3\n",
"future_trials = 10\n",
"trial_range = np.arange(-past_trials, future_trials+1) + ref_trial_id\n",
"\n",
"units = np.arange(num_unit)\n",
"orientation, phase, t_on = np.array(stim[['grat_orientation', 'grat_phase','stim_ontime']].iloc[trial_range]).T\n",
"spikes = [\n",
" spike_times[unit_id][\n",
" # Where the spike occurs during the stimulus period in one of the right trials\n",
" np.where((t_on[0] < spike_times[unit_id]) & (spike_times[unit_id] < t_on[-1]))\n",
" ]\n",
" for unit_id in units]\n",
"\n",
"fig, ax = plt.subplots(2,1,figsize=(7,7))\n",
"plt.subplots_adjust(hspace=0)\n",
"s = 1\n",
"ax[0].eventplot(spikes, linelength=s, lineoffsets=s)\n",
"\n",
"ref_id = list(trial_range).index(ref_trial_id)\n",
"# ax[0].axvspan(t_on[ref_id], t_on[ref_id]+0.08, color=cmap_jet(1-np.abs(stim_id-10)/10), alpha=0.3)\n",
"# ax[0].axvspan(t_on[ref_id-1], t_on[ref_id-1]+0.08, color=cmap_jet(1-np.abs(stim_prev_id-10)/10), alpha=0.3)\n",
"ax[0].set(ylabel='unit')\n",
"ax[0].invert_yaxis()\n",
"ax[1].step(t_on, phase, 'b', where='post', alpha=0.5, label='phase')\n",
"ax[1].set(xlabel='t / s', xlim=[t_on[0], t_on[-1]], ylim=[0, 360], ylabel='phase')\n",
"ax[1].legend(loc='upper left')\n",
"ax2 = ax[1].twinx()\n",
"ax2.step(t_on, orientation, 'r', where='post', alpha=0.5, label='orientation')\n",
"ax2.set(ylim=[0, 180], ylabel='orientation')\n",
"ax2.legend()\n",
"ax[0].set_title('Spikes in units')\n",
"ax[1].set_title('Phase and orientation')\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "afc70624cbfe4a5f8838bce9ae0c0ebc",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=0, description='delay/ms', max=299), IntSlider(value=0, description='uni…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"@widgets.interact(key=widgets.RadioButtons(options=key_list[1:],\n",
" description='stimulus:',\n",
" disabled=False), tau_id=widgets.IntSlider(0, min=0, max=max_delay-1, description='delay/ms'), unit_id=widgets.IntSlider(0, min=0, max=num_unit-1))\n",
"\n",
"def PSSH(tau_id, unit_id, key):\n",
" fig, ax = plt.subplots(1, 1, figsize=(7,6))\n",
" prob = stim_hist[key][unit_id, tau_id]\n",
" n = sorted_spike_num[unit_id]\n",
" confidence_interval = np.sqrt(prob/n)\n",
" plt.errorbar(stim_val[key], stim_hist[key][unit_id, tau_id], yerr=confidence_interval)\n",
" ymin = np.min(stim_hist[key][unit_id])*0.95\n",
" ymax = np.max(stim_hist[key][unit_id])*1.05\n",
" ax.set_ylabel('$\\mathcal{P}($'+key_symbol[key]+'$|\\\\tau)$')\n",
" ax.set_xlabel(key_symbol[key])\n",
" plt.ylim([ymin, ymax])\n",
" plt.suptitle('Distribution of stimulus at time $\\\\tau$ before a spike of unit: %d'%unit_id)\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Problem with the data\n",
"\n",
"The picture a couple of cells below clearly shows that there is a shift in the stimulus presentation times. Let's fix it!"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python3.10/site-packages/pandas/core/roperator.py:13: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.\n",
" return right - left\n"
]
}
],
"source": [
"trial_spike_times = np.ndarray((num_unit, num_trial), dtype=object)\n",
"delta_t_on = 0.2 # 200ms\n",
"delta_t_off = 0.3\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))]\n",
"subseq_trials = 5\n",
"subseq_spike_times = np.ndarray(num_unit, dtype=object)\n",
"for unit_id in range(num_unit):\n",
" subseq_spike_times[unit_id] = [np.concatenate(trial_spike_times[unit_id][i:i+subseq_trials]) for i in range(num_trial-subseq_trials)]\n",
"\n",
"subseq_spike_times_locked = {}\n",
"subseq_spike_times_locked['ontime'] = [subseq_spike_times[unit_id] - stim['stim_ontime'][:-subseq_trials] for unit_id in range(num_unit)]\n",
"subseq_spike_times_locked['offtime'] = [subseq_spike_times[unit_id] - stim['stim_offtime'][:-subseq_trials] for unit_id in range(num_unit)]"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"time_range = np.arange(0, stim['stim_ontime'].max(), np.array(sorted(np.diff(stim['stim_ontime'], n=1))[10:-10]).mean())"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((28, 19995), (28, 19995), 0.7671829999999886)"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"subseq_spike_times_len = len(subseq_spike_times[0])\n",
"subseq_spike_times_locked['ontime'] = np.array(subseq_spike_times_locked['ontime'])\n",
"subseq_spike_times_locked['offtime'] = np.array(subseq_spike_times_locked['offtime'])\n",
"from itertools import chain\n",
"subseq_spike_times_locked['ontime'].shape, subseq_spike_times_locked['offtime'].shape, max(chain(*subseq_spike_times_locked['ontime'].flatten()))"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAJsCAYAAAAsihANAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAADTXElEQVR4nOzdefwdVX3/8fdJAgQwYRUIIkYRQRZBQZG6BVHEFdta0FbrvlTtrhVcA2JBq/2ptSrWBax7tXUDBEEQ0SAICkgEZYsCEWRNILIknN8f3zthvpOZe2fmzlnmzOv5ePAg937vcu58536+cz7nc84x1loBAAAAAAAAPs0J3QAAAAAAAAAMD0kpAAAAAAAAeEdSCgAAAAAAAN6RlAIAAAAAAIB3JKUAAAAAAADgHUkpAAAAAAAAeEdSCgAAIDLGmE8aY94Vuh0AgOkQz4HxjLU2dBsAAABQwRizRNIXrLU7jXnMQZLeLelxkm6z1i720jgAQG014/k/SvpbSdtKulPSVyW91Vq71kcbAd+olAIAAOi/uyR9VtJbQzcEADCVb0t6nLV2oaS9JO0j6e/CNglwh6QUAACAA8YYa4x5ZO72icaYY0f/XmKMuc4Y88/GmJuMMSuNMa8sPtYYs7mkUyXtaIy5c/TfjsX3staeb639b0lXe/hoADAonuP5Vdba27OnS7pf0iOLjwNSQVIKAAAgjB0kbSHpIZJeLek/jTFb5R9grb1L0rMl3WCtfdDovxv8NxUAMEan8dwY85fGmFWSbtZMpdQJTlsPBERSCgAAIIz7JB1jrb3PWnuKZtYO2S1wmwAAzXUaz621XxpN33uUpE9KurGbZgLxISkFAAAQxi2FhWvXSHpQqMYAAFpzEs+ttb+RdJmkj0/7WkCsSEoBAAC4sUbSZrnbO7R8HbZKBoCwQsbzeZJ2afl+QPRISgEAALjxC0l/aYyZa4w5VNLTWr7OjZK2McZsUfUAY8wcY8x8SRvN3DTzjTEbt3w/AMBsv5C/eP4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iUAhJhrdWyq27RX376p1qy24N14iufELpJgFOMrPsRugMT24W0y/bE9lljEfIcbDIFNntsJnuO74XO+4h4HheX37lxC4y7XvA8hL62uwt9/uxl8Tx/3+q712rB/HnE9RJtKqVISgGJYaFzDEXITsyknU9CVk+57ACHTlClLPSaS33uPNThez2pkI44YZmWr1ylPRYt7E0FZ4h43nSXwqFVxcYs9XiF6aUa47P4LinaGE9SqgaSUkjZuvutdnn7Kdr7IVvoQ4fvo0dtvyB0kwBnXHRiutiqN1VlF3i+tgnP0AEBHjDNRguxxS4qpcJLtRM/VF0k7tr+DSZpOGwkpWogKYWUFf94fP0NB2r/xVsHag3gVgydGJ8VCUwBGq+ri+CuEmF12zNpt7pQF/Wu3j/k5yquP+Ky8x3y+1pVARRLAqpMDPG8Sh+OHzaUjzVV/276OmW3i4/LtHkvtENCNS4kpWogKYWUHf7JZTr/2lvX375k6SFaOH+jgC0C3Im5E4PphL6Qn6YDM+175qXakRlCBVwxKVWWpOoqcZVC0iT2eF51jH0mH4vvNc1i5yGEjuuAT65iQx8GHUhK1UBSCqljTSkMRQydmGmmz3St6gKoywujXY46WeusNNf428UpRAKDEW9MUvd7VVwsN+Ozgip0bKojhniOMIitcejib63L3+U01xtdX6u4SDiNu56sE8NjivMkpWogKYXUkZTCUPShE+PiIsFlxUUd4y7uur7wG1c91MeOTFmbY64a6uMxLlOWTM3fTkFxke5MDB2UOmKK56luVOFD1YYNZdWnRX2PM0XTThN0/XqpKNvEIovvmT7H+arYnokxxpOUqoGkFFJ19R/u1NM/9MNZ9/3
"text/plain": [
"<Figure size 1440x720 with 3 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"unit_id = 1\n",
"unit_id_2 = 3\n",
"\n",
"fig, ax = plt.subplots(1,3, figsize=(20,10))\n",
"ax[0].plot(np.diff(stim['stim_ontime'], n=2), np.arange(20000-2))\n",
"ax[0].invert_yaxis()\n",
"ax[0].set_xlabel('$\\Delta^2[t_{on}]=\\Delta$ trial duration / s', size=20)\n",
"ax[0].set(ylabel='trials')\n",
"ax[1].eventplot(subseq_spike_times_locked['ontime'][unit_id], lineoffsets=1, linelengths=0.8)\n",
"ax[1].set(title='unit %d'%unit_id, yticks=[], xlabel='t/s (locked to trial onsets)')\n",
"ax[1].invert_yaxis()\n",
"ax[2].eventplot(subseq_spike_times_locked['ontime'][unit_id_2], lineoffsets=1, linelengths=0.8)\n",
"ax[2].set(title='unit %d'%(unit_id_2), yticks=[], xlabel='t/s (locked to trial ends)')\n",
"ax[2].invert_yaxis()\n",
"plt.subplots_adjust(wspace=0)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_Whaaat?_\n",
"\n",
"Ok, we've gotta fix it.\n",
"\n",
"Let's take the \"bad\" times, identify the periods we want to calibrate - and align everything"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2280 2286 2291 2292 2295 2298 2301 2307 2377 2378 2380 2383 2386 2464 2467 2469 2472 2475 2478 15300 15306 15312 15315 15316 15318 15327 15329 15333 15336 15338 15342 15344 15348 15349 15402 15403 15405 15408\n"
]
}
],
"source": [
"stim_2diffs = np.diff(stim['stim_ontime'], n=2)\n",
"print(*[i for i in range(len(stim_2diffs)) if stim_2diffs[i] > 0.01])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Periods:\n",
"$[0, 2350)$, $[2350, 15350)$, $[15350, 20000]$"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_4135643/175591453.py:20: DeprecationWarning: Please use `gaussian_filter1d` from the `scipy.ndimage` namespace, the `scipy.ndimage.filters` namespace is deprecated.\n",
" period_1_dist = scipy.ndimage.filters.gaussian_filter1d(period_1_dist, sigma=10)\n",
"/tmp/ipykernel_4135643/175591453.py:21: DeprecationWarning: Please use `gaussian_filter1d` from the `scipy.ndimage` namespace, the `scipy.ndimage.filters` namespace is deprecated.\n",
" period_2_dist = scipy.ndimage.filters.gaussian_filter1d(period_2_dist, sigma=10)\n",
"/tmp/ipykernel_4135643/175591453.py:22: DeprecationWarning: Please use `gaussian_filter1d` from the `scipy.ndimage` namespace, the `scipy.ndimage.filters` namespace is deprecated.\n",
" period_3_dist = scipy.ndimage.filters.gaussian_filter1d(period_3_dist, sigma=10)\n"
]
}
],
"source": [
"p1, p2 = 2350, 15350\n",
"delta_t = 0.002\n",
"time_range_smoothing = np.arange(0, 0.8, delta_t)\n",
"period_1_dist = np.zeros(len(time_range_smoothing) - 1)\n",
"period_2_dist = np.zeros(len(time_range_smoothing) - 1)\n",
"period_3_dist = np.zeros(len(time_range_smoothing) - 1)\n",
"num_units = subseq_spike_times_locked['ontime'].shape[0]\n",
"for i in range(num_units):\n",
" for j, row in enumerate(subseq_spike_times_locked['ontime'][i]):\n",
" hist = np.histogram(row, bins=time_range_smoothing)[0]\n",
" if j < p1:\n",
" period_1_dist += hist\n",
" elif j < p2:\n",
" period_2_dist += hist\n",
" else:\n",
" period_3_dist += hist\n",
"period_1_dist /= num_units\n",
"period_2_dist /= num_units\n",
"period_3_dist /= num_units\n",
"period_1_dist = scipy.ndimage.filters.gaussian_filter1d(period_1_dist, sigma=10)\n",
"period_2_dist = scipy.ndimage.filters.gaussian_filter1d(period_2_dist, sigma=10)\n",
"period_3_dist = scipy.ndimage.filters.gaussian_filter1d(period_3_dist, sigma=10)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.collections.EventCollection at 0x7f1b53e02f80>]"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmoAAAR8CAYAAAAtjbjDAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG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5ifWE1bR1uL1bWdysPVDI5M4akqLA+32PJ+GRO1DVTEEAL+r64tQRr4eaZWec9NykqjDm5CSwNoJZOEZGecKJF7VHgyu4HrLW3WWunW2unA/8AXuj28qGu16y19/qvTBlqapta2XOivsfrjJ3NhaOTaGxpZ/uxWu8U1g8NzW1sKaph0Zjkft2n67/J2oOV3ijLK17dcYKZw+PITojs0fmXTUjlYHkjhytP+rgyERHv8XtQs9auBM64VLjpHL39YeBpvxYlAqwvrMZamDeqb92eXeaNSsSYziUxnLa+sJp2t2XR2P4FteyESIYnRLLmUGBMKCiqamLPiXquntLzJVQu9SxNEojLp4iInE2gjVFbCJRZawu6HRtpjNlqjFlhjFnoVGEy+K0vrCIiJIhpWXH9uk9cZChTM2NZEwBBbUNhFaHBLmYMj+v3veaPSmR9YRUdbufHqb2+q3NdtysmpfX4mqz4SCamx7BsT+BNihAROZtAC2of4f2taSeA4dbaGcDXgKeMMWdc3MoYc48xJt8Yk19RETgDuWXgWHuokrwR8X1awuJ0C0YnsbWolkaHF1ndcLiaGdlxhAWfe2P5npg/OomG5nZ2ldR5obL+eXN3KVMyY3vc7dnlonHJbCmq0eK3IjJ
"text/plain": [
"<Figure size 720x1440 with 3 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(3, 1, figsize=(10,20))\n",
"ax[0].plot(time_range_smoothing[:-1], period_1_dist, label='period 1')\n",
"ax[1].plot(time_range_smoothing[:-1], period_2_dist, label='period 2')\n",
"ax[2].plot(time_range_smoothing[:-1], period_3_dist, label='period 3')\n",
"ax[0].set(xlabel='t/s', ylabel='spike count', title='1st part')\n",
"ax[1].set(xlabel='t/s', ylabel='spike count', title='2nd part')\n",
"ax[2].set(xlabel='t/s', ylabel='spike count', title='3rd part')\n",
"ax[0].eventplot([0.2], linelengths=0.8)\n",
"ax[1].eventplot([0.2], linelengths=0.8)\n",
"ax[2].eventplot([0.2], linelengths=0.8)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"100"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(time_range_smoothing).index(0.2)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.2 0.162 0.194\n"
]
}
],
"source": [
"max_p_1 = time_range_smoothing[np.argmax(period_1_dist[:120])]\n",
"max_p_2 = time_range_smoothing[np.argmax(period_2_dist[:100])]\n",
"max_p_3 = time_range_smoothing[np.argmax(period_3_dist[:120])]\n",
"delta_2 = max_p_1 - max_p_2\n",
"delta_3 = max_p_1 - max_p_3\n",
"print(max_p_1, max_p_2, max_p_3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we'll fix the times"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"t_p1, t_p2 = stim['stim_offtime'][p1], stim['stim_offtime'][p2]\n",
"fix_time = lambda t: t - delta_2 * ((t < t_p2) & (t >= t_p1)) - delta_3 * ((t >= t_p2))"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 2.5839\n",
"1 2.7028\n",
"2 2.7863\n",
"3 2.8699\n",
"4 2.9534\n",
" ... \n",
"19990 1671.6389\n",
"19991 1671.7224\n",
"19992 1671.8059\n",
"19993 1671.8894\n",
"19994 1671.9730\n",
"Name: stim_offtime, Length: 19995, dtype: float64"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fix_time(stim['stim_offtime'][:-subseq_trials])"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python3.10/site-packages/pandas/core/roperator.py:13: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.\n",
" return right - left\n"
]
}
],
"source": [
"subseq_spike_times_locked_2 = {}\n",
"subseq_spike_times_locked_2['ontime'] = [subseq_spike_times[unit_id] - fix_time(stim['stim_ontime'][:-subseq_trials]) for unit_id in range(num_unit)]\n",
"subseq_spike_times_locked_2['offtime'] = [subseq_spike_times[unit_id] - fix_time(stim['stim_offtime'][:-subseq_trials]) for unit_id in range(num_unit)]"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJ8AAAJsCAYAAABTWwL8AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAADS4klEQVR4nOzdebwdRZ3//3eRAAFMWAWCGKOIIIugoLgbRBFXnBkHdEbHfRl1dh3FNSAO6Oj81HFU/LqA4z464wYIgiCiQTYFJIKyRYEosplACJBQvz/u6dC3092n+5yupatfz8eDB7lnrdO3z+d2fepTVcZaKwAAAAAAAMCFTUI3AAAAAAAAAOki+QQAAAAAAABnSD4BAAAAAADAGZJPAAAAAAAAcIbkEwAAAAAAAJwh+QQAAAAAAABnSD4BAABExhjzKWPMu0O3AwAwHeI5MMNYa0O3AQAAABWMMUskfdFau2vNYw6W9B5Jj5F0m7V2sZfGAQAaaxjP/0nS30naQdIdkr4m6a3W2nU+2gi4QuUTAABA/90p6XOS3hq6IQCAqXxH0mOstQsk7SNpP0l/H7ZJwPRIPgEAADhgjLHGmIfnfj7RGHPs6N9LjDHXG2P+xRhzkzFmpTHmlcXHGmO2knSqpF2MMXeM/tul+F7W2vOttf8t6RoPHw0ABsVzPL/aWnt79nRJ90l6ePFxQN+QfAIAAAhjZ0lbS3qQpFdL+i9jzLb5B1hr75T0bEk3WmsfMPrvRv9NBQDU6DSeG2P+yh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kq7VTYErPrbv2sbQusd3+VopKF5f5GN8po+xvpiQKup7nCf5lEPyCam65o936Okf/tG
"text/plain": [
"<Figure size 1440x720 with 3 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"unit_id = 1\n",
"\n",
"fig, ax = plt.subplots(1,3, figsize=(20,10))\n",
"ax[0].plot(np.diff(stim['stim_ontime'], n=2), np.arange(20000-2))\n",
"ax[0].invert_yaxis()\n",
"ax[0].set_xlabel('$\\Delta^2[t_{on}]=\\Delta$ trial duration / s', size=20)\n",
"ax[0].set(ylabel='trials')\n",
"ax[1].eventplot(subseq_spike_times_locked_2['ontime'][unit_id], lineoffsets=1, linelengths=0.8)\n",
"ax[1].set(title='unit %d'%unit_id, yticks=[], xlabel='t/s (locked to trial onsets)')\n",
"ax[1].invert_yaxis()\n",
"ax[2].eventplot(subseq_spike_times_locked_2['ontime'][unit_id_2], lineoffsets=1, linelengths=0.8)\n",
"ax[2].set(title='unit %d'%(unit_id_2), yticks=[], xlabel='t/s (locked to trial ends)')\n",
"ax[2].invert_yaxis()\n",
"plt.subplots_adjust(wspace=0)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [],
"source": [
"s = np.array([np.array(list(map(fix_time, spike_times[unit_id]))) for unit_id in range(len(spike_times))], dtype=object)//dt\n",
"B_spike_fixed = []\n",
"for unit_id in range(num_unit):\n",
" B_spike_fixed.append(sparse.coo_matrix((np.ones(len(s[unit_id])), (np.zeros(len(s[unit_id]), dtype=int), np.int0(s[unit_id]))), shape=(1, M)))"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"from copy import deepcopy\n",
"B_stim_original = deepcopy(B_stim)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"B_stim = {}\n",
"for key in key_list:\n",
" B_stim[key] = []\n",
" for stim_id, trials in enumerate(stim_id_trial[key]):\n",
" B_stim[key].append([])\n",
" s = []\n",
" for trial_id in trials:\n",
" t_on, t_off = fix_time(stim['stim_ontime'][trial_id]), fix_time(stim['stim_offtime'][trial_id])\n",
" s += list(np.arange(int(t_on//dt), int(t_off//dt)))\n",
"\n",
" B_stim[key][stim_id] = sparse.coo_matrix((np.ones(len(s)), (np.zeros(len(s), dtype=int), s)), shape=(1, M))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Calculate some matrices"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"get_trial_index = lambda t: fix_time(stim['stim_ontime'][t])//dt"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"B_spike_smooth = list()\n",
"for unit_id in range(len(B_spike)):\n",
" B_spike_smooth.append(scipy.ndimage.gaussian_filter(B_spike[unit_id].toarray()[0], sigma=50))\n",
"B_spike_smooth = np.array(B_spike_smooth)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f1b6ae5dcc0>]"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAABS2UlEQVR4nO29eZxkZ3nf+31rX3vfZu8ZzUij0YoYLUhgYwgYcEAxBlvg6xDbN8R2+NwbO3ECjq9jE998jG9snASubRJzg1cwYGLZgGVACIMkJI3WmZE0mn3p6Z7eu7r27b1/nPOerq46VXWqpraufr+fz3ymuupM13t6qp/znN/7PL9HSCnRaDQaTf/i6vYCNBqNRtNedKDXaDSaPkcHeo1Go+lzdKDXaDSaPkcHeo1Go+lzPN1eQDljY2Nyenq628vQ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YgXpbRq4Af74GMPpbKWZm8ta4+y+gHAhsjnIUQDIW8fa3RLyWypHNF9o4EGYv4e8optdVshYz+HuCMlPKclDILfB54sOyYB4HPmY+/BLxVCCGAtwMvSSlfBJBSLkkp23LpumPPEAcnInzuiQvt+PbbgkQmj9slLEc9S7rpskafLxRJZAvWZmzYrAqK91FGv57euJAphkK+vtboZ8yZxLuGQ4xFfX1na1FKvYw+0wMWCLuAyyVfXzGfsz1GSpkH1oBR4EZACiEeEUI8J4T4t3ZvIIT4sBDimBDi2MJCc0ORA143bzk8yfGZNT2CrUkSmQJhnxvjGl0i3XQ50Ks7DRUIo37j716402gVyWzBuoAphvvQ6qEUlcGPR/2MR/wsbIeMvkrVTXqLWyB4gDcCP2n+/aNCiLeWHySl/IyU8qiU8uj4+HjTb3bbrkF
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(B_spike_smooth[0][:5000]) # ~10 trials"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Reverse correlation\n",
"\n",
"TL;DR: We find the reverse correlation matrices. When we plot them they look meh, but if we plot them smoothed, they look awesome. However, we shouldn't use this smoothing when decoding parameters because it uses our (parameter-defined) notion of distance between points."
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"B_stim_total = np.sum(B_stim['phase'])"
]
},
{
"cell_type": "code",
"execution_count": 100,
"metadata": {},
"outputs": [],
"source": [
"R = dict()\n",
"for key in key_list:\n",
" R[key] = list()\n",
" for i in range(len(B_stim[key])):\n",
" item = []\n",
" for u in range(len(B_spike_smooth)):\n",
" item.append(B_stim[key][i].dot(np.roll(B_spike_smooth[u], 80)))\n",
" R[key].append(item)\n",
" R[key] = np.array(R[key])"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [],
"source": [
"R['pair'] = R['pair'].reshape((20, 20, 40))\n",
"Rp = R['pair']"
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [],
"source": [
"R_pair_smoothed = np.array([scipy.ndimage.gaussian_filter(R['pair'][:, :, i], sigma=2) for i in range(40)])"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA14AAAOUCAYAAACyq+IgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd5xcZdk+8Ove3muSTe+VBAghJITeuzSRIk1BQZFXbPhir6++4g95RQVEjUFEihRBOtJrIAkhJKT3uptke2/P74890SVkrrO7mWd3Zuf6fj75ZHfuPTPPnDnXOfNMObc55yAiIiIiIiL+JPX1AERERERERPo7TbxEREREREQ808RLRERERETEM028REREREREPNPES0RERERExDNNvERERERERDzTxCuBmdmdZva9vh6HSH+kfIn4oWyJ+KN8+aWJVxwzM2dm4/e67Idm9teuLO+c+4Jz7ifBcseZ2ZaQ2zMz+4WZ7Q7+/cLMrOf3QCR29UG+jjezl8ysysw29HjgIjGuD7J1o5ktNbMaM1tvZjf2fPQisa0P8vVVM1tnZtVmts3MbjWzlJ7fg/5NEy/pjmsAnAvgYAAHAfgEgGv7ckAi/UgdgLkA9KRQJLoMwBUACgGcBuB6M7u4b4ck0m88DmCGcy4PwDR0PEf8ct8OKXZp4tWP7Xmlwsy+bmZlZrbdzD7bqT7PzH5qZtkAngYw1Mxqg39D93GVVwK4xTm3xTm3FcAtAD7TK3dGJMZEO1/OuXecc/cAWNeLd0Mk5njI1s3OuUXOuVbn3EoAjwE4svfukUjs8JCvtc65yj2LA2gHMH7vv5MOmnj1f4MB5AMYBuBqAL8zs8LOf+CcqwNwOoBtzrmc4N+2fVzXVADvd/r9/eAykUQVzXyJyH94yVbw8fijASzzM2yRuBDVfJnZp82sG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w5zLnXJNzbnfw80IAawFM7O2xicQ75UvEH+VLxA9lSxJFX7zjdRKAFc65LXsuMLOBAMqdc21mNhbABADrwq4od0objnkg8umcH7qjgC4/ZD0/VfrKc/mpJK2Zn+6zK80xGucOofX6wSGnOp/F31JPDuljsPUUfjpftPPT6aaV81PhZm3kt7/mu/yUxcPvD99Es27gpxRuDDnt/8FzttL68t2DQ8cQQ6KWr+bWFGzcWRixvvXlEXR5y+enzN39AT9dfMtg/qJla3b4i5rrPxW5lwsAjJvKT4lfMpP3Knlj6QQ+gJAhPrSCn3L/pJPeo/WH35jFbyDkpbXMsvDX3g7MCcnHrBJaf+2Zg2m9LT2uXpyOWr7ggCRyDNk5ne8bqyfw41fuWr7v3Hwiv/4hb4Y06QKwewq/jfIp/PiQE9IoYOBj/HTy5X/m+/aKhXx8LSP4PiprGT9dfM1ZfP+Q+3J4r6HSWXz7bxvEzwt+1/v81OfteeRxTIqp7EUvWwa45Mj37d4nj6WLZ47lz1ta3uKni88o5+u1enT4fvcn591H6z9achatN5aHtIMIeW6IkDPe/+lD3opk4IxSWt+ew9fhPWtCjm1p4afkt3y+/5i/jLecSrqB72MLcnmroUjPTH2eTv4+AG8BmGRmW8zs6qB0MT76VjIAHANgSXAK0YcAfME5xxvwiCQw5UvEH+VLxA9lSxKdz7MaXhLh8s/s47KHATzsaywi/Y3yJeKP8iXih7Ilia6vzmooIiIiIiKSMDTxEhERERER8UwTLxEREREREc808RIREREREfFMEy8RERERERHP+qKPV9TsrsrFvCdPiFhPLeB9CqpG87ufVM97MWRt5/PWhkHhPTJ2Tef1cX/nfQLWDeR9QjJ383Vw1VVP0fqf/nwGrTcM4b0USt7hvWBS3uWPQcWk8E20/NlRtJ525G5a3/at8bS+67IEfX2iIQkpS3MilvOOKKOLjy/
"text/plain": [
"<Figure size 864x936 with 16 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, axs = plt.subplots(4, 4, figsize=(12, 13))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()):\n",
" ax.imshow(R['pair'][:, :, i], extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")"
]
},
{
"cell_type": "code",
"execution_count": 98,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA14AAAOUCAYAAACyq+IgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAADnrklEQVR4nOz9eZxtd13n+78/e6r5TDknycnESSAECBciRJCr2LR2t4jYgj8vDY2KikYUrvZtmxZUxIttd+u96q/tq2D8QQdtRZChoW1sRUTQK4NhCmEIJCGQhJNzkjPWvKfP74/aBysnZ38+u4Zv1a7ar+fjUY+qWt+99v7utdZnrfXdw3qbuwsAAAAAUE5luzsAAAAAALsdAy8AAAAAKIyBFwAAAAAUxsALAAAAAApj4AUAAAAAhTHwAgAAAIDCGHiNMDN7g5m9Zrv7AexG1BdQBrUFlEN9lcXAawczMzezx5w37ZfM7L8OMr+7v8zdf7k337PM7L7k8czMftXMTvR+ftXMbP3PABhe21Bf/9jMPmBmZ8zsnnV3HBhy21BbrzSz281s1sy+bGavXH/vgeG2DfX1f5jZ3WZ21sy+Zma/aWa19T+D3Y2BF9biJknPk/RkSU+S9N2Sfnw7OwTsIvOS3iSJk0Jgc5mkH5S0X9KzJb3CzF64vV0Cdo33SHqKu++R9EStnCP+1PZ2aXgx8NrFzr1SYWY/Y2bHzeyomf3wqvZbzOzfmdmUpD+TdJmZzfV+LrvAXb5E0q+7+33ufr+kX5f0Q1vyZIAhs9n15e4fc/c/kHT3Fj4NYOgUqK1fc/dPuHvb3e+Q9G5J37x1zwgYHgXq6y53P31udkldSY85/3ZYwcBr97tU0l5Jl0t6qaTfNrP9q2/g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
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, axs = plt.subplots(4, 4, figsize=(12, 13))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()):\n",
" ax.imshow(R_pair_smoothed[i], extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Topological noise reduction: 100%|██████████| 100/100 [01:57<00:00, 1.18s/it]\n"
]
}
],
"source": [
"res = top_noise_reduction(pd.DataFrame(Rp.reshape((400, 40)))).to_numpy()"
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"128.81601674915015"
]
},
"execution_count": 121,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res[0][0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Intermission: save variables to a file"
]
},
{
"cell_type": "code",
"execution_count": 132,
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"with open('dump.pkl', 'wb') as f:\n",
" pickle.dump({k: globals()[k] for k in [\n",
" 'data_folder', 'stim_file', 'spike_times_file', 'key_symbol', \n",
" 'stim', 'num_trial', 'stim_val', 'trial_stim_id', 'key_list', 'stim_id_trial', 'num_stim', 'key', 'pair_id', 'trial_pair_id', 'pair_val', 'pair_trial_id',\n",
" 'spike_times', 'num_unit', 'num_spike', 'spike_count_rate', 'avg_firing_rate', 'firing_rate', 'stim_num_trial', 'stim_hist', 'optimal_avg_firing_rate',\n",
" 'latest_spike_time', 'dt', 'exp_time', 'B_stim', 'trials', 't_on', 't_off', 'B_spike', 'trial_range', 'units', 'orientation', 'phase', 'trial_spike_times',\n",
" 'delta_t_on', 'delta_t_off', 'subseq_trials', 'subseq_spike_times', 'subseq_spike_times_locked', 'time_range', 'unit_id_2', 'p1', 'p2', 'delta_t', 'time_range_smoothing',\n",
" 'period_1_dist', 'period_2_dist', 'period_3_dist', 'num_units', 'max_p_1', 'max_p_2', 'max_p_3', 'delta_2', 'delta_3', 't_p1', 't_p2', 'subseq_spike_times_locked_2',\n",
" 'B_spike_fixed', 'B_stim_original', 'B_spike_smooth', 'B_stim_total', 'R', 'R_pair_smoothed', 'Rp'\n",
" ]}, f)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dict_keys(['data_folder', 'stim_file', 'spike_times_file', 'key_symbol', 'stim', 'num_trial', 'stim_val', 'trial_stim_id', 'key_list', 'stim_id_trial', 'num_stim', 'key', 'pair_id', 'trial_pair_id', 'pair_val', 'pair_trial_id', 'spike_times', 'num_unit', 'num_spike', 'spike_count_rate', 'avg_firing_rate', 'firing_rate', 'stim_num_trial', 'stim_hist', 'optimal_avg_firing_rate', 'latest_spike_time', 'dt', 'exp_time', 'B_stim', 'trials', 't_on', 't_off', 'B_spike', 'trial_range', 'units', 'orientation', 'phase', 'trial_spike_times', 'delta_t_on', 'delta_t_off', 'subseq_trials', 'subseq_spike_times', 'subseq_spike_times_locked', 'time_range', 'unit_id_2', 'p1', 'p2', 'delta_t', 'time_range_smoothing', 'period_1_dist', 'period_2_dist', 'period_3_dist', 'num_units', 'max_p_1', 'max_p_2', 'max_p_3', 'delta_2', 'delta_3', 't_p1', 't_p2', 'subseq_spike_times_locked_2', 'B_spike_fixed', 'B_stim_original', 'B_spike_smooth', 'B_stim_total', 'R', 'R_pair_smoothed', 'Rp', 'firing_rates_noise_red', 'firing_rates_flat', 'firing_rates_in_trials', 'avg_firing_rates'])\n"
]
}
],
"source": [
"file = open(\"dump.pkl\", 'rb')\n",
"data = pkl.load(file)\n",
"print(data.keys())\n",
"for key, value in data.items():\n",
" globals()[key] = value\n",
"file.close()"
]
},
{
"cell_type": "code",
"execution_count": 131,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"__name__ __doc__ __package__ __loader__ __spec__ __builtin__ __builtins__ _ih _oh _dh In Out get_ipython exit quit _ __ ___ os sys __vsc_ipynb_file__ _i _ii _iii _i1 np plt pd scipy sts pkl widgets mplot3d Axes3D sparse cm cmap_hot cmap_viridis cmap_jet _i2 data_folder stim_file spike_times_file key_symbol _i3 stim num_trial stim_val trial_stim_id key_list stim_id_trial num_stim key pair_id trial_pair_id pair_val pair_trial_id i _i4 _4 _i5 _i6 _i7 _7 _i8 spike_times active num_unit _8 _i9 num_spike _i10 files file_name file data value spike_count_rate avg_firing_rate sem_firing_rate firing_rate stim_num_trial C_r_fphi_theta theta_hist phase_hist pair_hist corr_stim_unit optimal_avg_firing_rate stim_hist stim_hist_caution _i11 max_delay tau_id_range latest_spike_time latest_stim_offtime experiment_dur dt exp_time M _i12 B_stim stim_id trials s trial_id t_on t_off B_spike unit_id _i13 sorted_spike_num cutoff_num_spike _i14 t0 t1 stim_prev_id t_prev_on t_prev_off spikes _i15 gridspec fig ax gs0 ax0 ax1 ax2 ax3 _i16 ref_trial_id past_trials future_trials trial_range units orientation phase ref_id _i17 PSSH _i18 trial_spike_times delta_t_on delta_t_off subseq_trials subseq_spike_times subseq_spike_times_locked _i19 time_range _i20 subseq_spike_times_len chain _20 _i21 unit_id_2 _i22 stim_2diffs _i23 p1 p2 delta_t time_range_smoothing period_1_dist period_2_dist period_3_dist num_units j row hist _i24 _24 _i25 _25 _i26 max_p_1 max_p_2 max_p_3 delta_2 delta_3 _i27 t_p1 t_p2 fix_time _i28 _28 _i29 subseq_spike_times_locked_2 _i30 _i31 B_spike_fixed _i32 deepcopy B_stim_original _i33 _i34 get_trial_index _i35 B_spike_smooth _i36 _36 _i37 _37 _i38 _38 _i39 _39 _i40 _40 _i41 _41 _i42 B_stim_total _i43 _i44 R _i45 item u _i46 _i47 _i48 _i49 _i50 _i51 _51 _i52 _52 _i53 _53 _i54 _54 _i55 _i56 _56 _i57 _57 _i58 _58 _i59 _59 _i60 _60 _i61 _61 _i62 _62 _i63 _63 _i64 _64 _i65 _65 _i66 _66 _i67 R_pair_smoothed _i68 axs _i69 _i70 _i71 _i72 _i73 _i74 _i75 _i76 _i77 _i78 _i79 _i80 _i81 _i82 _i83 _i84 _i85 _i86 _i87 _i88 _i89 _i90 _i91 _i92 _i93 _i94 _i95 _i96 _i97 _i98 _i99 _i100 R1 item1 _i101 _i102 _i103 _i104 Rp _i105 _i106 _i107 _i108 _i109 top_noise_reduction _i110 _i111 _i112 _i113 res _i114 _114 _i115 _115 _i116 _116 _i117 _117 _i118 _118 _i119 _i120 _120 _i121 _121 _i122 pickle _i123 f _i124 _i125 _i126 _i127 _i128 _128 _i129 _129 _i130 _130 _i131\n"
]
}
],
"source": [
"print(*globals().keys())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Forward correlation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"firing_rates_in_trials = [] # by pair, then by trial, then by neuron\n",
"firing_rates_flat = []\n",
"\n",
"for trial_ids in stim_id_trial['pair']:\n",
" row = []\n",
" for trial_id in trial_ids:\n",
" ind = round(get_trial_index(trial_id))\n",
" rr = []\n",
" for u in range(len(B_spike_smooth)):\n",
" rr.append(np.mean(B_spike_smooth[u][ind + 50:ind + 90]))\n",
" row.append(np.array(rr))\n",
" firing_rates_flat.append(np.array(rr))\n",
" firing_rates_in_trials.append(np.array(row))"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(400, (50, 40))"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"firing_rates_flat = np.array(firing_rates_flat)\n",
"len(firing_rates_in_trials), firing_rates_in_trials[0].shape"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"avg_firing_rates = np.array([np.mean(fr_pair, axis=0) for fr_pair in firing_rates_in_trials]).reshape((20, 20, 40))"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(20, 20, 40)"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA14AAAOUCAYAAACyq+IgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd3hc5Zk28PtR75Zkucjdxg0wYJoNoQQCoYeSsATSICGQxqZudlM3fbNhN8mXTsiGGBJCSCihBEILJXQM2MbgbtxtyZat3qXn+0PHiTCe+0iyXmlGc/+uy5el80x5Z+bc55x3ZnQec3eIiIiIiIhIOBnDPQAREREREZGRThMvERERERGRwDTxEhERERERCUwTLxERERERkcA08RIREREREQlMEy8REREREZHANPFKY2Z2nZl9dbjHITISKV8iYShbIuEoX2Fp4pXCzMzNbOY+y75uZr/ry/Xd/aPu/q3oeqeY2ZaY+zMz+56Z1UT/vmdmNvBHIJK8hiFfp5rZo2ZWZ2YbBjxwkSQ3DNn6vJktN7MGM3vdzD4/8NGLJLdhyNdnzGy9mdWb2TYz+6GZZQ38EYxsmnhJf1wN4EIARwA4HMA7AHxkOAckMoI0AbgBgA4KRQaXAfgAgDIAZwG4xswuHd4hiYwYdwM4yt1LAMxDzzHiJ4d3SMlLE68RbO87FWb2OTOrNrPtZvbBXvVFZvZtMysEcD+ACWbWGP2bsJ+bvBzA9919i7tvBfB9AFcMyYMRSTKDnS93f97dfwtg/RA+DJGkEyBb17r7S+7e6e6rANwF4IShe0QiySNAvta5e+3eqwPoBjBz38tJD028Rr7xAEYBmAjgSgA/M7Oy3hdw9yYAZwPY5u5F0b9t+7mtQwEs7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y94FZjYGwG537zKzGQBmAVgfd0OtozOx+vLEp5OdeDM/nebm82MaHbTxeWnmKN5gY+cFc/jtA+h4hp9Sc8dx/Prt0/kpQb9578X8BmJOSerT+XNY+SR/Y2nbSfwOtpzGz2fdWRB/yvCS1TG9lHJ4vXoBP2Xo+Kf5/ceuqENr0PJl3bwPTsVynp+aQ/ipXGsO5U2uGmbx081nlsTkF0DGBn5K3pyYsz1XHcPbGbTFnPK78nh+KvZNr/JGIJ/+xG20/oPreb4PeRc/1fSez0ykdQD42HseofVv/c/7+Q0s4NvJjefzU4LjJV4eYoOWL2TwHoHtFXy7VHUc365NeIJvO2sP4qdSLtwev+09/t1LaX3dXw+m9cYZMY2wtvNTrWfEtBLZczR/DgvXxvTRjDnlddvxvJ1DxtISWgcAn8q3YxntfDv63Orp/A5Sp0vXoGVrTHEDPn5i4u3WX/6D/wlZzcE8WzkxPSiz1/D9zrp3x/d3K+Fnc0fHKXW0vruAb1e7dvIeeg+28dPFVz7As7PnXY203lrF962LXngLrZe/ENMkE0DB+btofdc23uqkIXEnhp4x/HpgH6yGPJ38LQCeATDHzLaY2ZVR6VK88aNkADgZwLLoFKK3Afiou+8ONTaRVKd8iYSjfImEoWxJugt5VsPLEiy/Yj/Lbgdwe6ixiIw0ypdIOMqXSBjKlqS74TqroYiIiIiISNrQxEtERERERCQwTbxEREREREQC08RLREREREQkME28REREREREAhuOPl6DJqMDKNqceO7YzluAIGsn72NSxlvgoHU0f/qax/PrAwBi2gAUbeO9VLKaeC+GjtN5r4e8+3ifkbZy3gRkT0wrw9w9vJ7dxOudBfFNSNrKeN1inuPZN/J+EzuPie/FMhJltgMlpGNKVy5/3yavhj/xjZP5azvuSX77xRvj142aebyeW8fztfsQfh8H3VhF61t38z5ZmQt5AL7xxAW0nlPGn+NvTrq
"text/plain": [
"<Figure size 864x936 with 16 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, axs = plt.subplots(4, 4, figsize=(12, 13))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()):\n",
" ax.imshow(avg_firing_rates[:, :, i], extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"G_PAD = 5\n",
"\n",
"def gauss(img):\n",
" img_vpad = np.concatenate((img[-G_PAD:][:, ::-1], img, img[:G_PAD][:, ::-1]))\n",
" # pad horizontally too\n",
" img_vhpad = np.concatenate((img_vpad[:, -G_PAD:], img_vpad, img_vpad[:, :G_PAD]), axis=1)\n",
" return scipy.ndimage.gaussian_filter(img_vhpad, sigma=2, mode='wrap')[G_PAD:-G_PAD, G_PAD:-G_PAD]"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(20, 20)"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"avg_fr_blur = np.array([gauss(avg_firing_rates[:, :, i]) for i in range(40)])\n",
"gauss(avg_firing_rates[:, :, 0]).shape"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA14AAAOUCAYAAACyq+IgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAADpxklEQVR4nOz9e5ild1nn+3/udapzVx/T6SQdOoEQThsjIOpWHEadLSCO4I+LgUFFZYyMstU9DCOgiMOMM6N7q9c4W8C4YYKOIsphYBwcZRBFRzkECCGQBEII5Nid9LHO63T//qjVWOn0uu9Vh2/Vqqr367r66qrnXofvWuu5n+f5rrXq+Zi7CwAAAABQTmWrBwAAAAAAOx0TLwAAAAAojIkXAAAAABTGxAsAAAA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ssR6uyNs1YOHYqzViYacXOcnBuPByBpZiEOQ8qy0rJtiLWGK0xos1RarokH+7++jTNxf1Vm49c26y/V4/7sjuX95SNx2FAryblb3JfkdE2vL6erNRWvfN2RuO5JzJ0lUWpZRpeU7yNrcRySagvxY2jM9q9Xk/FvWx5nZVXaSU7XYnzz9Zm4Hj3nUn5sKkntJIcrqyspNxrxi39gdC6sP37iRFh/3MjxsH6oFu+7qoqfo/va+8K6JJ1rxzvYe0b3xtevJzvoNUZU8okXAAAAABTGxAsAAAAACmPiBQAAAACFMfECAAAAgMKYeAEAAABAYUy8AAAAAKAwJl4AAAAAUFixHC8ze7uk50s64e5P6S37JUk/Lumh3sVe7+4f7NVeJ+kVkjqSftrd/yy9j46rFmSZ2EK
"text/plain": [
"<Figure size 864x936 with 16 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, axs = plt.subplots(4, 4, figsize=(12, 13))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()):\n",
" ax.imshow(avg_fr_blur[i], extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")\n",
"avg_fr_blur = avg_fr_blur.swapaxes(0, 2).reshape((400, 40))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0., 9., 18., 27., 36., 45., 54., 63., 72., 81., 90.,\n",
" 99., 108., 117., 126., 135., 144., 153., 162., 171.])"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stim_val['orientation']"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f26f889e2c0>]"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAA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QIT1EpOVfLK2gJuGZ1Or4Rot+O02T0TMzxdSbdaV1LTelYITFD760f51NTW8bUrB7gdpV2ucrqS2klj0xZWCEzQKquo5u+fHOD6Ean0S+ridpx2adiVdEuRdSU1rWOFwAStF1flc7qqhm9cGRgnWK0rqWkrKwQmKFWcq+FvK/O5akgyw3vFuR2nQ8RHhzNjTBpvbyzm2Okqt+MYP2KFwASlV9YUcPzMuYDrbnn3hPqrkha4HcX4ESsEJuicq6nj2eX7GNuvGzkZ7k9K35GsK6lpCysEJui8taHQ5yal70jWldS0lhUCE1Rq65Q/LdtLZlocl/vQpPQd6aqhPejTLYYXVu53O4rxE1YITFA5Pyn9lQN9alL6jhQaItw1oS9r809YV1LjFSsEJmioKn9ctpcByV247hLfm5S+I30xpzcxEdaV1HjHCoEJGst2lrL9UDlfu2KAT05K35Hqr0pqXUmNN6wQmKCgqjy91DMp/fTRaW7H6RTWldR4ywqBCQpr9h9n3YETPHC5b09K35EG9Yxl8qAkXlplXUlN84LjN8IEvT8s20tS1wi+dKnvT0rfke6ZmMHh8kre2XrY7SjGh1khMAFvc2EZy3eV8pVJ/fxiUvqOdOUQpyupTXBvmmGFwAS8v368n9jIMO4c39ftKJ0uNES4c3wfcg+cIP/oGbfjGB/lzeT1USKyRkQ2ishWEXnUWb5CRPKcW7GIzGti+9oGz5vfYPk/RGSniGwRkb+KiP/MGG78RllFNYs2H+Km0b2I86NJ6TvSDSN7AbB
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"from sym_model import sigmoid\n",
"# sns.distplot([np.argmax(avg_fr_blur.reshape((20, 20, 40))[:, :, i], axis=0) for i in range(40)])\n",
"# plt.imshow(sigmoid(avg_fr_blur * 10000).reshape((20, 20, 40)).sum(axis=2), extent=(0, 360, 0, 180), aspect=2)\n",
"plt.plot(stim_val['orientation'], sigmoid(avg_fr_blur * 10000).reshape((20, 20, 40)).sum(axis=2).mean(axis=1))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Topological noise reduction (not used)"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.insert(0, '../model')\n",
"from noisereduction import top_noise_reduction"
]
},
{
"cell_type": "code",
"execution_count": 149,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Topological noise reduction: 100%|██████████| 100/100 [31:33<00:00, 18.93s/it]\n"
]
}
],
"source": [
"firing_rates_noise_red = top_noise_reduction(pd.DataFrame(firing_rates_flat[::5]))"
]
},
{
"cell_type": "code",
"execution_count": 150,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(400, 40)"
]
},
"execution_count": 150,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"firing_rates_noise_red.shape"
]
},
{
"cell_type": "code",
"execution_count": 151,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Topological noise reduction: 100%|██████████| 100/100 [3:44:17<00:00, 134.57s/it] \n"
]
}
],
"source": [
"firing_rates_noise_red = top_noise_reduction(pd.DataFrame(firing_rates_flat))"
]
},
{
"cell_type": "code",
"execution_count": 166,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2000, 40)"
]
},
"execution_count": 166,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"firing_rates_noise_red = firing_rates_noise_red.to_numpy()\n",
"firing_rates_noise_red.shape"
]
},
{
"cell_type": "code",
"execution_count": 167,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 167,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"firing_rates_noise_red[0] in firing_rates_flat"
]
},
{
"cell_type": "code",
"execution_count": 168,
"metadata": {},
"outputs": [],
"source": [
"from decoding import cohomological_parameterization"
]
},
{
"cell_type": "code",
"execution_count": 171,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KG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JCQkIDw83OBnwsPDdeIBID4+Xie+ukieP38eO3fuhJeX1x1zOXLkCORyOby9vRt5NkRELcOyZctaTJEErODWa3R0NCZNmoT+/fsjNDQU7733HoqKijB58mQAwMSJE9G2bVvExcUBAGbOnIlBgwZhxYoVeOSRR7B+/XocPnwYn376KQBNkRwzZgxSUlKwZcsWVFVVaZ9fenp6QqlUIjExEQcPHsSQIUPg6uqKxMREvPLKK3jqqafQqlUraf4giIhsRL9+/eDo6Ij58+c3+yIJABBW4MMPPxTt27cXSqVShIaGigMHDmi3DRo0SEyaNEkn/rvvvhNdunQRSqVS9OjRQ2zdulW77eLFiwKAwdfu3buFEEIkJyeLsLAw4e7uLhwcHET37t1FbGysKC0trXfOeXl5AoDIy8tr0rkTEdmiS5cuSZ1CkzTkO1zycZS2qiFjcIiIbN3777+PBx54AHfffbfUqZiEzYyjJCIi6xcbG4uXX34ZQ4cORXZ2ttTpWBwLJRG1COXl5UhLSwOKc4CSXABAWloaysvLpU3MytXu3frSSy/Vq3NkcyN5Zx4iInMrLy/H46MexYlD+7B7ghztPexxpc0QDFmegp69emPjxo1QKpVSp2l1WtIQkLqwUBJRs5ednY0Th/bizxslGPKVDF9HOWLi+z/iz5sCkMmRnZ0NPz8/qdO0KiySNXjrlYiaPT+nKuyeoMBdrWT486bAvV8W48+bAne1kmN3wk4Wydt89dVXLJK1sFASUfMnk6O9uxxfRzn
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Decoding... done\n"
]
}
],
"source": [
"param = cohomological_parameterization(pd.DataFrame(firing_rates_noise_red[::5, ::5]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### PCA"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"from sklearn.decomposition import PCA\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<AxesSubplot:>"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWgAAAD8CAYAAABaZT40AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAA5hUlEQVR4nO2de5wcZZX3v6fnksnkNoEECCSYAEFkUYREXtRVEbwEZGXXdRWQFbyhuCDgbfGy+IruZ0FcWdlV16xGRRHECJJXwwKLXGQ/ckkCBAi3JNwmhIRLEpJMJslMn/ePqoR2qHO6prtmpmdyvvn0Jz311FPP009VP1X9nPM7R1SVIAiCoPEoDXUHgiAIgmxigg6CIGhQYoIOgiBoUGKCDoIgaFBigg6CIGhQYoIOgiBoUGKCDoIgyIGIzBORtSLygFEuInKpiCwXkaUicni9bcYEHQRBkI+fAnOc8mOBmenrdOAH9TZY1wQtInNE5JH0jnFevZ0JgiBoVFT1NuBFZ5cTgMs04Q6gQ0Sm1NNmc60VRaQJ+B7wTqATuFtEFqjqMqvO9udXmrLF9x3+mcztH9k23uzDtW1bzbKjto/O3H4Im806j+oYs2zfcrdZdn9LW+b2OR1rzTrdXS1m2bKujsztP2/ZYNbZq5T9eQFm6KjM7c2OiFTsIlaUtjml2YxyngWanNY205u5faP2mHXGSJNZds+27HPyF62TzDpe/1qNz7Ude3B7KJtlbdh9327Ua3HGttsYP4AuzS7zntqandJe5zNbeP27+skF3mWYC2/OqaR18v6fJHnq3cFcVZ3bz+b2AZ6u+Lsz3ba6n8fZSc0TNHAEsFxVVwKIyJUkdxBzgg6CIBhUyvYNoJJ0Mu7vhDzg1LPEYd0tgiAIGgMt53sVwypgWsXfU9NtNTPgRkIROV1EFonIoh9ddsVANxcEQfAy5XK+VzEsAD6cenMcCWxQ1ZqXN6C+JY5cd4vKnw5514OCIAiKQIt7OkZErgC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bNCfbt7PLLMSal9bsiXM+zmy7YMNVX/ZMfhsd8pGO88J09uyL6nVTobzN7ba47TRGIwX1bAeAt8cbxt7L97Ykbn9Lexh1vHYu9eWRb8in1zKC06MZs8EZxnv2sX+Gq9xDIhag8FvvTPuhVCckfAIYLmqrgQQkSuBE/jzJNnKyyEvJgDP1NtoPRlVJgBvBU4DUNVtmDbyIAiCISD/8sXpwOkVm+aq6tyKv/cBKp+cOoH/0+cw/xe4QUTOAsYA7+hvd/tSzxP0DOA54CciciiwGDhbVe3HjSAIgsEkpxdHOhnPrbqjz0nAT1X1X9Pl3p+LyCGqtbuS1LMG3QwcDvwgXXPZDGQtnO+Uev+hK6TeQRAMIsUZCVcBlc73U9NtlXwMuApAVf8EtAF2CMoc1DNBdwKdqnpn+vd8kgn7z6iUeh/dHlLvIAgGkeIm6LuBmSIyI7W3nQgs6LPPU8AxACLyGpIJ+rl6ul9PTsJnReRpEXm1qj6SdmyZV2ffsm3Y2VTOXr6e5cT29RK5WvGbPUWgZwj80uJvmGXzX5ddb5LxmQC6y3ac3p/ck62SW1+yE5ve2mQnIp0q2Qq0w+gw64xT+9691FCENjkxkD3F2BixL8NNmm2UGu3U8Qx+mw0jYYehggP46ku2cXuG0Y9laserFmecHil5Y5g9kbQ6MZ89w51lJPTOlfdE19SIXrtajFJRVXtE5EzgeqAJmKeqD4rIBcAiVV0AfA74LxE5l8RgeJpqfR2o14vjLODy9I6yEvhInccLgiAojp7ipN6quhBY2Gfb+RXvl5EEkSuMuiZoVb0XmF1MV4IgCAompN5BEAQNyq4s9RaRc0XkQRF5QESuEDEWO4MgCIYC1XyvBqWejCr7AJ8BZqvqISQL5ycW1bEgCIK62cX
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fr_df = pd.DataFrame(firing_rates_flat)\n",
"sns.heatmap(fr_df.corr())"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(400, 40)"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"avg_fr_blur.shape"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(400, 7)\n"
]
},
{
"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>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>-0.000519</td>\n",
" <td>-0.000166</td>\n",
" <td>-0.000440</td>\n",
" <td>-0.000621</td>\n",
" <td>0.000040</td>\n",
" <td>0.000021</td>\n",
" <td>0.000077</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>-0.000851</td>\n",
" <td>-0.000060</td>\n",
" <td>-0.000512</td>\n",
" <td>-0.000473</td>\n",
" <td>0.000343</td>\n",
" <td>0.000135</td>\n",
" <td>0.000052</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>-0.001155</td>\n",
" <td>0.000042</td>\n",
" <td>-0.000481</td>\n",
" <td>-0.000354</td>\n",
" <td>0.000566</td>\n",
" <td>0.000213</td>\n",
" <td>0.000038</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>-0.001385</td>\n",
" <td>0.000152</td>\n",
" <td>-0.000368</td>\n",
" <td>-0.000247</td>\n",
" <td>0.000665</td>\n",
" <td>0.000252</td>\n",
" <td>0.000033</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>-0.001536</td>\n",
" <td>0.000289</td>\n",
" <td>-0.000196</td>\n",
" <td>-0.000120</td>\n",
" <td>0.000648</td>\n",
" <td>0.000248</td>\n",
" <td>0.000016</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2 3 4 5 6\n",
"0 -0.000519 -0.000166 -0.000440 -0.000621 0.000040 0.000021 0.000077\n",
"1 -0.000851 -0.000060 -0.000512 -0.000473 0.000343 0.000135 0.000052\n",
"2 -0.001155 0.000042 -0.000481 -0.000354 0.000566 0.000213 0.000038\n",
"3 -0.001385 0.000152 -0.000368 -0.000247 0.000665 0.000252 0.000033\n",
"4 -0.001536 0.000289 -0.000196 -0.000120 0.000648 0.000248 0.000016"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N_COMP = 7\n",
"pca = PCA(n_components=N_COMP)\n",
"pca.fit(avg_fr_blur)\n",
"data_pca = pca.transform(avg_fr_blur)\n",
"data_pca = pd.DataFrame(data_pca)\n",
"print(data_pca.shape)\n",
"data_pca.head()"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(400, 50, 7)"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"firing_rates_in_trials_pca = []\n",
"for trials in firing_rates_in_trials:\n",
" firing_rates_in_trials_pca.append(pca.transform(pd.DataFrame(trials)))\n",
"firing_rates_in_trials_pca = np.array(firing_rates_in_trials_pca)\n",
"firing_rates_in_trials_pca.shape"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [],
"source": [
"avg_firing_rates_pca = data_pca.to_numpy().reshape((20, 20, N_COMP))# np.mean(firing_rates_in_trials_pca, axis=1).reshape((20, 20, N_COMP))"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
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MzsyWXyTpSknPknSOpL8xs6e7e/dkP8BrruYZJy15AuvEHq51LVQvSx+/14j1v9bzUH03OH5rJlbf3BRbN81N6bXtjb3Q2N0N6duAJI1tXArVb98wH6rfOXM4VL+tERu/Vkl/vAdbk6Gx/8li29nDC/VQfYFuUM75Y11p7Ej6+mrMxrbrxpF2qL52NH27rswuhsb2+YVQvRZj+1iUTU6E6iu+Ibm2Oh57nah0QuWyWFxJsV0yXB+dTzXweKPrprYQm3xjNr0+OpdTcINyzh5JqtbS86Q3EXuSo4c+vcCxVX02NnjjcGwuY4dj21C1HavvjMfmv/j4WHLtI49vD4196/ZNofq/3Xx+qP6MqdixyXS9Gaofj4SJpLHATlwJHsssdss5lsntTJi7f1rSwRWLf0rS77p7M6vZny2/XNIH3b3p7l+TtFvSJXnNDcBwI38AlIHsAZCq6L8Je7qk7zKz283sf5vZi7LlOyQ9tKxuT7YMAAaF/AFQBrIHwJPk+XbEE/28LZIulfQiSR82s9D5UTO7RtI1klTdsmnQ8wMwvAaaP43JzQOfIIChNNDsqW3bOPAJAihe0WfC9kj6qPd9TlJP0jZJeyXtWla3M1v2JO5+nbtf7O4XV6encp8wgKEx0PypjZM/AJIM9thnA9kDDIOim7C/lPS9kmRmT5fUkPS4pFslXWlmY2Z2nqQLJH2u4LkBGG5/KfIHQPH+UmQPgBVyezuimd0k6SWStpnZHklvlXS9pOuzS7e2JF3l7i7pHjP7sKSvSOpIujbl6kAAcDzkD4AykD0AUuXWhLn7a07wrdeeoP5tkt6W13wAjA7yB0AZyB4AqYp+OyIAAAAAjDSaMAAAAAAoEE0YAAAAABSIJgwAAAA
"text/plain": [
"<Figure size 864x864 with 6 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"\n",
"fig, axs = plt.subplots(2, 3, figsize=(12, 12))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()[:7]):\n",
" ax.imshow(avg_firing_rates_pca[:, :, i], extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2EAAAL4CAYAAADyEv8AAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAABw60lEQVR4nO3de7wldXnn+++zLvvadxoQaRSIiEGPVyQ4jomRzBGNCcwcXx5MMiGGhElCLmYcE83NTBIz0ZkTo3PUhIwEzBjUoAlMxpnEoI6TE0URbyAaO4jS2NBA3/dtXeo5f6xqstl09/49u1f9avdan/fr1a/eq9azfutXv6p6qp5Va1WZuwsAAAAAkEej7g4AAAAAwDihCAMAAACAjCjCAAAAACAjijAAAAAAyIgiDAAAAAAyoggDAAAAgIwowrDumNkfmtmv190PAOOF3AOgLuSf8UMRhqEzMzezp6yY9ptm9l9TXu/uP+Xuv12+7sVmtmuV9zMze4uZPVL+e4uZ2drnAMDJqIbc871m9nEzO2Bm96654wBOejXkn9eb2Z1mdsjMvmFmr19771EHijCMgqslXS7pWZKeKekHJP2bOjsEYCzMSbpOEgc/AHIzST8qaaukSyX9rJldUW+XEEERhuyOfMJjZq8zsz1mttvMXrPs+evN7HfMbFbS/5D0RDM7XP574lGavFLS/+Puu9z9fkn/j6QfyzIzAE4aw8497v4Zd/9TSfdknA0AJ6EK8s9b3f0Od++5+9ck3SzphfnmCCeKIgx1eYKkzZLOlHSVpHea2dblAe4+J+llkr7t7hvKf98+SltPl/TFZY+/WE4DgJWGmXsAIKKS/FP+BONFku6qptuoAkUY6tKV9Fvu3nX3j0g6LOn8Nba1QdKBZY8PSNrA78IAHMUwcw8ARFSVf35Tg2P6PxlCW8ikVXcHMJL6ktorprU1SD5HPOLuvWWP5zUoptbisKRNyx5v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zs5dW1S8Ao4/8A6AO5B4AqVoVtn29pP9X0nuPTDCz75V0maRnufuSmZ1WTr9A0hWSni7piZL+1sye6u79472BN6XuBkvukB23taPE92LxjWB8hDdj8b3p9HGRpO7GWPudLUUo3k/pJMeesnUu1PaTN+0LxT9pem8o/vT2/lD8xsZiKD5qydPHfsnTx12SOu6h+NhakNX1qjj/qChkhxfSe9SLJQjvxJadLy5V1raKYPKMasTylVqxXZe30+OLiViy7U/EPsvst0Ph4dzv0Y9WY5u8LLDRx/ehsc5E+hKdzxNwvarOPUGFx7avXj+2EhVL6SvpxEKsLxMHQ+Ga3hvbK00cjA219WMrUm8mfWzac7GNvbkYy4OL8xtC8f8wNxGK37M11v69m7aF4p80m36s98TJ/aG2t7cOheI3NqPHefcfdWplZ8Lc/ZOSVh7t/rSk33P3pTJmTzn9Mknvd/cld/+GpJ2SLqqqbwBGG/kHQB3IPQBS5f5N2FMlvcjMbjOz/2Vmzy+nnynpvmVxu8ppADAs5B8AdSD3AHicKr+OeKz32ybpYknPl/RBMzs30oCZXS3paklqb9w69A4CGFlDzT9TzeB3eAGMq6HmnpnTY1/7ArA+5T4TtkvSh33gMxr8pGS7Bl+WPGtZ3A4d4wuU7n6tu1/o7hc2Z2Yr7zCAkTHU/DPRnK68wwBGwlBzz+TWqco7DKB6uYuwv5T0vZJkZk+VNCHpYUm3SLrCzCbN7BxJ50n6TOa+ARhtfynyD4D8/lLkHgArVPZ1RDO7UdKLJW03s12S3iTpOknXlZdu7Ui60t1d0l1m9kFJX5HUk3TNsK8OBGB8kH8A1IHcAyBVZUWYu7/6GE/9yDHi3yzpzVX1B8D4IP8AqAO5B0Cq3F9HBAAAAICxRhEGAAAAABlRhAEAAABARhRhAAAAAJBR7ps
"text/plain": [
"<Figure size 864x936 with 6 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"\n",
"fig, axs = plt.subplots(2, 3, figsize=(12, 13))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()):\n",
" ax.imshow(scipy.ndimage.gaussian_filter(avg_firing_rates_pca[:, :, i], sigma=2), extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Point Cloud Simplification"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [],
"source": [
"def radial_distance(X, eps, random_state=None):\n",
" \"\"\"\n",
" point cloud simplification using radial distance (euclidean metric). \n",
" Start with the first point in in X and mark it as a key point. All consecutive points that have a distance less than a predetermined distance eps to the key point are removed. The first point that have a distance greater than eps to the key point is marked as the new key point. The process repeates itself from this new key point, and continues until it reaches the end of the point cloud.\n",
" \n",
" Parameters\n",
" ----------\n",
" X: pandas DataFrame (n_datapoints, n_features):\n",
"\n",
" eps: max radial distance - cutoff distance\n",
"\n",
" random_state: seed of random generator used for choosing the inital point\n",
"\n",
" Returns\n",
" -------\n",
" X.iloc[ind_reduced]: dataframe with chosen datapoints \n",
" \"\"\"\n",
" if random_state is not None:\n",
" np.random.seed(random_state)\n",
" \n",
" ix0 = np.random.choice(X.shape[0])\n",
" x0 = X.iloc[ix0]\n",
" xt = x0\n",
" ixt = ix0\n",
" X_temp = X\n",
" ind_reduced = [ix0]\n",
"\n",
" while True:\n",
" dist = np.linalg.norm(X_temp.to_numpy() - xt.to_numpy(), axis=1)\n",
" cond = dist < eps\n",
"\n",
" X_temp = X_temp.drop(X_temp.index[np.where(cond)])\n",
" if len(X_temp)==0:\n",
" break\n",
"\n",
" where_not_cond = np.where(np.logical_not(cond))\n",
" w = np.argmin(dist[where_not_cond]) \n",
" ixt = X_temp.index[w]\n",
" xt = X.iloc[ixt]\n",
" ind_reduced.append(ixt)\n",
"\n",
" return X.iloc[ind_reduced], ind_reduced \n"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {},
"outputs": [],
"source": [
"from tqdm import trange\n",
"from noisereduction import compute_gradient\n",
"def top_noise_reduction(X, n=100, omega=0.2, fraction=0.1, plot=False):\n",
" \"\"\"\n",
" Topological denoising algorithm as in arxiv:0910.5947\n",
" \n",
" Parameters\n",
" ----------\n",
" X: dataframe(n_datapoints, n_features):\n",
" Dataframe containing the data\n",
" n: int, optional, default 100\n",
" Number of iterations\n",
" omega: float, optional, default 0.2\n",
" Strength of the repulsive force between datapoints\n",
" fraction: float between 0 and 1, optional, default 0.1\n",
" The fraction of datapoints from which the denoised dataset is\n",
" constructed\n",
" plot: bool, optional, default False\n",
" When true plot the dataset and homology each iteration\n",
" \"\"\"\n",
" N = X.shape[0]\n",
" inds = np.random.choice(N, round(fraction*N), replace=False)\n",
" S = X.iloc[inds]\n",
" sigma = X.stack().std()\n",
" c = 0.02*np.max(scipy.spatial.distance.cdist(X, X, metric='euclidean'))\n",
" \n",
" iterator = trange(0, n, position=0, leave=True)\n",
" iterator.set_description(\"Topological noise reduction\")\n",
" for i in iterator:\n",
" gradF = compute_gradient(S.to_numpy(), X.to_numpy(), sigma, omega)\n",
" \n",
" if i == 0:\n",
" maxgradF = np.max(np.sqrt(np.square(gradF).sum(axis=1)))\n",
" S = S + c* gradF/maxgradF\n",
" \n",
" if plot:\n",
" fig = pyplot.figure()\n",
" ax = Axes3D(fig)\n",
" ax.scatter(X[0],X[1],X[2],alpha=0.1)\n",
" ax.scatter(S[0],S[1],S[2])\n",
" pyplot.show()\n",
" return S, inds"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(414, 7)"
]
},
"execution_count": 127,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fr_pca_simpl, inds_simpl = radial_distance(pd.DataFrame(firing_rates_in_trials_pca.reshape((400 * 50, -1))), 0.025)\n",
"fr_pca_simpl.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Plots"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(400, 2)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"param_corr = stim_val['pair'] # [np.array(inds_simpl) // 50]\n",
"param_corr.shape"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [],
"source": [
"avg_firing_rates_pca_ = avg_firing_rates_pca.reshape((-1, N_COMP))"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAegAAAIICAYAAACl/H0TAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOydd3wU1deHn02DJJTQQ++9KiBIEURRFLAgWFCxYcWKBfUnVlBRBEUsYAHs9CJI7733EjqEUFJJT7bM9/1jQrLZNAJJQN95+PDZ7G1z5+7MnLnnnHuuTZKwsLCwsLCwuKrwutIdsLCwsLCwsMiKJaAtLCwsLCyuQiwBbWFhYWFhcRViCWgLCwsLC4urEEtAW1hYWFhYXIVYAtrCwsLCwuIqxBLQFhYWFhYWVyGWgLawuAqoVasW/v7+lChRgkqVKvHoo4+SkJAAwMKFC7nhhhsoWbIkFSpUoEuXLsyZMydT/RUrVmCz2RgxYsSV6L6FhUUhYAloC4urhL///puEhAS2bdvGli1bGDZsGNOmTaNfv34MGDCAU6dOce7cOT788EP+/vvvTHUnTZpE2bJl+eWXX65Q7y0sLAoaS0BbWFxlVK1aldtuu43du3czePBghg4dysCBAyldujReXl506dKFH374Ib18YmIi06ZN45tvvuHQoUNs2bLlCvbewsKioLAEtIXFVUZoaCj//PMPAQEBhIaG0rdv31zLz5gxgxIlStCvXz9uvfVWJk2aVEQ9tbCwKEwsAW1hcZVw1113ERQURKdO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2U92lHCGM2BxatsiOFBzMYT918OFepUD
"text/plain": [
"<Figure size 576x576 with 15 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"ncomp_disp = 5\n",
"fig = plt.figure(figsize=(8,8))\n",
"for j in range(ncomp_disp):\n",
" for i in range(j+1):\n",
" ax = fig.add_subplot(ncomp_disp,ncomp_disp, j + ncomp_disp*i + 1)\n",
" if i == j:\n",
" ax.scatter(\n",
" # param_corr[:, 0],\n",
" stim_val['pair'].reshape((-1, 2))[:, 1],\n",
" avg_firing_rates_pca_[:, i], s=1)\n",
" ax.set(xlabel='stim', ylabel='PC%d'%i)\n",
" else:\n",
" ax.scatter(avg_firing_rates_pca_[:, j], avg_firing_rates_pca_[:, i], s=1, c=stim_val['pair'].reshape((-1, 2))[:, 1], cmap='hsv')\n",
" \n",
" ax.set(xticks=[], yticks=[])\n",
" \n",
" if i==0 and j>0:\n",
" ax.set(xlabel='PC%d'%j)\n",
" ax.xaxis.set_label_position('top') \n",
"\n",
" if j==ncomp_disp-1 and i<ncomp_disp-1:\n",
" ax.set(ylabel='PC%d'%i)\n",
" ax.yaxis.set_label_position('right') \n",
"\n",
"fig.set_facecolor('white')\n",
"fig.suptitle('PCA')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### UMAP"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [],
"source": [
"from umap import UMAP"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
"ncomp_umap = 4\n",
"embed = UMAP(n_components=ncomp_umap, n_neighbors=10, metric='euclidean').fit_transform(avg_firing_rates_pca_)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"param_corr[:, 0].max()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a036911daea64abdac7731b44e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Z/+9Ke5/PLLGRgYOOb9br/9dq644go+8pGP8F/+y3/hyiuv5D/9p//EtddeS1EU4z7Ppz/9ad773vcC8L73vY/zzjuPe+6555jPJUmSJEnSXFSa7QFIkiRJktQuXve61/GVr3yFu+++mwsuuGDk8q9+9avUajWuvfZabrzxxjHv+5nPfIZVq1bxsY99jLe85S08/vjjnHrqqWPe9rWvfS2XXHIJAO95z3tYvnw5H//4x/nqV7/K29/+9nHH94Mf/OCoy04//XR+53d+h9tuu40Xv/jF4z4PwAc/+EFuvPFGXv/61/OGN7yBbdu20d3dPe7zSZIkSZI011iBLkmSJEnSBF1++eVs3ryZz33uc0dc/tnPfpZrr72WZcuWjXvfz33uc7zlLW/h9a9/PYsXLz7qMY7lVa96FQCPPfbYCY+5EdLv379/ws/1h3/4hzzxxBN85jOfOeHnkyRJkiSpnRmgS5IkSZJ0At7+9rfzhS98gRgjALt37+aGG27gHe94x7j3+fGPf8z27dt5+9vfTkdHB29605uO28a92SOPPALA8uXLj3vbLMvYvXs3zzzzDDfccAMf+tCH6O3t5dJLL53w873rXe8C4IYbbpjwfSRJkiRJmgsM0CVJkiRJOgHveMc7ePLJJ7nlllsA+NKXvkRXVxdveMMbxr3PZz7zGTZs2MBLX/pSAH7xF3+R+++/n7vuumvM2x84cIDdu3fz1FNP8cUvfpGPfvSjdHd38/rXv/6447vjjjtYuXIl69at45prriHGyNe+9rVjVsePtn79ehYvXjwS3EuSJEmSNF94BrokSZIkSSfgBS94Aeeffz6f//znednLXsbnPvc5fv7nf56enp4xb59lGV/84hf5lV/5FUIIwHCb9FWrVvHZz36WCy+88Kj7XH311Uf8702bNvHZz36WdevWHXd8W7du5Vvf+haVSoVbb72Vb3/72/T395/w61y4cCEHDx484ftJkiRJktTODNAlSZIkSRpDI+weyzve8Q4+9rGP8f73v59bb72V3//93x/3tjfccAPPP/88l156Kdu3bx+5/Morr+Tzn/88//k//2eS5MgGcZ/61KfYsmULpVKJ1atXc9ZZZx11m/EsWrRoJID/+Z//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RJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5
"text/html": [
"\n",
" <div style=\"display: inline-block;\">\n",
" <div class=\"jupyter-widgets widget-label\" style=\"text-align: center;\">\n",
" Figure\n",
" </div>\n",
" <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAPoCAYAAACGXmWqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAEl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S2XXHIJAO95z3tYvnw5H//4x/nqV7/K29/+9nHH94Mf/OCoy04//XR+53d+h9tuu40Xv/jF4z4PwAc/+EFuvPFGXv/61/OGN7yBbdu20d3dPe7zSZIkSZI011iBLkmSJEnSBF1++eVs3ryZz33uc0dc/tnPfpZrr72WZcuWjXvfz33uc7zlLW/h9a9/PYsXLz7qMY7lVa96FQCPPfbYCY+5EdLv379/ws/1h3/4hzzxxBN85jOfOeHnkyRJkiSpnRmgS5IkSZJ0At7+9rfzhS98gRgjALt37+aGG27gHe94x7j3+fGPf8z27dt5+9vfTkdHB29605uO28a92SOPPALA8uXLj3vbLMvYvXs3zzzzDDfccAMf+tCH6O3t5dJLL53w873rXe8C4IYbbpjwfSRJkiRJmgsM0CVJkiRJOgHveMc7ePLJJ7nlllsA+NKXvkRXVxdveMMbxr3PZz7zGTZs2MBLX/pSAH7xF3+R+++/n7vuumvM2x84cIDdu3fz1FNP8cUvfpGPfvSjdHd38/rXv/6447vjjjtYuXIl69at45prriHGyNe+9rVjVsePtn79ehYvXjwS3EuSJEmSNF94BrokSZIkSSfgBS94Aeeffz6f//znednLXsbnPvc5fv7nf56enp4xb59lGV/84hf5lV/5FUIIwHCb9FWrVvHZz36WCy+88Kj7XH311Uf8702bNvHZz36WdevWHXd8W7du5Vvf+haVSoVbb72Vb3/72/T395/w61y4cCEHDx484ftJkiRJktTODNAlSZIkSRpDI+weyzve8Q4+9rGP8f73v59bb72V3//93x/3tjfccAPPP/88l156Kdu3bx+5/Morr+Tzn/88//k//2eS5MgGcZ/61KfYsmULpVKJ1atXc9ZZZx11m/EsWrRoJID/+Z//+ZGA/8477+SCCy6Y0GMA9Pf3s2rVqgnfXpIkSZKkucAAXZIkSZI073R1dQEwODg45vUDAwMjtxnL29/+dj74wQ/ya7/2ayxfvpzXvOY14962cdb5W9/61jGv/973vseVV155xGWXXnopl1xyyTFfw0S96U1v4l3vehdf+MIXJhygP/XUUxw4cIAzzjhjSsYgSZIkSVK7MECXJEmSJM07mz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SJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkmSJEmSJEmSJEkSYIAuSZIkSZIkSZIkSRJggC5JkiRJkiRJkiRJEmCALkm
" </div>\n",
" "
],
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from mpl_toolkits import mplot3d\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"\n",
"%matplotlib inline\n",
"%matplotlib widget\n",
"\n",
"x, y, z, u = embed[:,0], embed[:,1], embed[:,2], embed[:,3] \n",
"\n",
"fig, ax = plt.subplots(1, 1, figsize=(20, 10))\n",
"# ax.scatter3D(x, y, z, c=np.array([param_corr[:, 0] / 180, [0] * param_corr.shape[0], param_corr[:, 1] / 360]).swapaxes(0, 1))\n",
"ax = fig.add_subplot(1, 2, 1, projection='3d')\n",
"ax.scatter3D(x, y, z, c=param_corr[:, 0], cmap=\"hsv\")\n",
"ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U2\", xticks=[], yticks=[], zticks=[])\n",
"ax = fig.add_subplot(1, 2, 2, projection='3d')\n",
"ax.scatter3D(x, y, z, c=param_corr[:, 1], cmap=\"hsv\")\n",
"ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U2\", xticks=[], yticks=[], zticks=[])\n",
"# ax = fig.add_subplot(2, 2, 3, projection='3d')\n",
"# ax.scatter3D(x, y, u, c=param_corr[:, 0], cmap=\"hsv\")\n",
"# ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U3\", xticks=[], yticks=[], zticks=[])\n",
"# ax = fig.add_subplot(2, 2, 4, projection='3d')\n",
"# ax.scatter3D(x, y, u, c=param_corr[:, 1], cmap=\"hsv\")\n",
"# ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U3\", xticks=[], yticks=[], zticks=[])\n",
"fig.suptitle('UMAP 3D')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "65996d51cb674a8b957ab31e54312416",
"version_major": 2,
"version_minor": 0
},
"image/png": "iVBORw0KGgoAAAANSUhEUgAABaAAAALQCAYAAABmJdeHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd5xcV33//9e5d2a2qxdLsmy5yL1hbGObZmya6TUU0xMgAcKXloQACeUXEiCBJPQSmoHQ4mC6CR3TbNy7XGSrWVZvO7s75d7z+2N2VVfSrrSz9fV8PPSwd/funTuj1ew573vO5xNijEiSJEmSJEmSNNKSsb4ASZIkSZIkSdLkZAAtSZIkSZIkSWoKA2hJkiRJkiRJUlMYQEuSJEmSJEmSmsIAWpIkSZIkSZLUFAbQkiRJkiRJkqSmMICWJEmSJEmSJDWFAbQkSZIkSZIkqSkMoCVJkiRJkiRJTWEALUmSJEmSJElqCgNoSZ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ia1PM+pVCoUCoWdYzBJkqYCA2hJmkLq9Tr1ep2+vr6dnwshUCwW95gMGUhLkiSNjBjjHmOwgXFWkiT7jMEkSZqMDKAlaQrYfeITQiBNU2KMhBCIMVKtVqlUKsCuyVCxWCRNU0IIBtKSJEmHYGCclec5wM6xVYxx5660vcdgBtKSpMnGAFqSJrk8z6nVauR5PmiYPBBID9g9kA4hkCQJhULBQFqSJGkYBm7+D9z0393e46nBAuk0TXeOvwqFguMvSdKEZQAtSZNUjJEsy6jVagBDXkWzeyAdYwSgWq1SrVZ3nmf3QNrVOZIkSbvsvfNsYKw0MK4azGCBdJ7ne5RNGwikB1ZIG0hLkiYKA2hJmoRijNRqNbIsO6wVywP
"text/html": [
"\n",
" <div style=\"display: inline-block;\">\n",
" <div class=\"jupyter-widgets widget-label\" style=\"text-align: center;\">\n",
" Figure\n",
" </div>\n",
" <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABaAAAALQCAYAAABmJdeHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd5xcV33//9e5d2a2qxdLsmy5yL1hbGObZmya6TUU0xMgAcKXloQACeUXEiCBJPQSmoHQ4mC6CR3TbNy7XGSrWVZvO7s75d7z+2N2VVfSrrSz9fV8PPSwd/funTuj1ew573vO5xNijEiSJEmSJEmSNNKSsb4ASZIkSZIkSdLkZAAtSZIkSZIkSWoKA2hJkiRJkiRJUlMYQEuSJEmSJEmSmsIAWpIkSZIkSZLUFAbQkiRJkiRJkqSmMICWJEmSJEmSJDWFAbQkSZIkSZIkqSkMoCVJkiRJkiRJTWEALUmSJEmSJElqCgNoSZIkSZIkSVJTGEBLkiRJkiRJkprCAFqSJEmSJEmS1BQG0JIkSZIkSZKkpjCAliRJ0oQXQoghhOP3+tx7Qghf7f//i/qP+c5ex5zZ//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iBNU2KMhBCIMVKtVqlUKsCuyVCxWCRNU0IIBtKSJEmHYGCclec5wM6xVYxx5660vcdgBtKSpMnGAFqSJrk8z6nVauR5PmiYPBBID9g9kA4hkCQJhULBQFqSJGkYBm7+D9z0393e46nBAuk0TXeOvwqFguMvSdKEZQAtSZNUjJEsy6jVagBDXkWzeyAdYwSgWq1SrVZ3nmf3QNrVOZIkSbvsvfNsYKw0MK4azGCBdJ7ne5RNGwi
" </div>\n",
" "
],
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(1, 1, figsize=(20, 10))\n",
"# ax.scatter3D(x, y, z, c=np.array([param_corr[:, 0] / 180, [0] * param_corr.shape[0], param_corr[:, 1] / 360]).swapaxes(0, 1))\n",
"ax = fig.add_subplot(1, 2, 1, projection='3d')\n",
"ax.scatter3D(x, y, u, c=param_corr[:, 0], cmap=\"hsv\")\n",
"ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U3\", xticks=[], yticks=[], zticks=[])\n",
"ax = fig.add_subplot(1, 2, 2, projection='3d')\n",
"ax.scatter3D(x, y, u, c=param_corr[:, 1], cmap=\"hsv\")\n",
"ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U3\", xticks=[], yticks=[], zticks=[])\n",
"\n",
"fig.suptitle('UMAP 3D')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Decoding"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import decoding"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQwAAAEGCAYAAACQF6v1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG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DTfcQK9evQJdUlCxwDDGJdwHv/EFCwxjXN555x0Li0pYG4YxLqNHj2bRokWMHj3awqIcdoZhIpqqcvfdd7Np0yZEhDFjxlhYVMACw0SsojaLe+65h1dffTXQ5YQECwwTkUo3cN51112BLikkWGCYiGN3Q6rPb4EhIk+LyB4R+bqc7UNF5ICIrHV93emvWoxxl5uby/r16y0sqsGfd0nmA7OB5yrY53NVHe3HGow5TlXJycmhfv36LF68mNjYWAuLKvLbGYaqfgbs99fxjamKosuQ4cOHk5OTQ1xcnIVFNQS6DWOwiKwTkfdEpHt5O4nIZBHJEJGMvXv31mZ9Jgy4t1kMHDiQuDgbvay6AhkYa4AOqtoL+DfwZnk7quqTqtpfVfu3aNGituozYcAaOH0rYIGhqgdVNdv1ejEQIyLNA1WPCU/33nuvhYUPBaxruIi0BnarqorIAJzwygpUPcYl/5jzZ526ga3DRyZNmgTA9OnTLSx8wJ+3VV8ClgOniEimiFwtIteJyHWuXSYCX4vIOuBfwKUaaqP5hJsVj8P9J8A/WsN/0wJdTbWpKq+//jqqysknn8ydd95pYeEjNuKWcRzYCWk9QN1GxL5hzfH5OEKFqpKamkpaWho
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Decoding... done\n"
]
}
],
"source": [
"# param = decoding.cohomological_parameterization(pd.DataFrame(firing_rates_in_trials_pca.reshape((400*50, -1))[::41]))\n",
"param = decoding.cohomological_parameterization(pd.DataFrame(embed))\n"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(788,)"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"param_corr[:, 0].shape"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f26ce0f09a0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAa4AAAGdCAYAAABKG5eZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAqrUlEQVR4nO3dfXTU5Z338c/MJJkgJhMVyINEHiwPihCUSjaoVUrWkHoQbIuYQxdQxN4c2KMnxUV6KmDZe9PW1tMHOOjuEaLHRcD7VthTWboQBUoBKYScittlgQ0EFhKEbWZIkDzM/O4/ejM6JRMy5ppkruH9Oud3DjNz/b75zsVMPvObzPwul+M4jgAAsIS7txsAACAWBBcAwCoEFwDAKgQXAMAqBBcAwCoEFwDAKgQXAMAqBBcAwCopvd2ACaFQSGfOnFFGRoZcLldvtwMAiJHjOLp48aLy8vLkdnd+TJUUwXXmzBnl5+f3dhsAgG46deqUBg4c2OmYpAiujIwMSdKYb70oT2p6t2r5v2Kioz/zjLxopM7tt1wwUkeSHu7/iZE6n4XSjNSRpKag10idkGPune8UV9BYrUQTkrl3Jdodj5E6l0OpRupIUsgxc/9M3TfJXE+JyNRzpbW5Ta+X/jr8+7zTn2nkJ/ayK28PelLT5UnrXnC5u7d7BM8NrUbqpPY1FxJ9bjTzX+6EzD102oNmfmkFDQZXqit5//xrMrjaDP1ydxIwuNwEV5eYfq505c89yfvsBAAkJYILAGCVuAXXqlWrNHjwYKWnp6uwsFD79+/vdPw777yjkSNHKj09XaNHj9aWLVvi1RoAwGJxCa4NGzaovLxcy5YtU3V1tQoKClRSUqJz5851OH7Pnj0qKyvT3LlzdejQIU2bNk3Tpk3T4cOH49EeAMBicQmuV155RfPmzdOTTz6pO++8U6+++qpuuOEGrVmzpsPxv/jFLzR58mQ9//zzuuOOO7RixQrdc889WrlyZTzaAwBYzHhwtba26uDBgyouLv78h7jdKi4u1t69ezvcZ+/evRHjJamkpCTq+JaWFgU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CAYAoBMEFwDAKgQXAMAqBBcAwCoEFwDAKsaDa/ny5XK5XBHbyJEjO93nnXfe0ciRI5Wenq7Ro0dry5YtptsCACSJuBxxjRo1SmfPng1vu3fvjjp2z549Kisr09y5c3Xo0CFNmzZN06ZN0+HDh+PRGgDAcnEJrpSUFOXk5IS3fv36RR37i1/8QpMnT9bzzz+vO+64QytWrNA999yjlStXxqM1AIDl4hJcR48eVV5enoYOHaqZM2eqrq4u6ti9e/equLg44rqSkhLt3bs36j4tLS0KBAIRGwDg+mA8uAoLC1VZWamtW7dq9erVqq2t1QMPPKCLFy92OL6+vl7Z2dkR12VnZ6u+vj7qz6ioqJDP5wtv+fn5Ru8DACBxGQ+u0tJSTZ8+XWPGjFFJSYm2bNmixsZGbdy40djPWLJkifx+f3g7deqUsdoAgMQW93MVZmVlafjw4Tp27FiHt+fk5KihoSHiuoaGBuXk5ESt6fV65fV6jfYJALBD3L/H1dTUpOPHjys3N7fD24uKilRVVRVx3bZt21RUVBTv1gAAFjIeXIsWLdLOnTt14sQJ7dmzR4899pg8Ho/KysokSbNmzdKSJUvC45999llt3bpVP/vZz/Qf//EfWr58uQ4cOKCFCxeabg0AkASMv1V4+vRplZWV6cKFC+rfv7/uv/9+7du3T/3795ck1dXVye3+PC8nTJigdevW6Qc/+IG+//3va9iwYdq0aZPuuusu060BAJKAy3Eccwvh9JJAICCfz6cnqmYq7ca0btUyuR4Xuob1uLqG9bi6WCsB1+Mydf9M3TeT3K6
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# plt.scatter(param_corr[:, 0], param_corr[:, 1], c=param.to_numpy())\n",
"plt.imshow(param.to_numpy().reshape((20, 20)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.collections.PathCollection at 0x7f26cbff4d30>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiQAAAGdCAYAAAAi3mhQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABIrklEQVR4nO3de3xU1bk//s9MIAkBEggxmYCBBKpiGggXIUYF+9UgqD+U2tNSvECpxUKh5Rh7DsYjRNQSrEdre6RQOdKLVKH266UojT+MUqQE0cSoMYCC4SLkAsRcSEgCmf39Yzohs5OZWXvPXjN7Zn/er1deLzN5Zmdn2M48e61nPcumKIoCIiIiohCyh/oEiIiIiJiQEBERUcgxISEiIqKQY0JCREREIceEhIiIiEKOCQkRERGFHBMSIiIiCjkmJERERBRy/UJ9AiKcTidOnjyJwYMHw2azhfp0iIiISICiKGhpacHw4cNht/seAwmLhOTkyZNIS0sL9WkQERGRDsePH8ell17qM0ZzQrJr1y48+eSTKCsrQ01NDV599VXMmTPH53N27tyJ/Px8fPbZZ0hLS8PDDz+MH/zgB8K/c/DgwQBcf1B8fLzWUyYiIqIQaG5uRlpaWvfnuC+aE5LW1lZkZ2fjhz/8Ie644w6/8dXV1bj11luxePFi/PnPf0ZJSQl+9KMfITU1FTNnzhT6ne5pmvj4eCYkREREYUak3EJzQnLzzTfj5ptvFo7fsGEDMjIy8NRTTwEArrzySuzevRu/+tWvhBMSIiIiimzSV9mUlpYiLy/P47GZM2eitLTU63M6OjrQ3Nzs8UVERESRS3pCUltbi5SUFI/HUlJS0NzcjHPnzvX5nKKiIiQkJHR/saCViIgospmyD0lBQQGampq6v44fPx7qUyIiIiKJpC/7dTgcqKur83isrq4O8fHxGDBgQJ/PiYmJQUxMjOxTIyIiIpOQPkKSm5uLkpISj8d27NiB3Nxc2b+aiIiIwoTmhOTs2bOoqKhARUUFANey3oqKChw7dgyAa7pl/vz53fGLFy/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RgBXsqK3D0nnBSd2VNX7jNlRVY/OC05E9wveRIqlpmymZiRiSFx/nzFD4voHPExVXFmD6554B/M27sXyLRWYt3EvrnvinYjcLpqIyIw6Lzix8b3eyUhPG9+rDmj6RlYvD9mj+b//p+/XRWucUSyVkIgIdAzDjM1miIis5oXSI0LdTl8oPaLr+DIXScgezd9RVWdonFEslZDsq25AY9t5nzFft53XXdTKVTxEROZwtEGsi6lonJrMRRLuolNvN8g2BFZ0qihio0KicUaxVEIiexiMq3iIiMxhVGKcoXFqMj9PZLe9H5sSb2icUXQlJOvWrUN6ejpiY2ORk5ODffv2+Yx/5plncMUVV2DAgAFIS0vD/fffj/b24K9kkT0MxlU8RETmcE9uut8peNu/4vSQ/XnibnufEh/j8XhKfEzADTwnC67OEY0ziuaEZOvWrcjPz0dhYSHKy8uRnZ2NmTNnor6+74rdF198EQ8++CAKCwuxf/9+PP/889i6dSseeuihgE9eK9lFrWZtNkNEZDVRdhvioqN8xsTFROkeZZA9reJ5JF/fa5cSL/YZJBpnFM0JydNPP41FixZh4cKFyMzMxIYNGxAXF4dNmzb1Gb9nzx5ce+21uPPOO5Geno6bbroJ8+bN8zuqIsu5Tt+tdv393JfJo4bC37Vtt7niiIhInn3VDWj1837e2tGlewq957SKN4FMq7gXSNQ2e46o1zUHvkDC6W9NscY4o2hKSDo7O1FWVoa8vLyLB7DbkZeXh9LS0j6fc80116CsrKw7Afnyyy+xfft23HLLLV5/T0dHB5qbmz2+jLDn0Gl0+Fni1XH
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.scatter(param_corr[:, 0], param)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python3.10/site-packages/seaborn/distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).\n",
" warnings.warn(msg, FutureWarning)\n"
]
},
{
"data": {
"text/plain": [
"<AxesSubplot:ylabel='Density'>"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkQAAAGdCAYAAADzOWwgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABJKklEQVR4nO3de1xUdf4/8NdcmBluMwjCAAFK3im1NMPZbmvxFY22i7qb5aaV2epi39Svaf62r7XWZlvfMruotZXYt+zifs1KSyO8VeKNQk0TbyQmDKDIDNcBZj6/P4Y5OooXEDgzc17Px2MewjmfOfP+qDO8+JzP5xyVEEKAiIiISMHUchdAREREJDcGIiIiIlI8BiIiIiJSPAYiIiIiUjwGIiIiIlI8BiIiIiJSPAYiIiIiUjwGIiIiIlI8rdwF+AOXy4Xi4mKEh4dDpVLJXQ4RERFdAiEEqqqqEB8fD7X6wmNADESXoLi4GImJiXKXQURERG1w7NgxJCQkXLANA9ElCA8PB+D+CzUajTJXQ0RERJfCbrcjMTFR+jl+IQxEl8BzmsxoNDIQERER+ZlLme7CSdVERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHhauQsgIpLb8m1FF9x/f2pSJ1VCRHLhCBEREREpHgMRERERKR4DERERESkeAxEREREpnqyBqHv37lCpVOc8MjMzAQD19fXIzMxEVFQUwsLCMHr0aJSWlnodo6ioCBkZGQgJCUFMTAyeeOIJNDU1ebXZuHEjBg0aBL1ej549eyIrK6uzukhERER+QNZAtGPHDpSUlEiP7OxsAMAf//hHAMD06dPx5ZdfYsWKFdi0aROKi4sxatQo6flOpxMZGRloaGjAli1bsGzZMmRlZWHu3LlSm8LCQmRkZG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b2pqQkVFhVeblo5x5mucSa/Xw2g0ej2IiIgocMkaiG644QYUFBR4bTtw4AC6desGAEhOTkZsbCxycnKk/Xa7Hdu2bYPFYgEAWCwWVFZWIi8vT2qzfv16uFwupKamSm02b96MxsZGqU12djb69OnjtaKNiIiIlEnWQDR9+nRs3boVzz//PA4dOoTly5fj7bffRmZmJgBApVJh2rRpeO655/DFF19gz549GD9+POLj43H33XcDcI8ojRgxApMmTcL27dvxww8/YOrUqRg7dizi4+MBAPfffz90Oh0mTpyIvXv34pNPPsHChQsxY8YMubpOREREPkQr54sPGTIEn332GebMmYN58+YhOTkZr776KsaNGye1mTVrFmpqavDoo4+isrISN954I9auXQuDwSC1+fDDDzF16lTcdtttUKvVGD16NF577TVpv8lkwjfffIPMzEwMHjwYXbt2xdy5c72uVURERETKJet1iPwFr0NEFNh4HSKiwOQ31yEiIiIi8gUMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4DERERESkeAxEREREpHgMRERERKR4sgaiZ555BiqVyuvRt29faX99fT0yMzMRFRWFsLA
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.distplot(param.clip(0.885, 0.888))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f26a77e8d60>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plt.imshow(gauss(np.random.uniform(size=(20, 20))))"
]
}
],
"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
}