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.

805 lines
390 KiB

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analyzing experimental data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Some imports*"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import scipy\n",
"import typing\n",
"from matplotlib import pyplot as plt\n",
"import pandas as pd\n",
"%matplotlib inline\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Spiketimes_Ntsr1Cre_2020_0003_s02_e05.npy Stiminfo_PVCre_2021_0012_s06_e14.csv\n",
"Spiketimes_Ntsr1Cre_2020_0003_s02_e10.npy res.pkl\n",
"Spiketimes_PVCre_2021_0012_s06_e14.npy\t simple_cell_center_fp\n",
"Stiminfo_Ntsr1Cre_2020_0003_s02_e05.npy simple_cell_random_fp\n",
"Stiminfo_Ntsr1Cre_2020_0003_s02_e10.npy\n"
]
}
],
"source": [
"!ls data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### *Load squares data*"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"\n",
"squares_stim = np.load(open('data/Stiminfo_Ntsr1Cre_2020_0003_s02_e10.npy', 'rb'), allow_pickle=True).item()\n",
"squares_spikes = np.load(open('data/Spiketimes_Ntsr1Cre_2020_0003_s02_e10.npy', 'rb'), allow_pickle=True).item()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"('AsparseNoise5_60deg',\n",
" dict_keys(['ename', 'area', 'probename', 'electrode_spacing', 'monitor_offset', 'stimtimes', 'stimvals', 'opto', 'optotimes', 'ivs', 'run_spdthr', 'run_minon', 'runperiods']))"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_stim['ename'], squares_stim.keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['grat_x_position', 'grat_y_position', 'grat_contrast'])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_stim['ivs'].keys()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"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": 10,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAD4CAYAAAD7CAEUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAm00lEQVR4nO3de3hc9X3n8fd3RhdbtmVdbWzLsoxtLgYb8C0k4DRAk0BDcC8kQEkhaQLZbcimzXb3Ie2GTbJp+2SfbLLJJu2WhKZJtgkQCokDTsgFkoAB3w2+YSzfLYQtyZJlW5YlzXz3j3Mky0KWZoxGZ2b0eT3PPJo5c86Z75kZzWfO73fOb8zdERERSVUs6gJERCS3KDhERCQtCg4REUmLgkNERNKi4BARkbQURF3AaKiqqvK6urqoyxARySkbNmxodvfqgdPHRHDU1dWxfv36qMsQEckpZrZ/sOlqqhI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u2N7azde5SntjTy3K4m3nvZBVw5syylsB2LUt3j+EfgI8DXzexHwHfcfWfmypKR0JNM8vOtb/DC7hbKSwq5belMFsyYrN1xkX7GFcZZVFvOotpy9jaf5OdbG/nRhkO8cugYH1hcQ0mxGmYGSumriLv/yt3vBBYB+4BfmdkLZvYRMxv6a6tEouN0D99ZvY8Xdrfw9jmVfOqGi7iipkyhITKE2VUT+PjvzeF9C6ZR33SCf/ztbo60d0ZdVtZJeR/WzCqBDwMfAzYBXyMIkl9mpDI5bx1dPTy0ei8Hj3bwwSUzef/C6RQVqM1WJBUxM66ZW8U9yy+kqyfJt57bw2G
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.distplot(squares_stim['ivs']['grat_x_position'])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(25.4911, 80.5089)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_stim['ivs']['grat_x_position'].min(), squares_stim['ivs']['grat_x_position'].max()"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(-27.5089, 27.5089)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"squares_stim['ivs']['grat_y_position'].min(), squares_stim['ivs']['grat_y_position'].max()"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 4, 8, 11, 14, 17, 20, 26, 29, 33, 34, 35, 36, 37,\n",
" 41, 44, 45, 46, 48, 51, 58, 59, 67, 72, 77, 82, 87,\n",
" 93, 96, 101, 104, 112, 116, 120, 128, 129, 140, 141, 142, 144,\n",
" 145])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_spikes['units']"
]
},
{
"cell_type": "code",
"execution_count": 14,
"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": 14,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZQAAAD4CAYAAADLhBA1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAzhUlEQVR4nO3dd3wd1Znw8d+j3iWry5JsSZZcZIMxNi50MMVUhwDBTiBAKMkSkt3wfjYLSZbN8oZ9Q7awyS4ECCWEAMahxQGDQ8eAu3GvsmRbsnovVr067x93HIRQuZLvvXPL8/189PHcM2fOfWasex/NnDNnxBiDUkopdbJC7A5AKaVUYNCEopRSyi00oSillHILTShKKaXcQhOKUkoptwizOwA7paammry8PLvDUEopv7Jly5Z6Y0za4PKgTih5eXls3rzZ7jCUUsqviMiRocr1kpdSSim30ISilFLKLTShKKWUcgtNKEoppdxCE4pSSim30ISilFLKLTShKKWUcgtNKEoppdxCE4pSSim3COo75ZUKNi9sOOr2Nr+5YJLb21T+Sc9QlFJKuYUmFKWUUm6hCUUppZRbaEJRSinlFppQlFJKuYUmFKWUUm6hCUUppZRbaEJRSinlFnpjo1InSW8WVMpJz1CUUkq5hZ6hKOWHeh39lDcep6qli7auPjq6++h19BMXFUZWYjRFGXEkRIXbHaYKMppQlPJxLcd72XGsmR0VLeyoaGZfdRsVTZ04+s2w24QInJabxBWnTuQb83KI1+SivEATilI+pr27jzd2VPJpSQPrSxsoq+/427q8lBhmTUzkqlMnkp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
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.distplot(squares_spikes['spiketimes'][0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### *Load gratings data*"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"gratings_stim = np.load(open('data/Stiminfo_Ntsr1Cre_2020_0003_s02_e05.npy', 'rb'), allow_pickle=True).item()\n",
"gratings_spikes = np.load(open('data/Spiketimes_Ntsr1Cre_2020_0003_s02_e05.npy', 'rb'), allow_pickle=True).item()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['ename', 'area', 'probename', 'electrode_spacing', 'monitor_offset', 'stimtimes', 'stimvals', 'optotimes', 'opto', 'optofreq', 'ivs', 'run_spdthr', 'run_minon', 'runperiods'])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gratings_stim.keys()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'oriTun12_opto'"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gratings_stim['ename']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['grat_height', 'opto', 'optofreq'])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gratings_stim['ivs'].keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 9.55191999, -3.82510311, 1.18950616, 1. , 3.35761066,\n",
" 4.65747346, 0.05402836])"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gratings_spikes['RFpars'][0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pre-processing squares data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Turn squares data into a better format*\n",
"\n",
"`{'squares': (x, y, c), 'firing_rates': [fr1, fr2, ...]}`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([1.512 , 1.7124]),\n",
" array([1155.5455, 1155.7459]),\n",
" 54.692066,\n",
" 1152.682366)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_stim['stimtimes'][0], squares_stim['stimtimes'][-1], squares_spikes['spiketimes'][0][0], squares_spikes['spiketimes'][0][-1]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"get_firing_rates = lambda i: ((squares_stim['stimtimes'][:, 0].reshape((-1, 1)) <= squares_spikes['spiketimes'][i]) * (squares_spikes['spiketimes'][i] < squares_stim['stimtimes'][:, 1].reshape((-1, 1)))).sum(axis=1) / (squares_stim['stimtimes'][:, 1] - squares_stim['stimtimes'][:, 0])"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(40, 5760)"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"N_UNITS = squares_spikes['spiketimes'].shape[0]\n",
"N_EXPS = squares_stim['stimtimes'].shape[0]\n",
"N_UNITS, N_EXPS"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"firing_rates = np.array([get_firing_rates(i) for i in range(N_UNITS)])"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"stim_data = np.array([((squares_stim['ivs']['grat_x_position'][i] - 25) * 100 / 60, 100 * (squares_stim['ivs']['grat_y_position'][i] / 55) + 50, round(squares_stim['ivs']['grat_contrast'][i])) for i in range(len(squares_stim['ivs']['grat_x_position']))])"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((40, 5760), (5760, 3))"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"squares_data = {'squares': stim_data, 'firing_rates': firing_rates}\n",
"firing_rates.shape, stim_data.shape"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"fields_plus = [np.zeros((100, 100)) for i in range(N_UNITS)]\n",
"fields_minus = [np.zeros((100, 100)) for i in range(N_UNITS)]\n",
"r_coord = lambda x: min(max(round(x), 0), 99)\n",
"\n",
"for i in range(N_EXPS):\n",
" for j in range(N_UNITS):\n",
" if squares_data['squares'][i, 2] >= 0:\n",
" fields_plus[j][r_coord(squares_data['squares'][i, 0]), r_coord(squares_data['squares'][i, 1])] += squares_data['firing_rates'][j, i]\n",
" else:\n",
" fields_minus[j][r_coord(squares_data['squares'][i, 0]), r_coord(squares_data['squares'][i, 1])] += squares_data['firing_rates'][j, i]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(N_UNITS):\n",
" fields_plus[i] = scipy.ndimage.gaussian_filter(fields_plus[i], sigma=6)\n",
" fields_minus[i] = scipy.ndimage.gaussian_filter(fields_minus[i], sigma=6)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAESCAYAAADkJY5uAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9eZRt2XbWB/7mWnufcyLiNtnn6/LpSegJIQmDkJCQLRtcAgrLZoiqMkJA2bgBFZRxA+6EoWzKw9i4HXiUB2WEDciFMc0wAlwIhIzpRONCNAJJqOc9vS7fy8ybt4uIc87ea836Y8619t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Pkx5KwD+CeCV5u8P+GszUdVvBb4V4Hb/on7NM/8nn3T+VPPFEawDnPM0+USQvoOuQ5ZLWC7QZY8uOnTRkfuAFmBXRbIiY0aGjKSEjH6s3fOpg2XKkBKMCR1HGEdICU15uo6cIQS7lhghRrueLsKi583tq/zo3b/OG2cf+ehVx+TkxVf0S77+N9FtlP400Z0lwjoRtiMyJAN01XqdpDxdbzleDHZdXUS7YD/RftoJLSnXzYHy9ShokOk7nZCjoP66LWRBowGDBqYFWMRBQSOkhTCuYDwWxiNIR8rZJz7CJ3/3/2v7qLnSjskteU6/Wr7uwrz4XJK7+gbfw1945JjAfFyO3vOKfvgbfzPdqbJ8kOkfJLrTkTBmyOrPXOyZOuhImpQBFdAukDux9dIJuRdy9GfsgJo7IS0grYTxGMZjZTxW0nGGZSYsEiEa6IooqoJmIedAHgK6DcgmEM8DYQNxLcQBJJVrgLSw46abGW4MHN3YIB/5MX74t/1RrjMmtxcv6z/68jddBFnVaf3
"text/plain": [
"<Figure size 432x288 with 15 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(3, 5)\n",
"ax = ax.flatten()\n",
"# set title\n",
"fig.suptitle('Receptive fields - positive')\n",
"for i in range(len(ax)):\n",
" ax[i].imshow(fields_plus[i])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f394518b4f0>"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD7CAYAAACscuKmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAB0IUlEQVR4nO29Xax1TXIW9lTv9/08niFmxg4Mw4wVT2QLZCER0MgxchQ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+LXyBu7KGS/LGRsTChiv+AQAeMUv8K7yCq+oKoKXdIczz7fOPL6DLszVRWQZAm7OTr2x9C944YfrGDS23Ta7XGay1xPzVwFt46h55u/LwG8ZXT22bECvjYR9ZmfD7MFSOMLULt5efJP2YH1Qa1+CWXIL4SBTV18fVwfJ75J6TJTVch4PuHE0A/neWNF7TF/VZcgWLkwuCpIJxNz3kLRdhLwRuADbVjFx3iq7n0pddy/EODPhFZ/wik848YY3t7refuINJ2w4q1U1V/OP7qA7NxNFWF02FFR2F1anOuBZWL2DVpmdR1Yv5zqg6OxB3pUD72rqadkztnSMRy5s5YG37F7PWcMBDPNhTe8osx+Q3YFslYfeFMsYrA9hdmEoZ6HQUG9X7lagoR579dqx1GZLcBqWnce0FmMmtgc2KLPX37pNlkubwjfmR4EqCb6r22JABXd3lbXfOtc18xe04Y4L3ihnvFXaMtypPlNyBuHz/BLvolcoxHjjSTF7bCjrfQeU1f3y2/gX2ZzCcTy3QD+0nJJItg/EMn702I/r4NDOtewONoBxcUQBGNZnn56bs1tQzAAyYcGhfsl1V1ZTHy2HZXRpk2ChZMqr+xpCe0mhDlspvtK5424H9PHeA+P
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(np.array(fields_plus).mean(axis=0))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAESCAYAAADkJY5uAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9ebBt23LWB/5yjDHnWmvvfc6559z77muvnnrUGYQlIbCxwQEymJ6KMgXGGBOFVVQVJgyuAtmOwg7CDdg43JSjqiwcdIUxOEzjTiAJCkQnGwkkYUkINU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fq2qvutJdBJS/w2bG8/b9aIg4jcLUhQp2v5v/2p9E7vm+jvVQ32pLr6Y/1DrawWC/atiP6u6adfQLthfVj+nLD8HZHFNKqBRTL8JSgfp+TtML766A377k+gkEr/hhJuP+9MvCFlzyo6L19UJPGKtnD0/r4v6XIOgAUqUh/ZFyCDZ10bReZ0soVN/3hp8f4kcLK22b5bLoi7Tugx1/j+Cr4v55wJQfE3neV1rEDQJuRPSM3eYzu9xLZ3E/htOTt/lC3S+LoqtS8lX94HOfyQPvbO/x+vsCbF7LGlhO67c6/LtZhujUIQwQRghjK6Dq89S/DkE8X1kz3b78sdffpRNeSsG/BPAC4v/f8B/diCq+u3AtwO8+2vu6Af+8Ldy94ef5c6Pws2f3tG9cgHjBClSTlfk0468igCEsSCT3aAKEIUSA3kdGE8DeWWWpb8orF/ck168D6/dQ7c7KAVZr5DTU/TshHK2Im868joynUX2NyP7W0Jeu5LFjE1Z2Wd1D4STzyg3PzKw+uR95P4FhEB59iaXL5zx4AOR3bOCJkgXsH5ZGX/yQ3z8R76L1175iY88qU7O7rygX/+LfhdxV5CsdtBgDzjuJsJ+QiY
"text/plain": [
"<Figure size 432x288 with 15 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(3, 5)\n",
"ax = ax.flatten()\n",
"# set title\n",
"fig.suptitle('Receptive fields - negative')\n",
"for i in range(len(ax)):\n",
" ax[i].imshow(fields_minus[i])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Finding centers of the receptive fields"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from scipy import signal\n",
"\n",
"def gkern(kernlen=100, std=5, x=0, y=0):\n",
" \"\"\"Returns a 2D Gaussian kernel array.\"\"\"\n",
" if not x and not y:\n",
" gkern1d = signal.gaussian(kernlen, std=std).reshape(kernlen, 1)\n",
" gkern2d = np.outer(gkern1d, gkern1d)\n",
" return gkern2d\n",
" else:\n",
" return np.roll(gkern(kernlen, std, 0, 0), (x - 50, y - 50))\n",
"\n",
"\n",
"def find_center(field) -> typing.Tuple[typing.Tuple[int, int], float]:\n",
" \"\"\"\n",
" Find the center of the field and return it and the score\n",
" \"\"\"\n",
" center = np.unravel_index(np.argmax(scipy.ndimage.gaussian_filter(field, sigma=7)), field.shape)\n",
" score = np.sum(field * gkern(x=center[0], y=center[1])) / field.mean()\n",
" return center, score"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_4092185/2956312832.py:18: RuntimeWarning: invalid value encountered in double_scalars\n",
" score = np.sum(field * gkern(x=center[0], y=center[1])) / field.mean()\n"
]
}
],
"source": [
"centers_pos = [find_center(fields_plus[i]) for i in range(N_UNITS)]\n",
"centers_neg = [find_center(fields_minus[i]) for i in range(N_UNITS)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"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": [
"12"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAD4CAYAAAD7CAEUAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAnSElEQVR4nO3deXgc1Znv8e+rbqm1S7YkrzKWsM0iCGYRZg2TQABDCL4TYDAJgSHOkJmByZDMBskdbpI73IQkk0xmQhYSmACB2IQA8SQGB8IaFtsyGLzb8m55k7xIsrW33vtHl4g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7t5mFrvleHARoE7NHeE63Vm4YhevVtdRkhvhUzOO4+Tx+YTSYp+ThuZ2Fm/exyvraqmuXcenz5nMlBLd2kVkqOvv6bgvm9mXgSwzuxT4FfA/iQtLUl2nO79eup1Xq+s4p3w0t188lVMnFryXNADys9L52Mlj+cLF08jPTOfnr23m3e0Hkhe0iAyI/iaOO4FaYDnweWAB8L8TFZSkvmdX7OLtbQe45KQxXD19Aumhvj9KxXkRPn/RFCaNzuLxqm2s2904iJGKyEDr7yCHncDTwN+6+7Xu/lNdRT5yLd60jz9W13He8UVccvJYupowDycrI8RN55UxNj+TxxZtZc2uhkGIVEQS4bCJw2K+amZ1wFpgbXD3v7sHJzxJNbsbWvjtuzuYNiaXj582Pq5lM9ND3HxeGZFwGn/76FscbO1IUJQikkhHOuL4InABcLa7j3b30cA5wAVm9sWERycppSPaybwl24iE07j2rFLS+nGk0VN+VjrXnz2
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"sns.distplot([centers_pos[i][1] for i in range(N_UNITS)])\n",
"tuning_threshold = 200\n",
"sum(centers_pos[i][1] > tuning_threshold for i in range(N_UNITS))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tuned_units = [i for i in range(N_UNITS) if centers_pos[i][1] > tuning_threshold]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAWcAAAEVCAYAAAA8UiRHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9e7CtW3YXhv3GmPNba+3HOefe2/fRt9WtlsCgB46BBIRIqbBsHgEMJVcqKGCFgAvchcuqQEISCb9iEz9Eykmcip0qBObhYF4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MHfDNH8O/qbUMRC7N1D7nBABjDreVASUdaxI/BgfC0ACoQSCMLrnAb3GbSH9bD0W0OdW0M7N9hOAEgEMAuaC9U+/tbexBXR8V8evgJOApgzkrPODYPMwoESGRIKEdu2cbe6VbpxpPo5CW19GPobtnssAYCg4WkxYcgKToAhBQGASBBQUEC7zgPU0QCYGJRs7mw/16dr5dW5gNjeEdGwlAIiCYUiY3n6IzcP19lXe2tguaCVHfGrzjADiuq5s8c90wWwtopvbNwn1a9TPbefyv69bGyLz5UNbx9fDtnXall64Rh7nL++cu+9HOT+TENEnAHwCAFbhHv7Hr/9mSEo6uV0BAoD3DaXOmJcCyQWYJv1tx1CMoNUSdHQEOTmCrJaQZVBFSIBEhgymFAXgMYMvE3gzAVNqg+4DxgzEAAmmcFIBpgQaJ2CcICkDJQNTguSs119kds0UdIHSEIEYQcMArJaQoyXK0QAZAv7yf/evv9/29deO7eLkZfzjv+73YPGkIF5kcCpVKVAuqkChyrKOy5T1Xvvx8M2oAIisYxnZlAmhLBh5GVAGPUdYZ8T
"text/plain": [
"<Figure size 432x288 with 12 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(3, 4)\n",
"ax = ax.flatten()\n",
"fig.suptitle('Receptive fields for tuned units')\n",
"for i in range(min(len(tuned_units), len(ax))):\n",
" ax[i].imshow(fields_plus[tuned_units[i]])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.collections.PathCollection at 0x7f394577b0a0>"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAARw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wxJUhd1jtyvAd4XETcArwZ+FbgTGIuIVdXR+wZgOLeSk6QVbNlH7pm5IzM3ZOZG4GbgW5n5IeBh4P3VYluB+2tXKUnqySDGuX8C+GhEHKbTB3/3ALYhSTqDvtxbJjO/DXy7+vwUcFU/1ivpzEq+N4rq8cZhUkv5bFGdibcfkFqq9HujqB7DXWqp0u+NonoMd6mlSr83iuox3KWWKv3eKKrHE6pSS62kJyapd4a71GIl3xtF9dgtI0kFMtwlqUCGuyQVyHCXpAIZ7pJUIMNdkgpkuEtSgQx3SSqQ4S5JBTLcJalAhrskFchwl6QCGe6SVCDDXZIKZLhLUoEMd0kqkOEuSQUy3CWpQIa7JBXIcJekAhnuklQgw12SCmS4S1KBDHdJKtCywz0iLo6IhyPiiYh4PCJurdovjIiHIuLJ6v2C/pUrSTobdY7cXwI+lpmXAVcDH46Iy4DbgH2ZeSmwr5qWJJ1Dyw73zHw+Mx+pPv8PcAhYD9wI3FMtdg+wpWaNkqQe9aXPPSI2ApuA/cCazHy+mvUCsOY039kWEVMRMTU3N9ePMiRJldrhHhGvBb4GfCQzf7p4XmYmkN2+l5m7MnMyMyfHx8frliFJWqRWuEfEajrB/qXM3F01vxgRa6v5a4Gj9UqUJPWqzmiZAO4GDmXmpxfNegDYWn3eCty//PIkScuxqsZ3rwF
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"centers_pos_np = np.array([c for c, _ in centers_pos])\n",
"plt.scatter(centers_pos_np[:, 0], centers_pos_np[:, 1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Preprocessing grating data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.5 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
},
"vscode": {
"interpreter": {
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}