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.

618 lines
76 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Tuning Curves"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"**Import everything**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"%matplotlib inline\n",
2 years ago
"import typing\n",
"\n",
"import matplotlib as mpl\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import ipywidgets as widgets\n",
"import sympy as sp\n",
"sp.init_printing()\n",
"AxOrImg = typing.Union[mpl.axes.Axes, mpl.image.AxesImage]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"k, x0, y0, phi, theta, sigma_x, sigma_y, sigma, x, y = sp.symbols(r'k x_0 y_0 \\phi \\theta \\sigma_x \\sigma_y \\sigma x y')\n",
"defaults = {\n",
" k: 6,\n",
" sigma: 0.2,\n",
" phi: sp.pi / 2,\n",
" theta: 0,\n",
" sigma: 1,\n",
" x0: 0, y0: 0\n",
"}\n",
"sigma_x = sigma_y = sigma"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"#### Formulas"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZUAAAAVCAYAAACOnHNXAAAACXBIWXMAAA7EAAAOxAGVKw4bAAALeklEQVR4Ae2d65XUNhTHhz1bAIEKAh3wqCDQAYEK2HQAh0/wjUM6SKiAQAchFSTQAXTAZjsg/59G19F4JEu2JY8H9p4jZOtx9b8PXT08wObr16+btaXnz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RmTJ14PVB6MqZPzbYaOytzzfGW5CXZ/lXasafevyrt/V85lCl9WhLf1LHAqbQj1wxes+QWjqPxX2F9pfRhqq5q94vhUVmxz4JH7WfZr7ZMfX7Ct5ivhro4iS1xBypjR2OrcAoCK3fNnQ47idQOJYWhZnmJzDXHW5IXOyt2Lo60o+KZn5fHTirsItHFMVBNm82Ve5X+KxtzYuv/uIardXxicRqBZ4zPIsdc+7XWxZK+2uliNYuKDM8xke86HPFS1H1PSTUYU66x+Jkr4x6ECmU+CLa5g0o2fqbNX3gkwPCjBY7pHLt3SHXYG7sfzA47gDIvHmfOTzNc3LXmbLmFZa3+y48U3gRKONSPaQxCER7ps8hnYaq2s+1n4FrlwlgSU7PD52Tt159mOS7bgMDD/eH9xLDczX5rlJP5aOWVs7F7yRHfinIn1ByPpetr2OwY5Y7pOaYL7H5N9mczwbcUvs3WvGGI4RgqK8ZT6LOMdSz2i9lnSFexupysO/Wr+p8fkUZGZQfAz5in/oXEmFJWXfY9yoxBJDdBJ3Ul9s3a7Jjljhnle/PfY7PfHPvkZI3V/wfyW5BPgYgjWgAAAABJRU5ErkJggg==",
"text/latex": [
"$\\displaystyle \\cos{\\left(\\phi + k \\left(x - x_{0}\\right) \\cos{\\left(\\theta \\right)} + k \\left(y - y_{0}\\right) \\sin{\\left(\\theta \\right)} \\right)}$"
],
"text/plain": [
"cos(\\phi + k⋅(x - x₀)⋅cos(\\theta) + k⋅(y - y₀)⋅sin(\\theta))"
]
2 years ago
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"grating_f = sp.cos(k * (x - x0) * sp.cos(theta) + k * (y - y0) * sp.sin(theta) + phi)\n",
"receptive_field = 1 / (2 * sp.pi * sigma * sigma) * sp.exp(-(x ** 2 + y ** 2) / (2 * sigma ** 2)) * sp.cos(k * x * sp.cos(theta) + k * y * sp.sin(theta) + phi)\n",
"receptive_field = receptive_field.subs(theta, 0).subs(phi, 0)\n",
"grating_f"
]
},
{
"cell_type": "code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32WhqjnUUlASIv7OrOJ4ZxcKQUBlLzFWSz1+/pM9JkflPKGUdwNGqSPXKU3yepBJJEdhK8417aoGavo5gWUn/OgcfZgGEx/PNV6pVONBzU36t2nQfJ6dEEjiWgf+xrjuvKNali1Ll+CpYK5zkCMrHL6qDt/PYygMtFKxOq95+0s+T8okkVASKI41zXF96nirPfR+EigI1nSmx/FUsi9rxZwfkoWDukDstvkRtWwJVffowKSWSuFiaEC4KUofUmaYMZalbkLrTnOJgaeStPPgBvp2f5OGhjW6Jn/8BCy8ISGIS3qgAAAAASUVORK5CYII=",
"text/latex": [
"$\\displaystyle \\frac{e^{\\frac{- x^{2} - y^{2}}{2 \\sigma^{2}}} \\cos{\\left(k x \\right)}}{2 \\pi \\sigma^{2}}$"
],
"text/plain": [
" 2 2 \n",
" - x - y \n",
" ───────── \n",
" 2 \n",
" 2⋅\\sigma \n",
"ℯ ⋅cos(k⋅x)\n",
"───────────────────\n",
" 2 \n",
" 2⋅π⋅\\sigma "
]
2 years ago
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"receptive_field"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"int1 = sp.Integral(grating_f * receptive_field, (x, -1, 1), (y, -1, 1)).subs(defaults)\n",
"# int1.evalf(2).doit()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiYAAAAdCAYAAACe7KcBAAAACXBIWXMAAA7EAAAOxAGVKw4bAAASBElEQVR4Ae2d65UUtxLHhz0bAF4iuDgDDBEYMrBNBIszwIdvfOPYGdhEAHYG2BGAyQDfCFhPBtz/TyPpavqhR79nR3VOj7r1KNVLpZJavXvny5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WTI5MmK1CAb+9Z8ccmEFPxtv6IdxSDcz3a2lU+q3G3e0I5Tt85YN0eQPWco+N1Dat5HAh/xwWZEvAxUR/hPrQ8+mUAOYUdFagtkzSD4z9BAbsj4WClrRtAQbXDrerCIwOXNBf8rlqkAQ7J9f1B/bhgCUcQe3UFyl6eVQau0GGBCznT106pn2jsMzL6rHy3amMywq69w6SeA+Ujh83q3NLmX01At6WZwOQVzx2AvJL6FR6C5C5bQR/007W7h+yPZE5dC2ZH0d6zO9Kkj75MnnCU6gkZDBlPlhyTsGLugpSsYvaJ7Uytn5T+ouWS01o2PVS+6ASa0W8nWHtJLepoy6KkubAkP/QhPA+BMT6ut78V9dWkaWk79/q+tJTgIHImySbht/3ZrTJZafeBq7Pvq6B8nBXAJPpCF5MIA4ataP9uU8+lQADCHzFK9d07CG3bVKBQShf1sSn6BTdb52NXJ0JjJkcCmxC6JrywHDlzwNqA6GDSIDDp+4zc6XNzOhfNOGuguYuJDIC+VX7MwRxa6lf4uwIP8rFX5JUKoj0ublTf2KVSbAHaPX3KY0yQ5xY+pXpS08nHEzgHg3iaSz8p/aXKN2vTEWFjO/DVAskZflhE9/q1oBEBb5ddY3857QNUrdtZfJx62bS+ZrZzhHxzEYi6teIPys711hkuB/f6wNV
"text/latex": [
"$\\displaystyle e^{- 4 \\sigma^{2} k^{2}} \\cos{\\left(\\phi - k \\left(x_{0} \\cos{\\left(\\theta \\right)} + y_{0} \\sin{\\left(\\theta \\right)}\\right) \\right)} \\cosh{\\left(4 \\sigma^{2} k^{2} \\cos{\\left(\\theta \\right)} \\right)}$"
],
"text/plain": [
" 2 2 \n",
" -4⋅\\sigma ⋅k ⎛ 2 \n",
"ℯ ⋅cos(\\phi - k⋅(x₀⋅cos(\\theta) + y₀⋅sin(\\theta)))⋅cosh⎝4⋅\\sigma ⋅\n",
"\n",
" \n",
" 2 ⎞\n",
"k ⋅cos(\\theta)⎠"
]
2 years ago
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# p = sp.cos(phi) * sp.cos(k*x0*sp.cos(theta) + k*y0*sp.sin(theta)) * sp.exp(k**2 * (sigma_x **2 * (1 + sp.cos(theta))**2 + sigma_y**2 * sp.sin(theta) **2) / 2)\n",
"# p = sp.cosh(k**2 * sigma**2 * sp.cos(theta)) * sp.exp(k ** 2 * (1 + sp.cos(theta) ** 2) / 2) * sp.cos(phi - k * (x0 * sp.cos(theta) + y0 * sp.sin(theta)))\n",
"\n",
"p = sp.cosh(k ** 2 * sigma ** 2 * sp.cos(theta) * 4) * sp.exp(-4 * k ** 2 * sigma ** 2) * sp.cos(\n",
" phi - k * (x0 * sp.cos(theta) + y0 * sp.sin(theta)))\n",
2 years ago
"p"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"#### Plot stuff"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"def get_orientation_phase_grid(step_phase: float, step_orientation: float) -> np.ndarray:\n",
" \"\"\"\n",
" Returns a grid of x and y values for plotting.\n",
" :param step_phase: step for the phase (phi) - in degrees\n",
" :param step_orientation: step for the orientation (theta) - in degrees\n",
" :return: numpy array of shape (n_orientation, n_phase). Each element is a tuple (theta, phi)\n",
" \"\"\"\n",
" # phase <-> phi\n",
" # orientation <-> theta\n",
" step_phase *= np.pi / 180\n",
" step_orientation *= np.pi / 180\n",
" phi = np.arange(0, 2 * np.pi, step_phase)\n",
" theta = np.arange(0, np.pi, step_orientation)\n",
" return np.array(np.meshgrid(theta, phi)).T.reshape(-1, len(phi), 2)\n",
"\n",
"\n",
"def get_spatial_grid(step_x: float, step_y: float, size: float = 1) -> np.ndarray:\n",
" \"\"\"\n",
" Returns a grid of x and y values for plotting.\n",
" :param step_x: step for the x-coordinate\n",
" :param step_y: step for the y-coordinate\n",
" :param size: size of the grid\n",
" :return: numpy array of shape (2 * size / step_x, 2 * size / step_y). Each element is a tuple (x, y)\n",
" \"\"\"\n",
" x = np.arange(-size, size, step_x)\n",
" y = np.arange(-size, size, step_y)\n",
" return np.array(np.meshgrid(x, y)).T.reshape(-1, len(x), 2)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"def eval_func(func: sp.Expr, sub_1: sp.Expr, sub_2: sp.Expr, grid: np.ndarray) -> np.ndarray:\n",
" # return np.array([[float(func.subs(sub_1, x_).subs(sub_2, y_)) for x_, y_ in line] for line in grid])\n",
" func = sp.lambdify([sub_1, sub_2], func, 'numpy')\n",
" return func(grid[:, :, 0], grid[:, :, 1])\n",
"\n",
"def plot_spatial(func: sp.Expr, ax: AxOrImg, step_x: float = 0.05, step_y: float = 0.05, size: float = 1, title: str = None, show: bool = False,\n",
" patch: typing.Optional[typing.Tuple[float, float, float]] = None\n",
" ):\n",
" \"\"\"\n",
" Plots a spatial map of the function.\n",
"\n",
" :param func: function to plot\n",
" :param ax: axes to plot on or the image on axes\n",
" :param step_x: step for the x-coordinate\n",
" :param step_y: step for the y-coordinate\n",
" :param size: size of the grid\n",
" :param title: title of the plot\n",
" :param show: whether to show the plot\n",
" :param patch: optional circle to plot - a tuple (x, y, radius)\n",
" \"\"\"\n",
" grid = get_spatial_grid(step_x, step_y, size)\n",
" image: np.ndarray = eval_func(func, x, y, grid)\n",
" if isinstance(ax, mpl.image.AxesImage):\n",
" ax.set_data(image)\n",
" return ax\n",
" img = ax.imshow(image, extent=[-size, size, -size, size], vmin=-size, vmax=size, cmap='gray')\n",
" ax.invert_yaxis()\n",
" if patch is not None:\n",
" ax.add_patch(plt.Circle(patch[:2], radius=patch[2], color='b', fill=False))\n",
" ax.set_title(title)\n",
" if show:\n",
" plt.show()\n",
" return img\n",
"\n",
"def normalize(img):\n",
" return (img - img.min()) / (img.max() - img.min())\n",
"\n",
"def plot_tuning_curve(func: typing.Union[sp.Expr, typing.Callable], ax: AxOrImg, step_phase: float = 20, step_orientation: float = 15, title: str = None, show: bool = False):\n",
" \"\"\"\n",
" Plots a tuning curve of the function.\n",
"\n",
" :param func: function to plot - sympy or a function of (theta, phi)\n",
" :param ax: axes to plot on or image to update\n",
" :param step_phase: step for the phase (phi) - in degrees\n",
" :param step_orientation: step for the orientation (theta) - in degrees\n",
" :param title: title of the plot\n",
" :param show: whether to show the plot\n",
" \"\"\"\n",
" grid = get_orientation_phase_grid(step_phase, step_orientation)\n",
" if isinstance(func, sp.Expr):\n",
" image: np.ndarray = eval_func(func, theta, phi, grid)\n",
" else:\n",
" image = np.array([[func(theta_val, phi_val) for theta_val, phi_val in line] for line in grid])\n",
" image = normalize(image)\n",
" if isinstance(ax, mpl.image.AxesImage):\n",
" ax.set_data(image)\n",
" return ax\n",
" img = ax.imshow(image, extent=[0, 360, 0, 180], cmap='viridis')\n",
" ax.set_title(title)\n",
" if show:\n",
" plt.show()\n",
" return img"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"def plot_gratings(ax: typing.Union[plt.Axes, mpl.image.AxesImage], k_val: float, phi_val: float, theta_val: float, x0_val: float = 0, y0_val: float = 0):\n",
" phi_val *= np.pi / 180\n",
" theta_val *= np.pi / 180\n",
" return plot_spatial(\n",
" # grating_f.evalf(subs={k: k_val, x0: x0_val, y0: y0_val, theta: theta_val, phi: phi_val}),\n",
" grating_f.subs(k, k_val).subs(x0, x0_val).subs(y0, y0_val).subs(theta, theta_val).subs(phi, phi_val),\n",
" ax, step_x=0.05, step_y=0.05, size=1, title='Grating', show=False)\n",
"\n",
"def plot_receptive_field(ax: plt.Axes, k_val: float, phi_val: float, theta_val: float, sigma_val: float = 1):\n",
" phi_val *= np.pi / 180\n",
" theta_val *= np.pi / 180\n",
" return plot_spatial(\n",
" receptive_field.subs(k, k_val).subs(theta, theta_val).subs(phi, phi_val).subs(sigma, sigma_val),\n",
" ax, step_x=0.05, step_y=0.05, size=1, title='Receptive field', show=False)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"def get_value(k_val: float = defaults[k], phi_val: float = 90, theta_val: float = 0, x0_val: float = 0, y0_val: float = 0, sigma_val: float = defaults[sigma]):\n",
" phi_val *= np.pi / 180\n",
" theta_val *= np.pi / 180\n",
" grid_size = 0.05\n",
" grid = get_spatial_grid(grid_size, grid_size, 1)\n",
" subs = {\n",
" k: k_val,\n",
" x0: x0_val,\n",
" y0: y0_val,\n",
" theta: theta_val,\n",
" phi: phi_val,\n",
" sigma: sigma_val\n",
" }\n",
" grating_img = eval_func(grating_f.subs(subs), x, y, grid)\n",
" rf_img = eval_func(receptive_field.subs(subs), x, y, grid)\n",
" return np.sum(grating_img * rf_img) * grid_size ** 2"
]
},
{
"cell_type": "code",
2 years ago
"execution_count": 11,
2 years ago
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAD8CAYAAAB+UHOxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAApiElEQVR4nO3de5gcdZ3v8fdnZhLIZSZDCGEgF25mVW4L60hg2T2iwi5EfAL7IAIeLh7XbHTzrOwRV9Tj6mHdczged11XEQweFlwvwCqXqFm5PSq7omwCQiRclhguGZKQhGSSTO4z8z1/VPWk06meru6unqru+r6eZ56ZrvpV1a+7en7f+l2qfjIznHPO5U9b2hlwzjmXDg8AzjmXUx4AnHMupzwAOOdcTnkAcM65nPIA4JxzOeUBwLkWJel8SS9IWiXp+oj1H5C0Ivx5TNLvxt3WtQb5fQDOtR5J7cB/AucBfcAy4HIze7Yoze8Dz5nZFkkXAJ83s7lxtnWtwWsAzrWmM4BVZrbazPYCdwLzixOY2WNmtiV8+StgZ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b57FbXtiH8PYUDp2L82pmx6adhwZaBsyRdBzwGkF/xBWjb5LItq6J1BUAzOw5ACmqxjhipEMpTFvoUGqagiJv/Lw2PzMbVPCoigeAduA2M1spaWG4/hZJPQQ3lXUBw5KuBU40s21R26byRlxDjcUzZWZw4M0pfcDccomLO5UmTJjwtmOO8f7OtEyYMIHp06cv6+7upr+/vzQa1Hxex48f/zZvL268GTNmFL/8wsyZM79QWDZz5sybJ06cyI4dOyKjvJktJRh15lpYxQAg6WGi72D8jJlVem4OVNk
"text/plain": [
"<Figure size 432x288 with 3 Axes>"
]
2 years ago
},
"metadata": {
"needs_background": "light"
2 years ago
},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1aeab1cd8fc64df8a7107f5cafb3bdc6",
2 years ago
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=6.0, description='k', max=10.0, step=0.2), FloatSlider(value=90.0, des…"
]
2 years ago
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(1, 3)\n",
"img_gr = plot_gratings(ax[0], defaults[k], 90, 0, 0, 0)\n",
"img_rf = plot_receptive_field(ax[1], defaults[k], 90, 90, defaults[sigma])\n",
"val = get_value()\n",
"line = ax[2].plot([val, val])[0]\n",
"ax[2].set(ylim=[-0.2, 0.2])\n",
"\n",
"@widgets.interact(\n",
" k_val=widgets.FloatSlider(min=0, max=10, step=0.2, value=defaults[k], description='k'),\n",
" phi_val=widgets.FloatSlider(min=0, max=360, step=10, value=90, description='phi'),\n",
" theta_val=widgets.FloatSlider(min=0, max=180, step=10, value=0, description='theta'),\n",
" x0_val=widgets.FloatSlider(min=-1, max=1, step=0.05, value=0, description='x0'),\n",
" y0_val=widgets.FloatSlider(min=-1, max=1, step=0.05, value=0, description='y0'),\n",
" sigma_val=widgets.FloatSlider(min=0, max=1, step=0.05, value=defaults[sigma], description='sigma'),\n",
")\n",
"def plot_stuff(k_val, phi_val, theta_val, x0_val, y0_val, sigma_val):\n",
" plot_gratings(img_gr, k_val, phi_val, theta_val, x0_val, y0_val)\n",
" plot_receptive_field(img_rf, k_val, phi_val, theta_val, sigma_val)\n",
" val = get_value(k_val, phi_val, theta_val, x0_val, y0_val, sigma_val)\n",
" line.set_ydata([val, val])\n",
" fig.canvas.draw_idle()"
]
},
{
"cell_type": "code",
"execution_count": 14,
2 years ago
"metadata": {
"pycharm": {
2 years ago
"name": "#%%\n"
2 years ago
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAB7CAYAAACPdcAxAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAP2UlEQVR4nO3dfYxc5XXH8e9vdte7Xq/f1jZgwMVQSIqpWppS2kQtjZKoCUgImtIKGqkkikRb9S1/pK0Rapq0Qkraqmql0lRIoVA1QChtBa1oE5I0QSRtCUmAYMBgXu3YYHvXb+v1rvfl9I+50LGz8zxje2bnzvXvI608c5/rZ86dOXvm7sy59yoiMDOzaql1OwAzM2s/F3czswpycTczqyAXdzOzCnJxNzOrIBd3M7MKcnFfRJJ+SNKEpL5ux2LWTs7t8nFxb6JI1Dd/5iUdabj/oZOZMyJei4iRiJhrd7wAki6X9JCk/ZLGJT0m6SOdeCzrXc7t04OLexNFoo5ExAjwGnB1w7LPdzu+40l6J/BV4OvAhcAa4DeBK09yPu+BVZRz+/TIbRf3EyTpk5L+seH+Rkkhqb+4/zVJfyrpG5IOSfqSpLUnum4x/muSXpU0JumPJL0i6X1NQvtz4K6I+ExE7I26b0fErxRzfVjSo8dtS0i6sLh9p6TPFntHh4GbJb3e+Isg6RclPVXcrknaLOnFIr77JI224Sm2LnFuVyu3Xdw741eBjwBnAEuAj5/oupI2AX8LfAhYD6wEzlloAknDwDuB+9sQ963AcuAvgMPAe44bv7u4/b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0d0n94JjtHZC6RF3MtXDOwlo5Vw/lumbm
"text/plain": [
"<Figure size 432x288 with 2 Axes>"
]
2 years ago
},
"metadata": {
"needs_background": "light"
2 years ago
},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a746cf33796443a2a12fcb48948c7aed",
2 years ago
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=0.8, description='k', max=10.0, step=0.2), FloatSlider(value=0.8, desc…"
]
2 years ago
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(1, 2)\n",
"DEF_K, DEF_SIGMA, DEF_X = 0.8, 0.05, 0.8\n",
"get_tuning_curve_func = lambda k_val, x0_val, y0_val, sigma_val: lambda theta_val, phi_val: get_value(k_val, phi_val * 180 / np.pi, theta_val * 180 / np.pi, x0_val, y0_val, sigma_val)\n",
"left_img = plot_tuning_curve(get_tuning_curve_func(DEF_K, DEF_X, 0, DEF_SIGMA), ax[0], title='Tuning Curve')\n",
"right_img = plot_tuning_curve(p.subs({k: defaults[k], x0: defaults[x0], y0: defaults[y0], sigma: defaults[sigma]}), ax[1], title='Tuning Curve')\n",
"\n",
"@widgets.interact(\n",
" k_val=widgets.FloatSlider(min=0, max=10, step=0.2, value=DEF_K, description='k'),\n",
" x0_val=widgets.FloatSlider(min=-1, max=1, step=0.05, value=DEF_X, description='x0'),\n",
" y0_val=widgets.FloatSlider(min=-1, max=1, step=0.05, value=0, description='y0'),\n",
" sigma_val=widgets.FloatSlider(min=0, max=1, step=0.05, value=DEF_SIGMA, description='sigma'),\n",
")\n",
"def plot_tuning_curves(k_val, x0_val, y0_val, sigma_val):\n",
" plot_tuning_curve(get_tuning_curve_func(k_val, x0_val, y0_val, sigma_val), left_img, title='Tuning Curve - Numeric')\n",
" plot_tuning_curve(p.subs({k: k_val, x0: x0_val, y0: y0_val, sigma: sigma_val}), right_img, title='Tuning Curve - Analytic')\n",
" fig.canvas.draw_idle()"
]
},
{
"cell_type": "code",
2 years ago
"execution_count": 13,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEDCAYAAAA2k7/eAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAv6ElEQVR4nO3deXxV5bn3/8+1Myc7jNk7QBgC2SAgikBEZicoiLZo61iLI9J6Wjuetno852nPYB+f0/462GO1CFacZ6tVBIVqBUUgDCphhkCYQkIgkEDmXL8/suFQmpBhD2sP1/v1yit7r6ys+4rCl5V73YOoKsYYY2Kfy+kCjDHGhIcFvjHGxAkLfGOMiRMW+MYYEycs8I0xJk5Y4BtjTJyI+MAXkSdFpFRENgbpeotFpEJE3j7ruIjIQyKyTUQ2i8h3g9GeMcZEiogPfOApYEYQr/dLYHYLx+8A+gFDVXUY8GIQ2zTGGMdFfOCr6kfAkTOPiUie/059rYgsF5GhHbjeMqCyhS/dC/yHqjb5zysNpG5jjIk0ER/4rZgH3KeqY4B/Bv4QhGvmATeJSIGIvCsig4NwTWOMiRiJThfQUSLiBiYAr4jIqcMp/q99FfiPFr5tv6pOb+PSKUCNqub7r/MkMDk4VRtjjPOiLvBp/q2kQlUvOvsLqvo68Honr7sPeM3/+g3gT528jjHGRKSo69JR1eNAkYjcAKdH14wMwqX/DFzhf30psC0I1zTGmIghkb5apoi8AFwGZAGHgJ8BfwUeA3oDScCLqtpSV05L11sODAXcQDlwt6ouEZFuwHNAf6AK+JaqfhbUH8YYYxwU8YFvjDEmOKKuS8cYY0znRPRD26ysLM3NzXW6DGOMiRpr1649rKqelr4W0YGfm5tLQUGB02UYY0zUEJE9rX3NunSMMSZOWOAbY0ycsMA3xpg4YYFvjDFxwgLfGGPiRFACX0RmiMhWEdkhIve38HURkUf8X/9cREYHo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xsfjGmPgRt4GfkpjAgJ4ZFvjGmLgRt4EPkOexRdSMMfEjrgPf53Wzu/wEDY0RscSPMcaEVNwHfn2jsufISadLMcaYkIv7wAd7cGuMiQ9xHfh5ngzAhmYaY+JDXAd+ZmoSvbqk2h2+MSYuxHXgQ3O3zk4LfGNMHLDA97rZWXYC1ZAsvW+MMREj7gM/z+umqraBkuM1TpdijDEhFfeB7/PYSB1jTHywwLehmcaYOBH3gZ/lTqZrWpIFvjEm5sV94IsIPq+tqWOMiX0BBb6I9BCR90Vku/9z91bO6yYir4rIFhHZLCLjA2k32Hwet02+MsbEvEDv8O8HlqnqYGCZ/31LfgcsVtWhwEhgc4DtBpXP6+ZwVR0VJ+ucLsUYY0Im0MCfBSz0v14IXHv2CSLSBZgCLABQ1TpVrQiw3aDK8zYvsWDdOsaYWBZo4Ger6kEA/2dvC+cMAsqAP4nIehGZLyIZrV1QROaKSIGIFJSVlQVYXvv4PJmABb4xJra1GfgislRENrbwMaudbSQCo4HHVHUUcILWu35Q1Xmqmq+q+R6Pp51NBCanexopiS4LfGNMTEts6wRVndra10TkkIj0VtWDItIbKG3htH3APlVd5X//KucIfCckuIRBHjc77MGtMSaGBdql8xZwu//17cCbZ5+gqiXAXhE5z3/oSmBTgO0GnQ3NNMbEukAD/2FgmohsB6b53yMifURk0Rnn3Qc8JyKfAxcBvwiw3aDzedzsr6imuq7R6VKMMSYk2uzSORdVLaf5jv3s4weAmWe83wDkB9JWqPm8blSbN0MZkdPV6XKMMSbo4n6m7Smn1tSxCVjGmFhlge+Xm5WOS2xopjEmdlng+6UkJjCgZ4YFvjEmZlngnyHPYyN1jDGxywL/DD6vm93lJ2hobHK6FGOMCToL/DP4vG7qG5XiIyedLsUYY4LOAv8Mtvu
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
2 years ago
"source": [
"# %matplotlib inline\n",
"func_1 = get_tuning_curve_func(DEF_K, DEF_X, 0, DEF_SIGMA)\n",
"func_2 = p.subs({k: DEF_K, x0: DEF_X, y0: 0, sigma: DEF_SIGMA})\n",
"grid = get_orientation_phase_grid(15, 15)\n",
"img_1 = np.array([[func_1(theta, phi) for theta, phi in line] for line in grid])\n",
"img_2 = eval_func(func_2, theta, phi, grid)\n",
"plt.plot(np.mean(img_2, axis=1))\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 14,
2 years ago
"metadata": {
"collapsed": false,
"pycharm": {
2 years ago
"name": "#%%\n"
2 years ago
}
},
2 years ago
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkoAAAApCAYAAADK3AZEAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAVb0lEQVR4Ae2d7bXcNBPHNzkpINxU8IQOIKkgoQNIKiB0ACff+JYDHUAqCKQDoAIgHUAHhNtBnv9PKwnZK1uyZe/a947O8crW68x/RtLoxd47Hz58OGzBffvttw91/b0FWrZEg+GyJWkYLYaAIWAIGAK3DYG7W2BYxsDXouOTLdCyQRowIMHHnCFgCBgChoAhYAicGYE7a6woaWB/Kj7u63qo62NdPyvsV/knTuGfK/Cx/G9OIhcImELLAtWtUoR4wFC6lv/jKhVYoYaAIWAIGAKGgCGQRWCtFSUMo7e6vletGEC/5GpXPMbUS/mrGEm+zipacvRtJczj+JXHaytkGR2GgCFgCBgChsCNR2AtQ+nTBDlWla6T5/T2Oz38kAascF9LywpVL1okOIGXOUPAEDAEDAFDwBA4EwKzDSWtbvyga2ilKD2UzeD+xQA/z1TGqttJKr+Wlkii8jzVdXJmSmFf63qBHxL7MFbGVnWqB5zAa/W6VmXECjcEDAFDwBAwBHaEwGxDSTxiJKVGyAnbGtRZBflG/sn5JIVxNmk0/0mBDQFjtKTFKh0GEgeo3/XCMfh+VTgGy+MQp2e2F4srPUo3mkbx1PmLrjFDCLyehbrNNwQMAUPAEDAEDIF1EWgxlD4TaX8OkecNA4ykd7riCkySnvwnBlQSv9htBS1pXd8pfWeVS88PleA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Jn+SUf+vyDgYiHVTqwBoX9e/46H7pbNHZczu+f4NMkD0ySuXNwBZ0YhJdKg/dGmxLigcD3mhCx6LTM30y4eBxpcu1TRIoDPww5kpvx47p5xzZUH1JPk3x4ukSOo2
"text/latex": [
"$\\displaystyle e^{\\frac{k^{2} \\left(\\cos^{2}{\\left(\\theta \\right)} + 1\\right)}{2}} \\cos{\\left(\\phi - k \\left(x_{0} \\cos{\\left(\\theta \\right)} + y_{0} \\sin{\\left(\\theta \\right)}\\right) \\right)} \\cosh{\\left(\\sigma^{2} k^{2} \\cos{\\left(\\theta \\right)} \\right)}$"
],
"text/plain": [
" 2 ⎛ 2 ⎞ \n",
" k ⋅⎝cos (\\theta) + 1⎠ \n",
" ───────────────────── \n",
" 2 ⎛ \n",
"ℯ ⋅cos(\\phi - k⋅(x₀⋅cos(\\theta) + y₀⋅sin(\\theta)))⋅cosh⎝\\s\n",
"\n",
" \n",
" \n",
" \n",
" 2 2 ⎞\n",
"igma ⋅k ⋅cos(\\theta)⎠"
]
2 years ago
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
2 years ago
"source": [
"p"
]
2 years ago
},
{
"cell_type": "code",
2 years ago
"execution_count": 14,
2 years ago
"metadata": {
"collapsed": false,
"pycharm": {
2 years ago
"name": "#%%\n"
2 years ago
}
},
"outputs": [],
"source": []
2 years ago
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.5 64-bit",
2 years ago
"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"
}
2 years ago
}
},
"nbformat": 4,
"nbformat_minor": 1
}