{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "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", "import seaborn as sns\n", "from distutils.dir_util import copy_tree\n", "from neo import SpikeTrain\n", "import scipy\n", "from functools import reduce\n", "from tqdm.notebook import tqdm_notebook as tqdm\n", "tqdm.pandas()\n", "\n", "from spikewaveform.core import calculate_waveform_features_from_template, cluster_waveform_features\n", "\n", "from septum_mec.analysis.plotting import violinplot, despine\n", "\n", "from septum_mec.analysis.statistics import load_data_frames, make_paired_tables, make_statistics_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## chose where to sample LFP" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "#################################################\n", "\n", "lfp_location = ''\n", "# lfp_location = '-other-tetrode'\n", "# lfp_location = '-other-drive'\n", "\n", "##################################################" ] }, { "cell_type": "code", "execution_count": 4, "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-spike-lfp-response\" + lfp_location)\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": 5, "metadata": {}, "outputs": [], "source": [ "project_path = dp.project_path()\n", "project = expipe.get_project(project_path)\n", "actions = project.actions" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of sessions above threshold 194\n", "Number of animals 4\n", "Number of individual gridcells 139\n", "Number of gridcell recordings 230\n" ] } ], "source": [ "data, labels, colors, queries = load_data_frames()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "lfp_action = actions['stimulus-spike-lfp-response' + lfp_location]\n", "lfp_results = pd.read_csv(lfp_action.data_path('results'))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# lfp_results has old unit id's but correct on (action, unit_name, channel_group)\n", "lfp_results = lfp_results.drop('unit_id', axis=1)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "data = data.merge(lfp_results, how='left')" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "data['stim_strength'] = data.stim_p_max / data.theta_peak" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "keys = [\n", " 'theta_energy',\n", " 'theta_peak',\n", " 'theta_freq',\n", " 'theta_half_width',\n", " 'theta_vec_len',\n", " 'theta_ang',\n", " 'stim_energy',\n", " 'stim_half_width',\n", " 'stim_p_max',\n", " 'stim_strength',\n", " 'stim_vec_len',\n", " 'stim_ang'\n", "]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "results, labels = make_paired_tables(data, keys)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | entity | \n", "unit_idnum | \n", "channel_group | \n", "date | \n", "Baseline I | \n", "11 Hz | \n", "Baseline II | \n", "30 Hz | \n", "
---|---|---|---|---|---|---|---|---|
51 | \n", "1833 | \n", "8 | \n", "0 | \n", "20719 | \n", "0.244278 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
85 | \n", "1833 | \n", "13 | \n", "0 | \n", "20719 | \n", "NaN | \n", "0.039465 | \n", "0.279382 | \n", "0.054633 | \n", "
86 | \n", "1833 | \n", "14 | \n", "0 | \n", "20719 | \n", "NaN | \n", "0.022268 | \n", "0.448472 | \n", "NaN | \n", "
58 | \n", "1833 | \n", "23 | \n", "0 | \n", "200619 | \n", "0.280865 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
127 | \n", "1833 | \n", "26 | \n", "0 | \n", "200619 | \n", "NaN | \n", "NaN | \n", "0.181703 | \n", "0.038459 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
139 | \n", "1849 | \n", "835 | \n", "4 | \n", "150319 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.692552 | \n", "
43 | \n", "1849 | \n", "851 | \n", "5 | \n", "60319 | \n", "0.662908 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
65 | \n", "1849 | \n", "932 | \n", "7 | \n", "280219 | \n", "0.050995 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
74 | \n", "1849 | \n", "937 | \n", "7 | \n", "280219 | \n", "NaN | \n", "0.131422 | \n", "NaN | \n", "NaN | \n", "
105 | \n", "1849 | \n", "939 | \n", "7 | \n", "280219 | \n", "NaN | \n", "NaN | \n", "0.472020 | \n", "NaN | \n", "
137 rows × 8 columns
\n", "