{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compute FWHM of PSTHs for 11 and 30Hz\n", "\n", "Only PSTHs with a significance level below 0.05 are used" ] }, { "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": [ "/home/mikkel/.virtualenvs/expipe/lib/python3.6/site-packages/ipykernel_launcher.py:21: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n", "Please use `tqdm.notebook.*` instead of `tqdm._tqdm_notebook.*`\n" ] } ], "source": [ "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import spatial_maps as sp\n", "import septum_mec.analysis.data_processing as dp\n", "import septum_mec.analysis.registration\n", "import expipe\n", "import os\n", "import pathlib\n", "import numpy as np\n", "import exdir\n", "import pandas as pd\n", "import optogenetics as og\n", "import quantities as pq\n", "import shutil\n", "from distutils.dir_util import copy_tree\n", "import seaborn as sns\n", "from functools import reduce\n", "from septum_mec.analysis.stimulus_response import stimulus_response_latency, compute_response\n", "import scipy.stats\n", "from tqdm import tqdm_notebook as tqdm\n", "from tqdm._tqdm_notebook import tqdm_notebook\n", "from septum_mec.analysis.statistics import load_data_frames, make_paired_tables, make_statistics_table \n", "tqdm_notebook.pandas()\n", "\n", "%matplotlib widget" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "std_gaussian_kde = 0.04\n", "window_size = 0.03\n", "tmin = 0. # delay to compute FWHM after stimulus onset" ] }, { "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": [ "output = pathlib.Path('output/stimulus-response-fwhm')\n", "(output / 'data').mkdir(parents=True, exist_ok=True)\n", "(output / 'figures').mkdir(parents=True, exist_ok=True)\n", "(output / 'statistics').mkdir(parents=True, exist_ok=True)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "colors = ['#d95f02','#e7298a']\n", "labels = [\n", " '11 Hz', \n", " '30 Hz'\n", "]\n", "queries = [\n", " 'frequency==11 and stim_location==\"ms\"',\n", " 'frequency==30 and stim_location==\"ms\"']" ] }, { "cell_type": "code", "execution_count": 7, "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(queries, labels, colors)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# use baseline==False and p_e_peak < 0.05\n", "session_units_sig = data.query('p_e_peak == p_e_peak')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | action | \n", "baseline | \n", "entity | \n", "frequency | \n", "i | \n", "ii | \n", "session | \n", "stim_location | \n", "stimulated | \n", "tag | \n", "... | \n", "bs_ctrl | \n", "ns_inhibited | \n", "ns_not_inhibited | \n", "gridcell | \n", "bs_not_gridcell | \n", "label | \n", "label_num | \n", "query | \n", "color | \n", "cell_type | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13 | \n", "1839-120619-4 | \n", "False | \n", "1839 | \n", "30.0 | \n", "False | \n", "True | \n", "4 | \n", "ms | \n", "True | \n", "stim ii | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "30 Hz | \n", "1.0 | \n", "frequency==30 and stim_location==\"ms\" | \n", "#e7298a | \n", "bs_not_gridcell | \n", "
14 | \n", "1839-120619-4 | \n", "False | \n", "1839 | \n", "30.0 | \n", "False | \n", "True | \n", "4 | \n", "ms | \n", "True | \n", "stim ii | \n", "... | \n", "NaN | \n", "True | \n", "False | \n", "True | \n", "False | \n", "30 Hz | \n", "1.0 | \n", "frequency==30 and stim_location==\"ms\" | \n", "#e7298a | \n", "gridcell | \n", "
15 | \n", "1839-120619-4 | \n", "False | \n", "1839 | \n", "30.0 | \n", "False | \n", "True | \n", "4 | \n", "ms | \n", "True | \n", "stim ii | \n", "... | \n", "NaN | \n", "True | \n", "False | \n", "False | \n", "False | \n", "30 Hz | \n", "1.0 | \n", "frequency==30 and stim_location==\"ms\" | \n", "#e7298a | \n", "ns_inhibited | \n", "
16 | \n", "1839-120619-4 | \n", "False | \n", "1839 | \n", "30.0 | \n", "False | \n", "True | \n", "4 | \n", "ms | \n", "True | \n", "stim ii | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "30 Hz | \n", "1.0 | \n", "frequency==30 and stim_location==\"ms\" | \n", "#e7298a | \n", "bs_not_gridcell | \n", "
17 | \n", "1839-120619-4 | \n", "False | \n", "1839 | \n", "30.0 | \n", "False | \n", "True | \n", "4 | \n", "ms | \n", "True | \n", "stim ii | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "30 Hz | \n", "1.0 | \n", "frequency==30 and stim_location==\"ms\" | \n", "#e7298a | \n", "bs_not_gridcell | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1279 | \n", "1833-010719-2 | \n", "False | \n", "1833 | \n", "11.0 | \n", "True | \n", "False | \n", "2 | \n", "ms | \n", "True | \n", "stim i | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "11 Hz | \n", "0.0 | \n", "frequency==11 and stim_location==\"ms\" | \n", "#d95f02 | \n", "bs_not_gridcell | \n", "
1280 | \n", "1833-010719-2 | \n", "False | \n", "1833 | \n", "11.0 | \n", "True | \n", "False | \n", "2 | \n", "ms | \n", "True | \n", "stim i | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "11 Hz | \n", "0.0 | \n", "frequency==11 and stim_location==\"ms\" | \n", "#d95f02 | \n", "bs_not_gridcell | \n", "
1281 | \n", "1833-010719-2 | \n", "False | \n", "1833 | \n", "11.0 | \n", "True | \n", "False | \n", "2 | \n", "ms | \n", "True | \n", "stim i | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "11 Hz | \n", "0.0 | \n", "frequency==11 and stim_location==\"ms\" | \n", "#d95f02 | \n", "bs_not_gridcell | \n", "
1282 | \n", "1833-010719-2 | \n", "False | \n", "1833 | \n", "11.0 | \n", "True | \n", "False | \n", "2 | \n", "ms | \n", "True | \n", "stim i | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "11 Hz | \n", "0.0 | \n", "frequency==11 and stim_location==\"ms\" | \n", "#d95f02 | \n", "bs_not_gridcell | \n", "
1283 | \n", "1833-010719-2 | \n", "False | \n", "1833 | \n", "11.0 | \n", "True | \n", "False | \n", "2 | \n", "ms | \n", "True | \n", "stim i | \n", "... | \n", "NaN | \n", "False | \n", "False | \n", "False | \n", "True | \n", "11 Hz | \n", "0.0 | \n", "frequency==11 and stim_location==\"ms\" | \n", "#d95f02 | \n", "bs_not_gridcell | \n", "
647 rows × 68 columns
\n", "