From 1652ab405e64091e0552c9ef586859506b5d177e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikkel=20Elle=20Lepper=C3=B8d?= Date: Wed, 10 Mar 2021 13:57:46 +0100 Subject: [PATCH] actions/cell-count/ --- actions/cell-count/attributes.yaml | 4 + actions/cell-count/data/20_cell_count.html | 13756 ++++++++++++++++ actions/cell-count/data/20_cell_count.ipynb | 517 + actions/cell-count/data/statistics/counts.csv | 5 + actions/cell-count/data/statistics/counts.tex | 11 + 5 files changed, 14293 insertions(+) create mode 100644 actions/cell-count/attributes.yaml create mode 100644 actions/cell-count/data/20_cell_count.html create mode 100644 actions/cell-count/data/20_cell_count.ipynb create mode 100644 actions/cell-count/data/statistics/counts.csv create mode 100644 actions/cell-count/data/statistics/counts.tex diff --git a/actions/cell-count/attributes.yaml b/actions/cell-count/attributes.yaml new file mode 100644 index 000000000..79e94af57 --- /dev/null +++ b/actions/cell-count/attributes.yaml @@ -0,0 +1,4 @@ +registered: '2020-08-26T13:39:33' +data: + notebook: 20_cell_count.ipynb + html: 20_cell_count.html diff --git a/actions/cell-count/data/20_cell_count.html b/actions/cell-count/data/20_cell_count.html new file mode 100644 index 000000000..a534b5588 --- /dev/null +++ b/actions/cell-count/data/20_cell_count.html @@ -0,0 +1,13756 @@ + + + + +20_cell_count + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
In [1]:
+
+
+
%load_ext autoreload
+%autoreload 2
+
+ +
+
+
+ +
+
+
+
In [2]:
+
+
+
import os
+import expipe
+import pathlib
+import numpy as np
+import spatial_maps.stats as stats
+import septum_mec
+import septum_mec.analysis.data_processing as dp
+import septum_mec.analysis.registration
+import head_direction.head as head
+import spatial_maps as sp
+import speed_cells.speed as spd
+import re
+import joblib
+import multiprocessing
+import shutil
+import psutil
+import pandas as pd
+import matplotlib.pyplot as plt
+import matplotlib
+# import seaborn as sns
+from distutils.dir_util import copy_tree
+from neo import SpikeTrain
+import scipy
+
+from tqdm.notebook import tqdm_notebook as tqdm
+tqdm.pandas()
+
+from spike_statistics.core import permutation_resampling
+
+from spikewaveform.core import calculate_waveform_features_from_template, cluster_waveform_features
+
+from septum_mec.analysis.plotting import violinplot, despine
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
13:30:10 [I] klustakwik KlustaKwik2 version 0.2.6
+
+
+
+ +
+
+ +
+
+
+
In [29]:
+
+
+
%matplotlib inline
+plt.rc('axes', titlesize=12)
+plt.rcParams.update({
+    'font.size': 12, 
+    'figure.figsize': (6, 4), 
+    'figure.dpi': 150
+})
+
+output_path = pathlib.Path("output") / "cell-count"
+(output_path / "statistics").mkdir(exist_ok=True, parents=True)
+(output_path / "figures").mkdir(exist_ok=True, parents=True)
+output_path.mkdir(exist_ok=True)
+
+ +
+
+
+ +
+
+
+
In [4]:
+
+
+
data_loader = dp.Data()
+actions = data_loader.actions
+project = data_loader.project
+
+ +
+
+
+ +
+
+
+
In [5]:
+
+
+
identification_action = actions['identify-neurons']
+sessions = pd.read_csv(identification_action.data_path('sessions'))
+units = pd.read_csv(identification_action.data_path('units'))
+session_units = pd.merge(sessions, units, on='action')
+
+ +
+
+
+ +
+
+
+
In [6]:
+
+
+
stim_action = actions['stimulus-response']
+stim_results = pd.read_csv(stim_action.data_path('results'))
+
+ +
+
+
+ +
+
+
+
In [8]:
+
+
+
statistics_action = actions['calculate-statistics']
+shuffling = actions['shuffling']
+
+statistics_results = pd.read_csv(statistics_action.data_path('results'))
+statistics_results = session_units.merge(statistics_results, how='left')
+quantiles_95 = pd.read_csv(shuffling.data_path('quantiles_95'))
+action_columns = ['action', 'channel_group', 'unit_name']
+data = pd.merge(statistics_results, quantiles_95, on=action_columns, suffixes=("", "_threshold"))
+
+ +
+
+
+ +
+
+
+
In [9]:
+
+
+
data['unit_day'] = data.apply(lambda x: str(x.unit_idnum) + '_' + x.action.split('-')[1], axis=1)
+
+ +
+
+
+ +
+
+
+
In [10]:
+
+
+
data = data.merge(stim_results, how='left')
+
+ +
+
+
+ +
+
+
+
In [11]:
+
+
+
waveform_action = actions['waveform-analysis']
+waveform_results = pd.read_csv(waveform_action.data_path('results')).drop('template', axis=1)
+
+ +
+
+
+ +
+
+
+
In [12]:
+
+
+
data = data.merge(waveform_results, how='left')
+
+ +
+
+
+ +
+
+
+
In [13]:
+
+
+
colors = ['#d95f02','#e7298a']
+labels = ['11 Hz', '30 HZ']
+queries = ['frequency==11', 'frequency==30']
+
+ +
+
+
+ +
+
+
+
In [14]:
+
+
+
data.bs = data.bs.astype(bool)
+
+ +
+
+
+ +
+
+
+
In [15]:
+
+
+
data.loc[data.eval('t_i_peak == t_i_peak and not bs'), 'ns_inhibited'] = True
+data.ns_inhibited.fillna(False, inplace=True)
+
+data.loc[data.eval('t_i_peak != t_i_peak and not bs'), 'ns_not_inhibited'] = True
+data.ns_not_inhibited.fillna(False, inplace=True)
+
+ +
+
+
+ +
+
+
+
In [16]:
+
+
+
query = (
+    'gridness > gridness_threshold and '
+    'information_rate > information_rate_threshold and '
+    'gridness > .2 and '
+    'average_rate < 25'
+)
+sessions_above_threshold = data.query(query)
+print("Number of sessions above threshold", len(sessions_above_threshold))
+print("Number of animals", len(sessions_above_threshold.groupby(['entity'])))
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
Number of sessions above threshold 194
+Number of animals 4
+
+
+
+ +
+
+ +
+
+
+
In [17]:
+
+
+
gridcell_sessions = data[data.unit_day.isin(sessions_above_threshold.unit_day.values)]
+print("Number of gridcells", gridcell_sessions.unit_idnum.nunique())
+print("Number of gridcell recordings", len(gridcell_sessions))
+print("Number of animals", len(gridcell_sessions.groupby(['entity'])))
+
+ +
+
+
+ +
+
+ + +
+ +
+ + +
+
Number of gridcells 139
+Number of gridcell recordings 231
+Number of animals 4
+
+
+
+ +
+
+ +
+
+
+
In [18]:
+
+
+
data.loc[:,'gridcell'] = np.nan
+data['gridcell'] = data.isin(gridcell_sessions)
+
+data.loc[data.eval('not gridcell and bs'), 'bs_not_gridcell'] = True
+data.bs_not_gridcell.fillna(False, inplace=True)
+
+ +
+
+
+ +
+
+
+
In [28]:
+
+
+
table = pd.DataFrame()
+table['Gridcell'] = data.drop_duplicates('unit_idnum').query('gridcell').groupby('entity')['action'].count()
+table['BS not gridcell'] = data.drop_duplicates('unit_idnum').query('bs_not_gridcell').groupby('entity')['action'].count()
+table['NSi'] = data.drop_duplicates('unit_idnum').query('ns_inhibited').groupby('entity')['action'].count()
+table['NSni'] = data.drop_duplicates('unit_idnum').query('ns_not_inhibited').groupby('entity')['action'].count()
+table
+
+ +
+
+
+ +
+
+ + +
+ +
Out[28]:
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
GridcellBS not gridcellNSiNSni
entity
1833941651652
18341421647
18391970115
18498229823
+
+
+ +
+ +
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
+

Store results in Expipe action

+
+
+
+
+
+
In [35]:
+
+
+
action = project.require_action("cell-count")
+
+ +
+
+
+ +
+
+
+
In [36]:
+
+
+
copy_tree(output_path, str(action.data_path()))
+
+ +
+
+
+ +
+
+ + +
+ +
Out[36]:
+ + + + +
+
['/media/storage/expipe/septum-mec/actions/stimulus-response/data/data/times.feather',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/data/psth.feather',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited-stim-mec.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited.svg',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited-stim-mec.png',
+ '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited.png']
+
+ +
+ +
+
+ +
+
+
+
In [37]:
+
+
+
septum_mec.analysis.registration.store_notebook(action, "20_cell_count.ipynb")
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+
In [ ]:
+
+
+
 
+
+ +
+
+
+ +
+
+
+ + + + + + diff --git a/actions/cell-count/data/20_cell_count.ipynb b/actions/cell-count/data/20_cell_count.ipynb new file mode 100644 index 000000000..301345394 --- /dev/null +++ b/actions/cell-count/data/20_cell_count.ipynb @@ -0,0 +1,517 @@ +{ + "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": [ + "13:30:10 [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", + "# import seaborn as sns\n", + "from distutils.dir_util import copy_tree\n", + "from neo import SpikeTrain\n", + "import scipy\n", + "\n", + "from tqdm.notebook import tqdm_notebook as tqdm\n", + "tqdm.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, despine" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "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\") / \"cell-count\"\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": [ + "identification_action = actions['identify-neurons']\n", + "sessions = pd.read_csv(identification_action.data_path('sessions'))\n", + "units = pd.read_csv(identification_action.data_path('units'))\n", + "session_units = pd.merge(sessions, units, on='action')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "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": [ + "statistics_action = actions['calculate-statistics']\n", + "shuffling = actions['shuffling']\n", + "\n", + "statistics_results = pd.read_csv(statistics_action.data_path('results'))\n", + "statistics_results = session_units.merge(statistics_results, how='left')\n", + "quantiles_95 = pd.read_csv(shuffling.data_path('quantiles_95'))\n", + "action_columns = ['action', 'channel_group', 'unit_name']\n", + "data = pd.merge(statistics_results, quantiles_95, on=action_columns, suffixes=(\"\", \"_threshold\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "data['unit_day'] = data.apply(lambda x: str(x.unit_idnum) + '_' + x.action.split('-')[1], axis=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "data = data.merge(stim_results, how='left')" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "waveform_action = actions['waveform-analysis']\n", + "waveform_results = pd.read_csv(waveform_action.data_path('results')).drop('template', axis=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "data = data.merge(waveform_results, how='left')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "colors = ['#d95f02','#e7298a']\n", + "labels = ['11 Hz', '30 HZ']\n", + "queries = ['frequency==11', 'frequency==30']" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "data.bs = data.bs.astype(bool)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "data.loc[data.eval('t_i_peak == t_i_peak and not bs'), 'ns_inhibited'] = True\n", + "data.ns_inhibited.fillna(False, inplace=True)\n", + "\n", + "data.loc[data.eval('t_i_peak != t_i_peak and not bs'), 'ns_not_inhibited'] = True\n", + "data.ns_not_inhibited.fillna(False, inplace=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Number of sessions above threshold 194\n", + "Number of animals 4\n" + ] + } + ], + "source": [ + "query = (\n", + " 'gridness > gridness_threshold and '\n", + " 'information_rate > information_rate_threshold and '\n", + " 'gridness > .2 and '\n", + " 'average_rate < 25'\n", + ")\n", + "sessions_above_threshold = data.query(query)\n", + "print(\"Number of sessions above threshold\", len(sessions_above_threshold))\n", + "print(\"Number of animals\", len(sessions_above_threshold.groupby(['entity'])))" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Number of gridcells 139\n", + "Number of gridcell recordings 231\n", + "Number of animals 4\n" + ] + } + ], + "source": [ + "gridcell_sessions = data[data.unit_day.isin(sessions_above_threshold.unit_day.values)]\n", + "print(\"Number of gridcells\", gridcell_sessions.unit_idnum.nunique())\n", + "print(\"Number of gridcell recordings\", len(gridcell_sessions))\n", + "print(\"Number of animals\", len(gridcell_sessions.groupby(['entity'])))" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [], + "source": [ + "data.loc[:,'gridcell'] = np.nan\n", + "data['gridcell'] = data.isin(gridcell_sessions)\n", + "\n", + "data.loc[data.eval('not gridcell and bs'), 'bs_not_gridcell'] = True\n", + "data.bs_not_gridcell.fillna(False, inplace=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GridcellBS not gridcellNSiNSni
entity
1833941651652
18341421647
18391970115
18498229823
\n", + "
" + ], + "text/plain": [ + " Gridcell BS not gridcell NSi NSni\n", + "entity \n", + "1833 94 165 16 52\n", + "1834 14 216 4 7\n", + "1839 19 70 11 5\n", + "1849 8 229 8 23" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "table = pd.DataFrame()\n", + "table['Gridcell'] = data.drop_duplicates('unit_idnum').query('gridcell').groupby('entity')['action'].count()\n", + "table['BS not gridcell'] = data.drop_duplicates('unit_idnum').query('bs_not_gridcell').groupby('entity')['action'].count()\n", + "table['NSi'] = data.drop_duplicates('unit_idnum').query('ns_inhibited').groupby('entity')['action'].count()\n", + "table['NSni'] = data.drop_duplicates('unit_idnum').query('ns_not_inhibited').groupby('entity')['action'].count()\n", + "table" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Store results in Expipe action" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [], + "source": [ + "action = project.require_action(\"cell-count\")" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['/media/storage/expipe/septum-mec/actions/stimulus-response/data/data/times.feather',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/data/psth.feather',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_not_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-nsi-ns.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_not_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-bs_not_gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-bs_not_gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/response-probability-gc-ns-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-bs_not_gridcell-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_inhibited-stim-mec.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-gridcell.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_e_peak-ns_not_inhibited.svg',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-bs_not_gridcell-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_e_peak-ns_not_inhibited.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-p_i_peak-ns_inhibited-stim-mec.png',\n", + " '/media/storage/expipe/septum-mec/actions/stimulus-response/data/figures/histogram-t_i_peak-ns_inhibited.png']" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "copy_tree(output_path, str(action.data_path()))" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [], + "source": [ + "septum_mec.analysis.registration.store_notebook(action, \"20_cell_count.ipynb\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.6.8" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/actions/cell-count/data/statistics/counts.csv b/actions/cell-count/data/statistics/counts.csv new file mode 100644 index 000000000..eec83b9c5 --- /dev/null +++ b/actions/cell-count/data/statistics/counts.csv @@ -0,0 +1,5 @@ +entity,Gridcell,BS not gridcell,NSi,NSni +1833,94,165,16,52 +1834,14,216,4,7 +1839,19,70,11,5 +1849,8,229,8,23 diff --git a/actions/cell-count/data/statistics/counts.tex b/actions/cell-count/data/statistics/counts.tex new file mode 100644 index 000000000..493b90d0a --- /dev/null +++ b/actions/cell-count/data/statistics/counts.tex @@ -0,0 +1,11 @@ +\begin{tabular}{lrrrr} +\toprule +{} & Gridcell & BS not gridcell & NSi & NSni \\ +entity & & & & \\ +\midrule +1833 & 94 & 165 & 16 & 52 \\ +1834 & 14 & 216 & 4 & 7 \\ +1839 & 19 & 70 & 11 & 5 \\ +1849 & 8 & 229 & 8 & 23 \\ +\bottomrule +\end{tabular}