{ "cells": [ { "cell_type": "code", "execution_count": null, "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 statsmodels\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", "\n", "from septum_mec.analysis.statistics import load_data_frames, make_paired_tables, make_statistics_table\n", "\n", "from spikewaveform.core import calculate_waveform_features_from_template, cluster_waveform_features\n", "\n", "from septum_mec.analysis.plotting import violinplot, despine" ] }, { "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': (8, 4), \n", " 'figure.dpi': 150\n", "})\n", "\n", "output_path = pathlib.Path(\"output\") / (\"theta-rhythmicity\")\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": [ { "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": 6, "metadata": {}, "outputs": [], "source": [ "theta_action = actions['theta-rhythmicity']\n", "theta_results = pd.read_csv(theta_action.data_path('results'))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "stim_action = actions['stimulus-response']\n", "stim_results = pd.read_csv(stim_action.data_path('results'))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "data = data.drop(columns='theta_score').merge(theta_results, how='left')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "data = data.merge(stim_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_score',\n", " 'theta_bandpower',\n", " 'theta_relpower',\n", " 'theta_relpeak',\n", " 'theta_peak',\n", " 'theta_freq',\n", " 'theta_half_width',\n", " 'stim_bandpower',\n", " 'stim_relpower',\n", " 'stim_relpeak',\n", " 'stim_half_width',\n", " 'stim_p_max',\n", " 'stim_strength',\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", "1.248894 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
85 | \n", "1833 | \n", "13 | \n", "0 | \n", "20719 | \n", "NaN | \n", "0.037071 | \n", "1.287301 | \n", "0.176807 | \n", "
86 | \n", "1833 | \n", "14 | \n", "0 | \n", "20719 | \n", "NaN | \n", "0.107253 | \n", "1.573884 | \n", "NaN | \n", "
58 | \n", "1833 | \n", "23 | \n", "0 | \n", "200619 | \n", "1.032539 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
127 | \n", "1833 | \n", "26 | \n", "0 | \n", "200619 | \n", "NaN | \n", "NaN | \n", "0.851083 | \n", "0.265955 | \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", "2.182959 | \n", "
43 | \n", "1849 | \n", "851 | \n", "5 | \n", "60319 | \n", "2.999367 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
65 | \n", "1849 | \n", "932 | \n", "7 | \n", "280219 | \n", "1.869360 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
74 | \n", "1849 | \n", "937 | \n", "7 | \n", "280219 | \n", "NaN | \n", "0.264037 | \n", "NaN | \n", "NaN | \n", "
105 | \n", "1849 | \n", "939 | \n", "7 | \n", "280219 | \n", "NaN | \n", "NaN | \n", "2.499672 | \n", "NaN | \n", "
137 rows × 8 columns
\n", "