{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "18:16:41 [I] klustakwik KlustaKwik2 version 0.2.6\n" ] } ], "source": [ "import os\n", "import expipe\n", "import pathlib\n", "import numpy as np\n", "import spatial_maps.stats as stats\n", "import septum_mec\n", "import septum_mec.analysis.data_processing as dp\n", "import septum_mec.analysis.registration\n", "import head_direction.head as head\n", "import spatial_maps as sp\n", "import speed_cells.speed as spd\n", "import re\n", "import joblib\n", "import multiprocessing\n", "import shutil\n", "import psutil\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import matplotlib\n", "from distutils.dir_util import copy_tree\n", "from neo import SpikeTrain\n", "import scipy\n", "import seaborn as sns\n", "from tqdm import tqdm_notebook as tqdm\n", "from tqdm._tqdm_notebook import tqdm_notebook\n", "tqdm_notebook.pandas()\n", "\n", "from spike_statistics.core import permutation_resampling\n", "\n", "from spikewaveform.core import calculate_waveform_features_from_template, cluster_waveform_features\n", "\n", "from septum_mec.analysis.plotting import violinplot" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "plt.rc('axes', titlesize=12)\n", "plt.rcParams.update({\n", " 'font.size': 12, \n", " 'figure.figsize': (6, 4), \n", " 'figure.dpi': 150\n", "})\n", "\n", "output_path = pathlib.Path(\"output\") / \"stimulus-lfp-response\"\n", "(output_path / \"statistics\").mkdir(exist_ok=True, parents=True)\n", "(output_path / \"figures\").mkdir(exist_ok=True, parents=True)\n", "output_path.mkdir(exist_ok=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "data_loader = dp.Data()\n", "actions = data_loader.actions\n", "project = data_loader.project" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "identify_neurons = actions['identify-neurons']\n", "sessions = pd.read_csv(identify_neurons.data_path('sessions'))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "lfp_action = actions['stimulus-lfp-response']\n", "lfp_results = pd.read_csv(lfp_action.data_path('results'))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "lfp_results = pd.merge(sessions, lfp_results, how='left')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "def action_group(row):\n", " a = int(row.channel_group in [0,1,2,3])\n", " return f'{row.action}-{a}'\n", "lfp_results['action_side_a'] = lfp_results.apply(action_group, axis=1)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "lfp_results['stim_strength'] = lfp_results['stim_p_max'] / lfp_results['theta_energy']" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | action_side_a | \n", "channel_group | \n", "signal_to_noise | \n", "stim_strength | \n", "
---|---|---|---|---|
68 | \n", "1833-010719-1-0 | \n", "4 | \n", "0.006686 | \n", "NaN | \n", "
66 | \n", "1833-010719-1-1 | \n", "2 | \n", "0.034550 | \n", "NaN | \n", "
694 | \n", "1833-010719-2-0 | \n", "6 | \n", "0.004609 | \n", "7.173297 | \n", "
691 | \n", "1833-010719-2-1 | \n", "3 | \n", "0.003974 | \n", "6.446883 | \n", "
580 | \n", "1833-020719-1-0 | \n", "4 | \n", "0.008427 | \n", "NaN | \n", "