{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example behavior session\n", "The following example shows how to access behavioral data for a given mouse across sessions\n", "\n", "The following assumes that the AllenSDK has been installed in your environment. If not, run:\n", "\n", " pip install allensdk" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "allensdk version 2.10.2 or higher is required, you have 2.10.2 installed\n" ] } ], "source": [ "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import os\n", "import numpy as np\n", "import pandas as pd\n", "pd.set_option('display.max_columns', 500)\n", "\n", "import allensdk.brain_observatory.behavior.behavior_project_cache as bpc\n", "\n", "import allensdk\n", "import pkg_resources\n", "print('allensdk version 2.10.2 or higher is required, you have {} installed'.format(pkg_resources.get_distribution(\"allensdk\").version))" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.core.display import display, HTML\n", "display(HTML(\"\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## load cache, get behavior session table\n", "This will set a location on your local drive to cache NWB files. \n", "Then a table of all behavior sessions will be loaded. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# choose a location on your file system to cache NWB files as they are loaded:\n", "my_cache_dir = A_PATH_TO_SOME_LOCAL_FOLDER\n", "\n", "bc = bpc.VisualBehaviorOphysProjectCache.from_s3_cache(cache_dir=my_cache_dir)\n", " \n", "behavior_session_table = bc.get_behavior_session_table() " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## view a sample of the behavior session table\n", "The `behavior_session_table` is a Pandas DataFrame with one row for every session and a collection of informative columns. We can view 10 randomly selected rows of the table using the Pandas `sample` command. \n", "It's important to note that this table contains every session, including sessions performed on a two-photon imaging rig (`session_type` starts with `OPHYS_`) and pre-imaging (aka 'training') sessions, (`session_type` starts with `TRAINING_`)." ] }, { "cell_type": "code", "execution_count": 5, "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", " \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", " \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", " \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", " \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", " \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", "
equipment_namefull_genotypemouse_idreporter_linedriver_linesexage_in_dayssession_typecre_lineindicatorsession_numberprior_exposures_to_session_typeprior_exposures_to_image_setprior_exposures_to_omissionsophys_session_idophys_experiment_idophys_container_idproject_codedate_of_acquisitionfile_id
behavior_session_id
939977516BEH.B-Box6Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt476970Ai148(TIT2L-GC6f-ICL-tTA2)[Sst-IRES-Cre]M97.0TRAINING_1_gratingsSst-IRES-CreGCaMP6fNaN7NaN0NaNNaNNaNNaN2019-09-05 12:52:50.0801.085374e+09
966814252BEH.F-Box4Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt482853Ai148(TIT2L-GC6f-ICL-tTA2)[Sst-IRES-Cre]M106.0TRAINING_5_images_A_handoff_readySst-IRES-CreGCaMP6fNaN1NaN0NaNNaNNaNNaN2019-10-14 13:51:16.7481.081756e+09
904950235BEH.G-Box4Vip-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt467953Ai148(TIT2L-GC6f-ICL-tTA2)[Vip-IRES-Cre]M87.0TRAINING_1_gratingsVip-IRES-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-07-12 15:08:08.6201.085371e+09
857612105BEH.B-Box5Vip-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt435431Ai148(TIT2L-GC6f-ICL-tTA2)[Vip-IRES-Cre]M160.0TRAINING_4_images_A_trainingVip-IRES-CreGCaMP6fNaN14NaN0NaNNaNNaNNaN2019-04-25 15:13:52.9141.081601e+09
935601725CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...459777Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]F175.0OPHYS_0_images_A_habituationSlc17a7-IRES2-CreGCaMP6f0.033.00NaNNaNNaNNaN2019-08-30 08:56:11.5491.085370e+09
880191852BEH.B-Box5Vip-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt453989Ai148(TIT2L-GC6f-ICL-tTA2)[Vip-IRES-Cre]M115.0TRAINING_2_gratings_flashedVip-IRES-CreGCaMP6fNaN13NaN0NaNNaNNaNNaN2019-06-03 12:47:43.0791.081624e+09
972527218BEH.D-Box6Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt476970Ai148(TIT2L-GC6f-ICL-tTA2)[Sst-IRES-Cre]M146.0TRAINING_5_images_B_handoff_lapsedSst-IRES-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-10-24 11:43:27.8011.081760e+09
1041490593CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...513626Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M211.0OPHYS_1_images_BSlc17a7-IRES2-CreGCaMP6f1.003.00NaNNaNNaNNaN2020-08-07 11:51:28.6811.081782e+09
868653129BEH.B-Box3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...456916Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]F83.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-05-15 11:56:15.8791.085367e+09
913694953BEH.F-Box2Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt470784Ai148(TIT2L-GC6f-ICL-tTA2)[Sst-IRES-Cre]F91.0TRAINING_1_gratingsSst-IRES-CreGCaMP6fNaN4NaN0NaNNaNNaNNaN2019-07-29 09:23:40.3481.085373e+09
\n", "
" ], "text/plain": [ " equipment_name \\\n", "behavior_session_id \n", "939977516 BEH.B-Box6 \n", "966814252 BEH.F-Box4 \n", "904950235 BEH.G-Box4 \n", "857612105 BEH.B-Box5 \n", "935601725 CAM2P.3 \n", "880191852 BEH.B-Box5 \n", "972527218 BEH.D-Box6 \n", "1041490593 CAM2P.3 \n", "868653129 BEH.B-Box3 \n", "913694953 BEH.F-Box2 \n", "\n", " full_genotype \\\n", "behavior_session_id \n", "939977516 Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "966814252 Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "904950235 Vip-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "857612105 Vip-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "935601725 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "880191852 Vip-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "972527218 Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "1041490593 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "868653129 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "913694953 Sst-IRES-Cre/wt;Ai148(TIT2L-GC6f-ICL-tTA2)/wt \n", "\n", " mouse_id reporter_line \\\n", "behavior_session_id \n", "939977516 476970 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "966814252 482853 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "904950235 467953 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "857612105 435431 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "935601725 459777 Ai93(TITL-GCaMP6f) \n", "880191852 453989 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "972527218 476970 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "1041490593 513626 Ai93(TITL-GCaMP6f) \n", "868653129 456916 Ai93(TITL-GCaMP6f) \n", "913694953 470784 Ai148(TIT2L-GC6f-ICL-tTA2) \n", "\n", " driver_line sex age_in_days \\\n", "behavior_session_id \n", "939977516 [Sst-IRES-Cre] M 97.0 \n", "966814252 [Sst-IRES-Cre] M 106.0 \n", "904950235 [Vip-IRES-Cre] M 87.0 \n", "857612105 [Vip-IRES-Cre] M 160.0 \n", "935601725 [Slc17a7-IRES2-Cre, Camk2a-tTA] F 175.0 \n", "880191852 [Vip-IRES-Cre] M 115.0 \n", "972527218 [Sst-IRES-Cre] M 146.0 \n", "1041490593 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 211.0 \n", "868653129 [Slc17a7-IRES2-Cre, Camk2a-tTA] F 83.0 \n", "913694953 [Sst-IRES-Cre] F 91.0 \n", "\n", " session_type cre_line \\\n", "behavior_session_id \n", "939977516 TRAINING_1_gratings Sst-IRES-Cre \n", "966814252 TRAINING_5_images_A_handoff_ready Sst-IRES-Cre \n", "904950235 TRAINING_1_gratings Vip-IRES-Cre \n", "857612105 TRAINING_4_images_A_training Vip-IRES-Cre \n", "935601725 OPHYS_0_images_A_habituation Slc17a7-IRES2-Cre \n", "880191852 TRAINING_2_gratings_flashed Vip-IRES-Cre \n", "972527218 TRAINING_5_images_B_handoff_lapsed Sst-IRES-Cre \n", "1041490593 OPHYS_1_images_B Slc17a7-IRES2-Cre \n", "868653129 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "913694953 TRAINING_1_gratings Sst-IRES-Cre \n", "\n", " indicator session_number \\\n", "behavior_session_id \n", "939977516 GCaMP6f NaN \n", "966814252 GCaMP6f NaN \n", "904950235 GCaMP6f NaN \n", "857612105 GCaMP6f NaN \n", "935601725 GCaMP6f 0.0 \n", "880191852 GCaMP6f NaN \n", "972527218 GCaMP6f NaN \n", "1041490593 GCaMP6f 1.0 \n", "868653129 GCaMP6f NaN \n", "913694953 GCaMP6f NaN \n", "\n", " prior_exposures_to_session_type \\\n", "behavior_session_id \n", "939977516 7 \n", "966814252 1 \n", "904950235 2 \n", "857612105 14 \n", "935601725 3 \n", "880191852 13 \n", "972527218 2 \n", "1041490593 0 \n", "868653129 2 \n", "913694953 4 \n", "\n", " prior_exposures_to_image_set \\\n", "behavior_session_id \n", "939977516 NaN \n", "966814252 NaN \n", "904950235 NaN \n", "857612105 NaN \n", "935601725 3.0 \n", "880191852 NaN \n", "972527218 NaN \n", "1041490593 3.0 \n", "868653129 NaN \n", "913694953 NaN \n", "\n", " prior_exposures_to_omissions ophys_session_id \\\n", "behavior_session_id \n", "939977516 0 NaN \n", "966814252 0 NaN \n", "904950235 0 NaN \n", "857612105 0 NaN \n", "935601725 0 NaN \n", "880191852 0 NaN \n", "972527218 0 NaN \n", "1041490593 0 NaN \n", "868653129 0 NaN \n", "913694953 0 NaN \n", "\n", " ophys_experiment_id ophys_container_id project_code \\\n", "behavior_session_id \n", "939977516 NaN NaN NaN \n", "966814252 NaN NaN NaN \n", "904950235 NaN NaN NaN \n", "857612105 NaN NaN NaN \n", "935601725 NaN NaN NaN \n", "880191852 NaN NaN NaN \n", "972527218 NaN NaN NaN \n", "1041490593 NaN NaN NaN \n", "868653129 NaN NaN NaN \n", "913694953 NaN NaN NaN \n", "\n", " date_of_acquisition file_id \n", "behavior_session_id \n", "939977516 2019-09-05 12:52:50.080 1.085374e+09 \n", "966814252 2019-10-14 13:51:16.748 1.081756e+09 \n", "904950235 2019-07-12 15:08:08.620 1.085371e+09 \n", "857612105 2019-04-25 15:13:52.914 1.081601e+09 \n", "935601725 2019-08-30 08:56:11.549 1.085370e+09 \n", "880191852 2019-06-03 12:47:43.079 1.081624e+09 \n", "972527218 2019-10-24 11:43:27.801 1.081760e+09 \n", "1041490593 2020-08-07 11:51:28.681 1.081782e+09 \n", "868653129 2019-05-15 11:56:15.879 1.085367e+09 \n", "913694953 2019-07-29 09:23:40.348 1.085373e+09 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "behavior_session_table.sample(10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## randomly select one mouse\n", "We'll choose one mouse id from the full list of unique mouse IDs in the dataset" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "445002" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.random.seed(5)\n", "mouse_id = np.random.choice(behavior_session_table['mouse_id'].unique())\n", "mouse_id" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## query the full behavior sessions table for all sessions that this mouse performed\n", "This will return a subset of the full `behavior_session_table` in which the mouse_id matches our `mouse_id` variable (mouse 445002). The table should be returned in order of date of acquisition, but we'll call use the Pandas command `sort_values(by = 'date_of_acquisition')` just to be sure. \n", "\n", "What we then see is a table that has metadata for every session performed by this mouse, in sequential order. The `equipment_name` column tells us where the session was run on that day and the `session_type` column tells us the name of the session type. See the technical white paper for a description of the progression of stages.\n", "\n", "For this mouse, we can see that it progressed through a series of training stages starting on 3/15/2019 in behavior training boxes `BEH.B-Box3` and `BEH.B-Box1`.\n", "\n", "On 4/1/2019, it reached the `TRAINING_5_images_A_handoff_ready`, which meant that it was ready for transition to an imaging rig as soon as space became available. \n", "\n", "On 4/4/2019, it was transitioned to ophys rig `CAM2P.3`, where it then underwent three days of habituation without imaging. This is evidenced by the fact that the session type for 4/4/2019, 4/5/2019, and 4/8/2019 was `OPHYS_0_images_A_habituation` and there was no associated `ophys_session_id`.\n", "\n", "The first day of imaging for this mouse was on 4/9/2019, with `session_type = OPHYS_1_images_A`.\n", "\n", "Note that this mouse has two `OPHYS_5_images_B_passive` sessions, the first taken in order (immediately after `OPHYS_4_images_B`), and second taken at the end of the sequence. The first `OPHYS_5_images_B_passive` does not have an `ophys_session_id` associated with it. This is likely due to that first session failing to meet quality control standards and being excluded from the dataset. The second `OPHYS_5_images_B_passive` was likely a retake, taken after the first was identified as having been failed. \n", "\n", "In general, ophys behavior sessions that do not have associated ophys_session_ids are sessions for which the ophys data has been removed do to failure to meet quality control standards." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "scrolled": false }, "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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
equipment_namefull_genotypemouse_idreporter_linedriver_linesexage_in_dayssession_typecre_lineindicatorsession_numberprior_exposures_to_session_typeprior_exposures_to_image_setprior_exposures_to_omissionsophys_session_idophys_experiment_idophys_container_idproject_codedate_of_acquisitionfile_id
behavior_session_id
837658854BEH.B-Box3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M72.0TRAINING_0_gratings_autorewards_15minSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-15 14:49:24.0151.085362e+09
838515247BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M75.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-18 13:44:01.4741.085362e+09
839219841BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M76.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN1NaN0NaNNaNNaNNaN2019-03-19 12:50:12.0681.085362e+09
839565422BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M77.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-03-20 13:16:44.4611.085362e+09
839912316BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M78.0TRAINING_2_gratings_flashedSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-21 12:54:25.3881.081589e+09
840581827BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M79.0TRAINING_2_gratings_flashedSlc17a7-IRES2-CreGCaMP6fNaN1NaN0NaNNaNNaNNaN2019-03-22 12:56:37.1621.081589e+09
841426832BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M82.0TRAINING_3_images_A_10uL_rewardSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-25 13:33:53.2751.081589e+09
841827774BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M83.0TRAINING_3_images_A_10uL_rewardSlc17a7-IRES2-CreGCaMP6fNaN1NaN0NaNNaNNaNNaN2019-03-26 12:43:01.4701.081590e+09
842385277BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M84.0TRAINING_3_images_A_10uL_rewardSlc17a7-IRES2-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-03-27 12:13:04.9231.081591e+09
842819933BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M85.0TRAINING_4_images_A_trainingSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-28 12:11:36.4131.081591e+09
843400453BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M86.0TRAINING_5_images_A_epilogueSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-29 13:03:16.0291.081592e+09
844199758BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M89.0TRAINING_5_images_A_handoff_readySlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-04-01 11:59:06.0261.081591e+09
844908261BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M90.0TRAINING_5_images_A_handoff_readySlc17a7-IRES2-CreGCaMP6fNaN1NaN0NaNNaNNaNNaN2019-04-02 12:34:16.1701.081592e+09
845572044BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M91.0TRAINING_5_images_A_handoff_readySlc17a7-IRES2-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-04-03 12:16:13.5221.081592e+09
846331423CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M92.0OPHYS_0_images_A_habituationSlc17a7-IRES2-CreGCaMP6f0.000.00NaNNaNNaNNaN2019-04-04 13:13:13.3991.085362e+09
847036328CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M93.0OPHYS_0_images_A_habituationSlc17a7-IRES2-CreGCaMP6f0.011.00NaNNaNNaNNaN2019-04-05 12:47:32.4221.085362e+09
847874940CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M96.0OPHYS_0_images_A_habituationSlc17a7-IRES2-CreGCaMP6f0.022.00NaNNaNNaNNaN2019-04-08 13:27:21.0951.085362e+09
848613406CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M97.0OPHYS_1_images_ASlc17a7-IRES2-CreGCaMP6f1.003.00848264483.0[848697625][846215539]VisualBehavior2019-04-09 13:26:26.372NaN
849147676CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M98.0OPHYS_2_images_A_passiveSlc17a7-IRES2-CreGCaMP6f2.004.01848894137.0[849203565][846215539]VisualBehavior2019-04-10 13:34:39.264NaN
849651275CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M99.0OPHYS_3_images_ASlc17a7-IRES2-CreGCaMP6f3.005.02849597937.0[850479305][846215539]VisualBehavior2019-04-11 12:31:50.074NaN
850989832CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M100.0OPHYS_4_images_BSlc17a7-IRES2-CreGCaMP6f4.000.03850959102.0[851060467][846215539]VisualBehavior2019-04-12 13:30:27.946NaN
851773928CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M103.0OPHYS_5_images_B_passiveSlc17a7-IRES2-CreGCaMP6f5.001.04NaNNaNNaNNaN2019-04-15 12:20:00.1231.081596e+09
852451567CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M104.0OPHYS_6_images_BSlc17a7-IRES2-CreGCaMP6f6.002.05852326785.0[852691524][846215539]VisualBehavior2019-04-16 12:24:46.804NaN
855200229CAM2P.3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M110.0OPHYS_5_images_B_passiveSlc17a7-IRES2-CreGCaMP6f5.013.06855083235.0[855582961][846215539]VisualBehavior2019-04-22 09:01:33.022NaN
\n", "
" ], "text/plain": [ " equipment_name \\\n", "behavior_session_id \n", "837658854 BEH.B-Box3 \n", "838515247 BEH.B-Box1 \n", "839219841 BEH.B-Box1 \n", "839565422 BEH.B-Box1 \n", "839912316 BEH.B-Box1 \n", "840581827 BEH.B-Box1 \n", "841426832 BEH.B-Box1 \n", "841827774 BEH.B-Box1 \n", "842385277 BEH.B-Box1 \n", "842819933 BEH.B-Box1 \n", "843400453 BEH.B-Box1 \n", "844199758 BEH.B-Box1 \n", "844908261 BEH.B-Box1 \n", "845572044 BEH.B-Box1 \n", "846331423 CAM2P.3 \n", "847036328 CAM2P.3 \n", "847874940 CAM2P.3 \n", "848613406 CAM2P.3 \n", "849147676 CAM2P.3 \n", "849651275 CAM2P.3 \n", "850989832 CAM2P.3 \n", "851773928 CAM2P.3 \n", "852451567 CAM2P.3 \n", "855200229 CAM2P.3 \n", "\n", " full_genotype \\\n", "behavior_session_id \n", "837658854 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "838515247 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "839219841 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "839565422 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "839912316 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "840581827 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "841426832 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "841827774 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "842385277 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "842819933 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "843400453 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "844199758 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "844908261 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "845572044 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "846331423 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "847036328 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "847874940 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "848613406 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "849147676 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "849651275 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "850989832 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "851773928 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "852451567 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "855200229 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "\n", " mouse_id reporter_line \\\n", "behavior_session_id \n", "837658854 445002 Ai93(TITL-GCaMP6f) \n", "838515247 445002 Ai93(TITL-GCaMP6f) \n", "839219841 445002 Ai93(TITL-GCaMP6f) \n", "839565422 445002 Ai93(TITL-GCaMP6f) \n", "839912316 445002 Ai93(TITL-GCaMP6f) \n", "840581827 445002 Ai93(TITL-GCaMP6f) \n", "841426832 445002 Ai93(TITL-GCaMP6f) \n", "841827774 445002 Ai93(TITL-GCaMP6f) \n", "842385277 445002 Ai93(TITL-GCaMP6f) \n", "842819933 445002 Ai93(TITL-GCaMP6f) \n", "843400453 445002 Ai93(TITL-GCaMP6f) \n", "844199758 445002 Ai93(TITL-GCaMP6f) \n", "844908261 445002 Ai93(TITL-GCaMP6f) \n", "845572044 445002 Ai93(TITL-GCaMP6f) \n", "846331423 445002 Ai93(TITL-GCaMP6f) \n", "847036328 445002 Ai93(TITL-GCaMP6f) \n", "847874940 445002 Ai93(TITL-GCaMP6f) \n", "848613406 445002 Ai93(TITL-GCaMP6f) \n", "849147676 445002 Ai93(TITL-GCaMP6f) \n", "849651275 445002 Ai93(TITL-GCaMP6f) \n", "850989832 445002 Ai93(TITL-GCaMP6f) \n", "851773928 445002 Ai93(TITL-GCaMP6f) \n", "852451567 445002 Ai93(TITL-GCaMP6f) \n", "855200229 445002 Ai93(TITL-GCaMP6f) \n", "\n", " driver_line sex age_in_days \\\n", "behavior_session_id \n", "837658854 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 72.0 \n", "838515247 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 75.0 \n", "839219841 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 76.0 \n", "839565422 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 77.0 \n", "839912316 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 78.0 \n", "840581827 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 79.0 \n", "841426832 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 82.0 \n", "841827774 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 83.0 \n", "842385277 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 84.0 \n", "842819933 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 85.0 \n", "843400453 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 86.0 \n", "844199758 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 89.0 \n", "844908261 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 90.0 \n", "845572044 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 91.0 \n", "846331423 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 92.0 \n", "847036328 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 93.0 \n", "847874940 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 96.0 \n", "848613406 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 97.0 \n", "849147676 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 98.0 \n", "849651275 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 99.0 \n", "850989832 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 100.0 \n", "851773928 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 103.0 \n", "852451567 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 104.0 \n", "855200229 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 110.0 \n", "\n", " session_type cre_line \\\n", "behavior_session_id \n", "837658854 TRAINING_0_gratings_autorewards_15min Slc17a7-IRES2-Cre \n", "838515247 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "839219841 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "839565422 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "839912316 TRAINING_2_gratings_flashed Slc17a7-IRES2-Cre \n", "840581827 TRAINING_2_gratings_flashed Slc17a7-IRES2-Cre \n", "841426832 TRAINING_3_images_A_10uL_reward Slc17a7-IRES2-Cre \n", "841827774 TRAINING_3_images_A_10uL_reward Slc17a7-IRES2-Cre \n", "842385277 TRAINING_3_images_A_10uL_reward Slc17a7-IRES2-Cre \n", "842819933 TRAINING_4_images_A_training Slc17a7-IRES2-Cre \n", "843400453 TRAINING_5_images_A_epilogue Slc17a7-IRES2-Cre \n", "844199758 TRAINING_5_images_A_handoff_ready Slc17a7-IRES2-Cre \n", "844908261 TRAINING_5_images_A_handoff_ready Slc17a7-IRES2-Cre \n", "845572044 TRAINING_5_images_A_handoff_ready Slc17a7-IRES2-Cre \n", "846331423 OPHYS_0_images_A_habituation Slc17a7-IRES2-Cre \n", "847036328 OPHYS_0_images_A_habituation Slc17a7-IRES2-Cre \n", "847874940 OPHYS_0_images_A_habituation Slc17a7-IRES2-Cre \n", "848613406 OPHYS_1_images_A Slc17a7-IRES2-Cre \n", "849147676 OPHYS_2_images_A_passive Slc17a7-IRES2-Cre \n", "849651275 OPHYS_3_images_A Slc17a7-IRES2-Cre \n", "850989832 OPHYS_4_images_B Slc17a7-IRES2-Cre \n", "851773928 OPHYS_5_images_B_passive Slc17a7-IRES2-Cre \n", "852451567 OPHYS_6_images_B Slc17a7-IRES2-Cre \n", "855200229 OPHYS_5_images_B_passive Slc17a7-IRES2-Cre \n", "\n", " indicator session_number \\\n", "behavior_session_id \n", "837658854 GCaMP6f NaN \n", "838515247 GCaMP6f NaN \n", "839219841 GCaMP6f NaN \n", "839565422 GCaMP6f NaN \n", "839912316 GCaMP6f NaN \n", "840581827 GCaMP6f NaN \n", "841426832 GCaMP6f NaN \n", "841827774 GCaMP6f NaN \n", "842385277 GCaMP6f NaN \n", "842819933 GCaMP6f NaN \n", "843400453 GCaMP6f NaN \n", "844199758 GCaMP6f NaN \n", "844908261 GCaMP6f NaN \n", "845572044 GCaMP6f NaN \n", "846331423 GCaMP6f 0.0 \n", "847036328 GCaMP6f 0.0 \n", "847874940 GCaMP6f 0.0 \n", "848613406 GCaMP6f 1.0 \n", "849147676 GCaMP6f 2.0 \n", "849651275 GCaMP6f 3.0 \n", "850989832 GCaMP6f 4.0 \n", "851773928 GCaMP6f 5.0 \n", "852451567 GCaMP6f 6.0 \n", "855200229 GCaMP6f 5.0 \n", "\n", " prior_exposures_to_session_type \\\n", "behavior_session_id \n", "837658854 0 \n", "838515247 0 \n", "839219841 1 \n", "839565422 2 \n", "839912316 0 \n", "840581827 1 \n", "841426832 0 \n", "841827774 1 \n", "842385277 2 \n", "842819933 0 \n", "843400453 0 \n", "844199758 0 \n", "844908261 1 \n", "845572044 2 \n", "846331423 0 \n", "847036328 1 \n", "847874940 2 \n", "848613406 0 \n", "849147676 0 \n", "849651275 0 \n", "850989832 0 \n", "851773928 0 \n", "852451567 0 \n", "855200229 1 \n", "\n", " prior_exposures_to_image_set \\\n", "behavior_session_id \n", "837658854 NaN \n", "838515247 NaN \n", "839219841 NaN \n", "839565422 NaN \n", "839912316 NaN \n", "840581827 NaN \n", "841426832 NaN \n", "841827774 NaN \n", "842385277 NaN \n", "842819933 NaN \n", "843400453 NaN \n", "844199758 NaN \n", "844908261 NaN \n", "845572044 NaN \n", "846331423 0.0 \n", "847036328 1.0 \n", "847874940 2.0 \n", "848613406 3.0 \n", "849147676 4.0 \n", "849651275 5.0 \n", "850989832 0.0 \n", "851773928 1.0 \n", "852451567 2.0 \n", "855200229 3.0 \n", "\n", " prior_exposures_to_omissions ophys_session_id \\\n", "behavior_session_id \n", "837658854 0 NaN \n", "838515247 0 NaN \n", "839219841 0 NaN \n", "839565422 0 NaN \n", "839912316 0 NaN \n", "840581827 0 NaN \n", "841426832 0 NaN \n", "841827774 0 NaN \n", "842385277 0 NaN \n", "842819933 0 NaN \n", "843400453 0 NaN \n", "844199758 0 NaN \n", "844908261 0 NaN \n", "845572044 0 NaN \n", "846331423 0 NaN \n", "847036328 0 NaN \n", "847874940 0 NaN \n", "848613406 0 848264483.0 \n", "849147676 1 848894137.0 \n", "849651275 2 849597937.0 \n", "850989832 3 850959102.0 \n", "851773928 4 NaN \n", "852451567 5 852326785.0 \n", "855200229 6 855083235.0 \n", "\n", " ophys_experiment_id ophys_container_id project_code \\\n", "behavior_session_id \n", "837658854 NaN NaN NaN \n", "838515247 NaN NaN NaN \n", "839219841 NaN NaN NaN \n", "839565422 NaN NaN NaN \n", "839912316 NaN NaN NaN \n", "840581827 NaN NaN NaN \n", "841426832 NaN NaN NaN \n", "841827774 NaN NaN NaN \n", "842385277 NaN NaN NaN \n", "842819933 NaN NaN NaN \n", "843400453 NaN NaN NaN \n", "844199758 NaN NaN NaN \n", "844908261 NaN NaN NaN \n", "845572044 NaN NaN NaN \n", "846331423 NaN NaN NaN \n", "847036328 NaN NaN NaN \n", "847874940 NaN NaN NaN \n", "848613406 [848697625] [846215539] VisualBehavior \n", "849147676 [849203565] [846215539] VisualBehavior \n", "849651275 [850479305] [846215539] VisualBehavior \n", "850989832 [851060467] [846215539] VisualBehavior \n", "851773928 NaN NaN NaN \n", "852451567 [852691524] [846215539] VisualBehavior \n", "855200229 [855582961] [846215539] VisualBehavior \n", "\n", " date_of_acquisition file_id \n", "behavior_session_id \n", "837658854 2019-03-15 14:49:24.015 1.085362e+09 \n", "838515247 2019-03-18 13:44:01.474 1.085362e+09 \n", "839219841 2019-03-19 12:50:12.068 1.085362e+09 \n", "839565422 2019-03-20 13:16:44.461 1.085362e+09 \n", "839912316 2019-03-21 12:54:25.388 1.081589e+09 \n", "840581827 2019-03-22 12:56:37.162 1.081589e+09 \n", "841426832 2019-03-25 13:33:53.275 1.081589e+09 \n", "841827774 2019-03-26 12:43:01.470 1.081590e+09 \n", "842385277 2019-03-27 12:13:04.923 1.081591e+09 \n", "842819933 2019-03-28 12:11:36.413 1.081591e+09 \n", "843400453 2019-03-29 13:03:16.029 1.081592e+09 \n", "844199758 2019-04-01 11:59:06.026 1.081591e+09 \n", "844908261 2019-04-02 12:34:16.170 1.081592e+09 \n", "845572044 2019-04-03 12:16:13.522 1.081592e+09 \n", "846331423 2019-04-04 13:13:13.399 1.085362e+09 \n", "847036328 2019-04-05 12:47:32.422 1.085362e+09 \n", "847874940 2019-04-08 13:27:21.095 1.085362e+09 \n", "848613406 2019-04-09 13:26:26.372 NaN \n", "849147676 2019-04-10 13:34:39.264 NaN \n", "849651275 2019-04-11 12:31:50.074 NaN \n", "850989832 2019-04-12 13:30:27.946 NaN \n", "851773928 2019-04-15 12:20:00.123 1.081596e+09 \n", "852451567 2019-04-16 12:24:46.804 NaN \n", "855200229 2019-04-22 09:01:33.022 NaN " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "this_mouse_table = behavior_session_table.query('mouse_id == @mouse_id').sort_values(by = 'date_of_acquisition')\n", "# note that the following is functionally equivalent if you find the syntax easier to read: \n", "# this_mouse_table = behavior_session_table[behavior_session_table['mouse_id'] == mouse_id]\n", "this_mouse_table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## iterate over all sessions for this mouse, build a `behavior_session_dict` which will have one behavior session object for every session that this mouse performed, with the key being the `behavior_session_id`\n", "Note that this could take many minutes to complete. For each session in our new table, `this_mouse_table`, we are pulling the behavior session NWB file from AWS, opening it as a BehaviorSession object using the AllenSDK, and also caching a copy of the NWB file in the directory specified above as `my_cache_dir`. When the below cell completes, all behavior sessions for this mouse will be held in memory in the `behavior_session_dict` dictionary. \n", "\n", "If you were to re-run this cell a second time, it would access your cached NWB files instead of downloading them from AWS, allowing it to run substantially faster. \n", "\n", "It is important to note that we will only be loading the behavior data here, even for sessions that had corresponding imaging data. The `get_behavior_ophys_experiment` method would be used to get behavior *and* ophys data for ophys sessions. See additional sample notebooks for details." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "behavior_session_ids = this_mouse_table.index.values\n", "behavior_session_dict = {}\n", "for behavior_session_id in behavior_session_ids:\n", " behavior_session_dict[behavior_session_id] = bc.get_behavior_session(behavior_session_id)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## We can view all attributes of the behavior session object\n", "These are all of the methods and attributes available on the BehaviorSession object. Not all are explored in this notebook." ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "['behavior_session_id',\n", " 'get_performance_metrics',\n", " 'get_reward_rate',\n", " 'get_rolling_performance_df',\n", " 'licks',\n", " 'metadata',\n", " 'raw_running_speed',\n", " 'rewards',\n", " 'running_speed',\n", " 'stimulus_presentations',\n", " 'stimulus_templates',\n", " 'stimulus_timestamps',\n", " 'task_parameters',\n", " 'trials']" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "behavior_session_id = behavior_session_ids[-1]\n", "behavior_session_dict[behavior_session_id].list_data_attributes_and_methods()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that any attribute can be followed by a `?` in a Jupyter Notebook to see the docstring. For example, running the cell below will make a frame appear at the bottom of your browser with the docstring for the `running_speed` attribute." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "behavior_session = behavior_session_dict[behavior_session_id]\n", "behavior_session.running_speed?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### here are some basic task parameters\n", "We can see the session_type, which is `OPHYS_5_images_B_passive` and a number of other task parameters." ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'stimulus': 'images',\n", " 'task': 'change detection',\n", " 'response_window_sec': [0.15, 0.75],\n", " 'reward_volume': 0.007,\n", " 'omitted_flash_fraction': 0.05,\n", " 'blank_duration_sec': [0.5, 0.5],\n", " 'auto_reward_volume': 0.005,\n", " 'n_stimulus_frames': 69255,\n", " 'stimulus_duration_sec': 0.25,\n", " 'stimulus_distribution': 'geometric',\n", " 'session_type': 'OPHYS_5_images_B_passive'}" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "behavior_session_dict[behavior_session_id].task_parameters" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Look at some of the attributes of the last 'handoff ready session'\n", "We can filter the full table to get the last `TRAINING_5_images_A_handoff_ready` session. This would have been the last training session before the animal was subsequently handed off to the imaging team, after which all sessions were performed on a two-photon imaging rig." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "behavior_session_id = this_mouse_table.query('session_type == \"TRAINING_5_images_A_handoff_ready\"').index[-1]\n", "# note that the following is functionally equivalent if you find the syntax easier to read: \n", "# behavior_session_id = this_mouse_table[this_mouse_table['session_type'] == \"TRAINING_5_images_A_handoff_ready\"].index[-1]\n", "dataset = behavior_session_dict[behavior_session_id]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### stimuli" ] }, { "cell_type": "code", "execution_count": 13, "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", " \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", "
durationend_frameimage_indeximage_nameimage_setindexomittedstart_framestart_timestop_time
stimulus_presentations_id
00.25020818000.00im065Natural_Images_Lum_Matched_set_training_2017.0...0False17985.0300.001180300.251388
10.25022818045.00im065Natural_Images_Lum_Matched_set_training_2017.0...1False18030.0300.751814301.002042
20.25025918090.00im065Natural_Images_Lum_Matched_set_training_2017.0...2False18075.0301.502388301.752647
30.25027718136.00im065Natural_Images_Lum_Matched_set_training_2017.0...3False18121.0302.269753302.520030
40.25019918181.00im065Natural_Images_Lum_Matched_set_training_2017.0...4False18166.0303.020392303.270591
\n", "
" ], "text/plain": [ " duration end_frame image_index image_name \\\n", "stimulus_presentations_id \n", "0 0.250208 18000.0 0 im065 \n", "1 0.250228 18045.0 0 im065 \n", "2 0.250259 18090.0 0 im065 \n", "3 0.250277 18136.0 0 im065 \n", "4 0.250199 18181.0 0 im065 \n", "\n", " image_set \\\n", "stimulus_presentations_id \n", "0 Natural_Images_Lum_Matched_set_training_2017.0... \n", "1 Natural_Images_Lum_Matched_set_training_2017.0... \n", "2 Natural_Images_Lum_Matched_set_training_2017.0... \n", "3 Natural_Images_Lum_Matched_set_training_2017.0... \n", "4 Natural_Images_Lum_Matched_set_training_2017.0... \n", "\n", " index omitted start_frame start_time stop_time \n", "stimulus_presentations_id \n", "0 0 False 17985.0 300.001180 300.251388 \n", "1 1 False 18030.0 300.751814 301.002042 \n", "2 2 False 18075.0 301.502388 301.752647 \n", "3 3 False 18121.0 302.269753 302.520030 \n", "4 4 False 18166.0 303.020392 303.270591 " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset.stimulus_presentations.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### licks" ] }, { "cell_type": "code", "execution_count": 14, "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", "
timestampsframe
12401570.28319094138
470722.88930943337
503780.27080446777
12521580.99216694780
12571581.72611194824
\n", "
" ], "text/plain": [ " timestamps frame\n", "1240 1570.283190 94138\n", "470 722.889309 43337\n", "503 780.270804 46777\n", "1252 1580.992166 94780\n", "1257 1581.726111 94824" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset.licks.sample(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### rewards" ] }, { "cell_type": "code", "execution_count": 15, "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", "
volumetimestampsautorewarded
1000.0072041.578365False
290.007813.631992False
60.007401.736694False
240.007720.820943False
250.007761.721954False
\n", "
" ], "text/plain": [ " volume timestamps autorewarded\n", "100 0.007 2041.578365 False\n", "29 0.007 813.631992 False\n", "6 0.007 401.736694 False\n", "24 0.007 720.820943 False\n", "25 0.007 761.721954 False" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset.rewards.sample(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### running data" ] }, { "cell_type": "code", "execution_count": 16, "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", "
timestampsspeed
00.0000000.010719
10.016554-0.034077
20.033231-0.079193
30.049912-0.121338
40.067623-0.156735
\n", "
" ], "text/plain": [ " timestamps speed\n", "0 0.000000 0.010719\n", "1 0.016554 -0.034077\n", "2 0.033231 -0.079193\n", "3 0.049912 -0.121338\n", "4 0.067623 -0.156735" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset.running_speed.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### we can make a simple plot where we combine together running, licking and stimuli" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### First, add a column to the stimulus_presentations table that assigns a unique color to every stimulus" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "unique_stimuli = [stimulus for stimulus in dataset.stimulus_presentations['image_name'].unique()]\n", "colormap = {image_name: sns.color_palette()[image_number] for image_number, image_name in enumerate(np.sort(unique_stimuli))}\n", "dataset.stimulus_presentations['color'] = dataset.stimulus_presentations['image_name'].map(lambda image_name: colormap[image_name])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### now make some simple plotting functions to plot these datastreams" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "def plot_running(ax, initial_time, final_time):\n", " '''\n", " a simple function to plot running speed between two specified times on a specified axis\n", " inputs:\n", " ax: axis on which to plot\n", " intial_time: initial time to plot from\n", " final_time: final time to plot to\n", " '''\n", " running_sample = dataset.running_speed.query('timestamps >= @initial_time and timestamps <= @final_time')\n", " ax.plot(\n", " running_sample['timestamps'],\n", " running_sample['speed']\n", " )\n", "\n", "def plot_licks(ax, initial_time, final_time):\n", " '''\n", " a simple function to plot licks as dots between two specified times on a specified axis\n", " inputs:\n", " ax: axis on which to plot\n", " intial_time: initial time to plot from\n", " final_time: final time to plot to\n", " '''\n", " licking_sample = dataset.licks.query('timestamps >= @initial_time and timestamps <= @final_time')\n", " ax.plot(\n", " licking_sample['timestamps'],\n", " np.zeros_like(licking_sample['timestamps']),\n", " marker = 'o',\n", " color = 'black',\n", " linestyle = 'none'\n", " )\n", " \n", "def plot_rewards(ax, initial_time, final_time):\n", " '''\n", " a simple function to plot rewards between two specified times as blue diamonds on a specified axis\n", " inputs:\n", " ax: axis on which to plot\n", " intial_time: initial time to plot from\n", " final_time: final time to plot to\n", " '''\n", " rewards_sample = dataset.rewards.query('timestamps >= @initial_time and timestamps <= @final_time')\n", " ax.plot(\n", " rewards_sample['timestamps'],\n", " np.zeros_like(rewards_sample['timestamps']),\n", " marker = 'd',\n", " color = 'blue',\n", " linestyle = 'none',\n", " markersize = 12,\n", " alpha = 0.5\n", " )\n", " \n", "def plot_stimuli(ax, ti, tf):\n", " '''\n", " a simple function to plot stimuli as colored vertical spans on a s\n", " inputs:\n", " ax: axis on which to plot\n", " intial_time: initial time to plot from\n", " final_time: final time to plot to\n", " '''\n", " stimulus_presentations_sample = dataset.stimulus_presentations.query('stop_time >= @initial_time and start_time <= @final_time')\n", " for idx, stimulus in stimulus_presentations_sample.iterrows():\n", " ax.axvspan(stimulus['start_time'], stimulus['stop_time'], color=stimulus['color'], alpha=0.25)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### now make the plot" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "/* global mpl */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function () {\n", " if (typeof WebSocket !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof MozWebSocket !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert(\n", " 'Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.'\n", " );\n", " }\n", "};\n", "\n", "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = this.ws.binaryType !== undefined;\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById('mpl-warnings');\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent =\n", " 'This browser does not support binary websocket messages. ' +\n", " 'Performance may be slow.';\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = document.createElement('div');\n", " this.root.setAttribute('style', 'display: inline-block');\n", " this._root_extra_style(this.root);\n", "\n", " parent_element.appendChild(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message('supports_binary', { value: fig.supports_binary });\n", " fig.send_message('send_image_mode', {});\n", " if (fig.ratio !== 1) {\n", " fig.send_message('set_dpi_ratio', { dpi_ratio: fig.ratio });\n", " }\n", " fig.send_message('refresh', {});\n", " };\n", "\n", " this.imageObj.onload = function () {\n", " if (fig.image_mode === 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function () {\n", " fig.ws.close();\n", " };\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "};\n", "\n", "mpl.figure.prototype._init_header = function () {\n", " var titlebar = document.createElement('div');\n", " titlebar.classList =\n", " 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n", " var titletext = document.createElement('div');\n", " titletext.classList = 'ui-dialog-title';\n", " titletext.setAttribute(\n", " 'style',\n", " 'width: 100%; text-align: center; padding: 3px;'\n", " );\n", " titlebar.appendChild(titletext);\n", " this.root.appendChild(titlebar);\n", " this.header = titletext;\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._init_canvas = function () {\n", " var fig = this;\n", "\n", " var canvas_div = (this.canvas_div = document.createElement('div'));\n", " canvas_div.setAttribute(\n", " 'style',\n", " 'border: 1px solid #ddd;' +\n", " 'box-sizing: content-box;' +\n", " 'clear: both;' +\n", " 'min-height: 1px;' +\n", " 'min-width: 1px;' +\n", " 'outline: 0;' +\n", " 'overflow: hidden;' +\n", " 'position: relative;' +\n", " 'resize: both;'\n", " );\n", "\n", " function on_keyboard_event_closure(name) {\n", " return function (event) {\n", " return fig.key_event(event, name);\n", " };\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'keydown',\n", " on_keyboard_event_closure('key_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'keyup',\n", " on_keyboard_event_closure('key_release')\n", " );\n", "\n", " this._canvas_extra_style(canvas_div);\n", " this.root.appendChild(canvas_div);\n", "\n", " var canvas = (this.canvas = document.createElement('canvas'));\n", " canvas.classList.add('mpl-canvas');\n", " canvas.setAttribute('style', 'box-sizing: content-box;');\n", "\n", " this.context = canvas.getContext('2d');\n", "\n", " var backingStore =\n", " this.context.backingStorePixelRatio ||\n", " this.context.webkitBackingStorePixelRatio ||\n", " this.context.mozBackingStorePixelRatio ||\n", " this.context.msBackingStorePixelRatio ||\n", " this.context.oBackingStorePixelRatio ||\n", " this.context.backingStorePixelRatio ||\n", " 1;\n", "\n", " this.ratio = (window.devicePixelRatio || 1) / backingStore;\n", " if (this.ratio !== 1) {\n", " fig.send_message('set_dpi_ratio', { dpi_ratio: this.ratio });\n", " }\n", "\n", " var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n", " 'canvas'\n", " ));\n", " rubberband_canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'\n", " );\n", "\n", " var resizeObserver = new ResizeObserver(function (entries) {\n", " var nentries = entries.length;\n", " for (var i = 0; i < nentries; i++) {\n", " var entry = entries[i];\n", " var width, height;\n", " if (entry.contentBoxSize) {\n", " if (entry.contentBoxSize instanceof Array) {\n", " // Chrome 84 implements new version of spec.\n", " width = entry.contentBoxSize[0].inlineSize;\n", " height = entry.contentBoxSize[0].blockSize;\n", " } else {\n", " // Firefox implements old version of spec.\n", " width = entry.contentBoxSize.inlineSize;\n", " height = entry.contentBoxSize.blockSize;\n", " }\n", " } else {\n", " // Chrome <84 implements even older version of spec.\n", " width = entry.contentRect.width;\n", " height = entry.contentRect.height;\n", " }\n", "\n", " // Keep the size of the canvas and rubber band canvas in sync with\n", " // the canvas container.\n", " if (entry.devicePixelContentBoxSize) {\n", " // Chrome 84 implements new version of spec.\n", " canvas.setAttribute(\n", " 'width',\n", " entry.devicePixelContentBoxSize[0].inlineSize\n", " );\n", " canvas.setAttribute(\n", " 'height',\n", " entry.devicePixelContentBoxSize[0].blockSize\n", " );\n", " } else {\n", " canvas.setAttribute('width', width * fig.ratio);\n", " canvas.setAttribute('height', height * fig.ratio);\n", " }\n", " canvas.setAttribute(\n", " 'style',\n", " 'width: ' + width + 'px; height: ' + height + 'px;'\n", " );\n", "\n", " rubberband_canvas.setAttribute('width', width);\n", " rubberband_canvas.setAttribute('height', height);\n", "\n", " // And update the size in Python. We ignore the initial 0/0 size\n", " // that occurs as the element is placed into the DOM, which should\n", " // otherwise not happen due to the minimum size styling.\n", " if (width != 0 && height != 0) {\n", " fig.request_resize(width, height);\n", " }\n", " }\n", " });\n", " resizeObserver.observe(canvas_div);\n", "\n", " function on_mouse_event_closure(name) {\n", " return function (event) {\n", " return fig.mouse_event(event, name);\n", " };\n", " }\n", "\n", " rubberband_canvas.addEventListener(\n", " 'mousedown',\n", " on_mouse_event_closure('button_press')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'mouseup',\n", " on_mouse_event_closure('button_release')\n", " );\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband_canvas.addEventListener(\n", " 'mousemove',\n", " on_mouse_event_closure('motion_notify')\n", " );\n", "\n", " rubberband_canvas.addEventListener(\n", " 'mouseenter',\n", " on_mouse_event_closure('figure_enter')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'mouseleave',\n", " on_mouse_event_closure('figure_leave')\n", " );\n", "\n", " canvas_div.addEventListener('wheel', function (event) {\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " on_mouse_event_closure('scroll')(event);\n", " });\n", "\n", " canvas_div.appendChild(canvas);\n", " canvas_div.appendChild(rubberband_canvas);\n", "\n", " this.rubberband_context = rubberband_canvas.getContext('2d');\n", " this.rubberband_context.strokeStyle = '#000000';\n", "\n", " this._resize_canvas = function (width, height, forward) {\n", " if (forward) {\n", " canvas_div.style.width = width + 'px';\n", " canvas_div.style.height = height + 'px';\n", " }\n", " };\n", "\n", " // Disable right mouse context menu.\n", " this.rubberband_canvas.addEventListener('contextmenu', function (_e) {\n", " event.preventDefault();\n", " return false;\n", " });\n", "\n", " function set_focus() {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'mpl-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " continue;\n", " }\n", "\n", " var button = (fig.buttons[name] = document.createElement('button'));\n", " button.classList = 'mpl-widget';\n", " button.setAttribute('role', 'button');\n", " button.setAttribute('aria-disabled', 'false');\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", "\n", " var icon_img = document.createElement('img');\n", " icon_img.src = '_images/' + image + '.png';\n", " icon_img.srcset = '_images/' + image + '_large.png 2x';\n", " icon_img.alt = tooltip;\n", " button.appendChild(icon_img);\n", "\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " var fmt_picker = document.createElement('select');\n", " fmt_picker.classList = 'mpl-widget';\n", " toolbar.appendChild(fmt_picker);\n", " this.format_dropdown = fmt_picker;\n", "\n", " for (var ind in mpl.extensions) {\n", " var fmt = mpl.extensions[ind];\n", " var option = document.createElement('option');\n", " option.selected = fmt === mpl.default_extension;\n", " option.innerHTML = fmt;\n", " fmt_picker.appendChild(option);\n", " }\n", "\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "};\n", "\n", "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n", " // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n", " // which will in turn request a refresh of the image.\n", " this.send_message('resize', { width: x_pixels, height: y_pixels });\n", "};\n", "\n", "mpl.figure.prototype.send_message = function (type, properties) {\n", " properties['type'] = type;\n", " properties['figure_id'] = this.id;\n", " this.ws.send(JSON.stringify(properties));\n", "};\n", "\n", "mpl.figure.prototype.send_draw_message = function () {\n", " if (!this.waiting) {\n", " this.waiting = true;\n", " this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " var format_dropdown = fig.format_dropdown;\n", " var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n", " fig.ondownload(fig, format);\n", "};\n", "\n", "mpl.figure.prototype.handle_resize = function (fig, msg) {\n", " var size = msg['size'];\n", " if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n", " fig._resize_canvas(size[0], size[1], msg['forward']);\n", " fig.send_message('refresh', {});\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n", " var x0 = msg['x0'] / fig.ratio;\n", " var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n", " var x1 = msg['x1'] / fig.ratio;\n", " var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", " y1 = Math.floor(y1) + 0.5;\n", " var min_x = Math.min(x0, x1);\n", " var min_y = Math.min(y0, y1);\n", " var width = Math.abs(x1 - x0);\n", " var height = Math.abs(y1 - y0);\n", "\n", " fig.rubberband_context.clearRect(\n", " 0,\n", " 0,\n", " fig.canvas.width / fig.ratio,\n", " fig.canvas.height / fig.ratio\n", " );\n", "\n", " fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n", "};\n", "\n", "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n", " // Updates the figure title.\n", " fig.header.textContent = msg['label'];\n", "};\n", "\n", "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n", " var cursor = msg['cursor'];\n", " switch (cursor) {\n", " case 0:\n", " cursor = 'pointer';\n", " break;\n", " case 1:\n", " cursor = 'default';\n", " break;\n", " case 2:\n", " cursor = 'crosshair';\n", " break;\n", " case 3:\n", " cursor = 'move';\n", " break;\n", " }\n", " fig.rubberband_canvas.style.cursor = cursor;\n", "};\n", "\n", "mpl.figure.prototype.handle_message = function (fig, msg) {\n", " fig.message.textContent = msg['message'];\n", "};\n", "\n", "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n", " // Request the server to send over a new figure.\n", " fig.send_draw_message();\n", "};\n", "\n", "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n", " fig.image_mode = msg['mode'];\n", "};\n", "\n", "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n", " for (var key in msg) {\n", " if (!(key in fig.buttons)) {\n", " continue;\n", " }\n", " fig.buttons[key].disabled = !msg[key];\n", " fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n", " if (msg['mode'] === 'PAN') {\n", " fig.buttons['Pan'].classList.add('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " } else if (msg['mode'] === 'ZOOM') {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.add('active');\n", " } else {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " }\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Called whenever the canvas gets updated.\n", " this.send_message('ack', {});\n", "};\n", "\n", "// A function to construct a web socket function for onmessage handling.\n", "// Called in the figure constructor.\n", "mpl.figure.prototype._make_on_message_function = function (fig) {\n", " return function socket_on_message(evt) {\n", " if (evt.data instanceof Blob) {\n", " /* FIXME: We get \"Resource interpreted as Image but\n", " * transferred with MIME type text/plain:\" errors on\n", " * Chrome. But how to set the MIME type? It doesn't seem\n", " * to be part of the websocket stream */\n", " evt.data.type = 'image/png';\n", "\n", " /* Free the memory for the previous frames */\n", " if (fig.imageObj.src) {\n", " (window.URL || window.webkitURL).revokeObjectURL(\n", " fig.imageObj.src\n", " );\n", " }\n", "\n", " fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n", " evt.data\n", " );\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " } else if (\n", " typeof evt.data === 'string' &&\n", " evt.data.slice(0, 21) === 'data:image/png;base64'\n", " ) {\n", " fig.imageObj.src = evt.data;\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " }\n", "\n", " var msg = JSON.parse(evt.data);\n", " var msg_type = msg['type'];\n", "\n", " // Call the \"handle_{type}\" callback, which takes\n", " // the figure and JSON message as its only arguments.\n", " try {\n", " var callback = fig['handle_' + msg_type];\n", " } catch (e) {\n", " console.log(\n", " \"No handler for the '\" + msg_type + \"' message type: \",\n", " msg\n", " );\n", " return;\n", " }\n", "\n", " if (callback) {\n", " try {\n", " // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n", " callback(fig, msg);\n", " } catch (e) {\n", " console.log(\n", " \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n", " e,\n", " e.stack,\n", " msg\n", " );\n", " }\n", " }\n", " };\n", "};\n", "\n", "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n", "mpl.findpos = function (e) {\n", " //this section is from http://www.quirksmode.org/js/events_properties.html\n", " var targ;\n", " if (!e) {\n", " e = window.event;\n", " }\n", " if (e.target) {\n", " targ = e.target;\n", " } else if (e.srcElement) {\n", " targ = e.srcElement;\n", " }\n", " if (targ.nodeType === 3) {\n", " // defeat Safari bug\n", " targ = targ.parentNode;\n", " }\n", "\n", " // pageX,Y are the mouse positions relative to the document\n", " var boundingRect = targ.getBoundingClientRect();\n", " var x = e.pageX - (boundingRect.left + document.body.scrollLeft);\n", " var y = e.pageY - (boundingRect.top + document.body.scrollTop);\n", "\n", " return { x: x, y: y };\n", "};\n", "\n", "/*\n", " * return a copy of an object with only non-object keys\n", " * we need this to avoid circular references\n", " * http://stackoverflow.com/a/24161582/3208463\n", " */\n", "function simpleKeys(original) {\n", " return Object.keys(original).reduce(function (obj, key) {\n", " if (typeof original[key] !== 'object') {\n", " obj[key] = original[key];\n", " }\n", " return obj;\n", " }, {});\n", "}\n", "\n", "mpl.figure.prototype.mouse_event = function (event, name) {\n", " var canvas_pos = mpl.findpos(event);\n", "\n", " if (name === 'button_press') {\n", " this.canvas.focus();\n", " this.canvas_div.focus();\n", " }\n", "\n", " var x = canvas_pos.x * this.ratio;\n", " var y = canvas_pos.y * this.ratio;\n", "\n", " this.send_message(name, {\n", " x: x,\n", " y: y,\n", " button: event.button,\n", " step: event.step,\n", " guiEvent: simpleKeys(event),\n", " });\n", "\n", " /* This prevents the web browser from automatically changing to\n", " * the text insertion cursor when the button is pressed. We want\n", " * to control all of the cursor setting manually through the\n", " * 'cursor' event from matplotlib */\n", " event.preventDefault();\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n", " // Handle any extra behaviour associated with a key event\n", "};\n", "\n", "mpl.figure.prototype.key_event = function (event, name) {\n", " // Prevent repeat events\n", " if (name === 'key_press') {\n", " if (event.which === this._key) {\n", " return;\n", " } else {\n", " this._key = event.which;\n", " }\n", " }\n", " if (name === 'key_release') {\n", " this._key = null;\n", " }\n", "\n", " var value = '';\n", " if (event.ctrlKey && event.which !== 17) {\n", " value += 'ctrl+';\n", " }\n", " if (event.altKey && event.which !== 18) {\n", " value += 'alt+';\n", " }\n", " if (event.shiftKey && event.which !== 16) {\n", " value += 'shift+';\n", " }\n", "\n", " value += 'k';\n", " value += event.which.toString();\n", "\n", " this._key_event_extra(event, name);\n", "\n", " this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n", " if (name === 'download') {\n", " this.handle_save(this, null);\n", " } else {\n", " this.send_message('toolbar_button', { name: name });\n", " }\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", "\n", "mpl.default_extension = \"png\";/* global mpl */\n", "\n", "var comm_websocket_adapter = function (comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", " // object with the appropriate methods. Currently this is a non binary\n", " // socket, so there is still some room for performance tuning.\n", " var ws = {};\n", "\n", " ws.close = function () {\n", " comm.close();\n", " };\n", " ws.send = function (m) {\n", " //console.log('sending', m);\n", " comm.send(m);\n", " };\n", " // Register the callback with on_msg.\n", " comm.on_msg(function (msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data']);\n", " });\n", " return ws;\n", "};\n", "\n", "mpl.mpl_figure_comm = function (comm, msg) {\n", " // This is the function which gets called when the mpl process\n", " // starts-up an IPython Comm through the \"matplotlib\" channel.\n", "\n", " var id = msg.content.data.id;\n", " // Get hold of the div created by the display call when the Comm\n", " // socket was opened in Python.\n", " var element = document.getElementById(id);\n", " var ws_proxy = comm_websocket_adapter(comm);\n", "\n", " function ondownload(figure, _format) {\n", " window.open(figure.canvas.toDataURL());\n", " }\n", "\n", " var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n", "\n", " // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n", " // web socket which is closed, not our websocket->open comm proxy.\n", " ws_proxy.onopen();\n", "\n", " fig.parent_element = element;\n", " fig.cell_info = mpl.find_output_cell(\"
\");\n", " if (!fig.cell_info) {\n", " console.error('Failed to find cell for figure', id, fig);\n", " return;\n", " }\n", " fig.cell_info[0].output_area.element.one(\n", " 'cleared',\n", " { fig: fig },\n", " fig._remove_fig_handler\n", " );\n", "};\n", "\n", "mpl.figure.prototype.handle_close = function (fig, msg) {\n", " var width = fig.canvas.width / fig.ratio;\n", " fig.cell_info[0].output_area.element.off(\n", " 'cleared',\n", " fig._remove_fig_handler\n", " );\n", "\n", " // Update the output cell to use the data from the current canvas.\n", " fig.push_to_output();\n", " var dataURL = fig.canvas.toDataURL();\n", " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable();\n", " fig.parent_element.innerHTML =\n", " '';\n", " fig.close_ws(fig, msg);\n", "};\n", "\n", "mpl.figure.prototype.close_ws = function (fig, msg) {\n", " fig.send_message('closing', msg);\n", " // fig.ws.close()\n", "};\n", "\n", "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", " var width = this.canvas.width / this.ratio;\n", " var dataURL = this.canvas.toDataURL();\n", " this.cell_info[1]['text/html'] =\n", " '';\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Tell IPython that the notebook contents must change.\n", " IPython.notebook.set_dirty(true);\n", " this.send_message('ack', {});\n", " var fig = this;\n", " // Wait a second, then push the new image to the DOM so\n", " // that it is saved nicely (might be nice to debounce this).\n", " setTimeout(function () {\n", " fig.push_to_output();\n", " }, 1000);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'btn-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " var button;\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " continue;\n", " }\n", "\n", " button = fig.buttons[name] = document.createElement('button');\n", " button.classList = 'btn btn-default';\n", " button.href = '#';\n", " button.title = name;\n", " button.innerHTML = '';\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message pull-right';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "\n", " // Add the close button to the window.\n", " var buttongrp = document.createElement('div');\n", " buttongrp.classList = 'btn-group inline pull-right';\n", " button = document.createElement('button');\n", " button.classList = 'btn btn-mini btn-primary';\n", " button.href = '#';\n", " button.title = 'Stop Interaction';\n", " button.innerHTML = '';\n", " button.addEventListener('click', function (_evt) {\n", " fig.handle_close(fig, {});\n", " });\n", " button.addEventListener(\n", " 'mouseover',\n", " on_mouseover_closure('Stop Interaction')\n", " );\n", " buttongrp.appendChild(button);\n", " var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n", " titlebar.insertBefore(buttongrp, titlebar.firstChild);\n", "};\n", "\n", "mpl.figure.prototype._remove_fig_handler = function (event) {\n", " var fig = event.data.fig;\n", " fig.close_ws(fig, {});\n", "};\n", "\n", "mpl.figure.prototype._root_extra_style = function (el) {\n", " el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (el) {\n", " // this is important to make the div 'focusable\n", " el.setAttribute('tabindex', 0);\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " } else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (event, _name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager) {\n", " manager = IPython.keyboard_manager;\n", " }\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which === 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " fig.ondownload(fig, null);\n", "};\n", "\n", "mpl.find_output_cell = function (html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i = 0; i < ncells; i++) {\n", " var cell = cells[i];\n", " if (cell.cell_type === 'code') {\n", " for (var j = 0; j < cell.output_area.outputs.length; j++) {\n", " var data = cell.output_area.outputs[j];\n", " if (data.data) {\n", " // IPython >= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] === html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "};\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel !== null) {\n", " IPython.notebook.kernel.comm_manager.register_target(\n", " 'matplotlib',\n", " mpl.mpl_figure_comm\n", " );\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "initial_time = 775 # initial time for plot, in seconds\n", "final_time = 800 # final time for plot, in seconds\n", "fig, ax = plt.subplots(figsize = (15,5))\n", "plot_running(ax, initial_time, final_time)\n", "plot_licks(ax, initial_time, final_time)\n", "plot_rewards(ax, initial_time, final_time)\n", "plot_stimuli(ax, initial_time, final_time)\n", "\n", "ax.legend(['running speed', 'licks', 'rewards'])\n", "\n", "ax.set_ylabel('running speed (cm/s)')\n", "ax.set_xlabel('time in session (s)')\n", "ax.set_xlim(initial_time, final_time)\n", "ax.set_title('a short section of the session');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Above, we can see that stimuli were being delivered at a regular cadence (250 ms on, 500 ms off). There were changes to new stimuli at t = 778.6 and t = 793.7, as indicated by the change in the color of the bars. The mouse licked inside of the required response window following both stimulus changes and received a reward coincident with the first lick following the change. The subsequent licks are likely a result of the mouse consuming the water reward. There was also a brief bout of two licks, likely representing impulsivity, at t = 786.9." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### trials\n", "We can view attributes of every trial here. Below is a random sample of 5 trials" ] }, { "cell_type": "code", "execution_count": 20, "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", " \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", " \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", " \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", "
start_timestop_timelick_timesreward_timereward_volumehitfalse_alarmmissstimulus_changeabortedgocatchauto_rewardedcorrect_rejecttrial_lengthresponse_timechange_framechange_timeresponse_latencyinitial_image_namechange_image_name
trials_id
1331145.7772541148.362823[1147.8956996658817, 1148.0458577824757]NaN0.0FalseFalseFalseFalseTrueFalseFalseFalseFalse2.585569NaNNaNNaNNaNim065im065
62650.712128658.018251[]NaN0.0FalseFalseTrueTrueFalseTrueFalseFalseFalse7.306123NaN39191.0653.752495infim063im061
2391768.7662771771.885580[1771.5686300797388]NaN0.0FalseFalseFalseFalseTrueFalseFalseFalseFalse3.119302NaNNaNNaNNaNim066im066
4973736.6830523743.972490[]NaN0.0FalseFalseTrueTrueFalseTrueFalseFalseFalse7.289437NaN224193.03739.723400infim061im063
4633443.8875933451.193661[]NaN0.0FalseFalseTrueTrueFalseTrueFalseFalseFalse7.306068NaN206640.03446.927890infim062im065
\n", "
" ], "text/plain": [ " start_time stop_time lick_times \\\n", "trials_id \n", "133 1145.777254 1148.362823 [1147.8956996658817, 1148.0458577824757] \n", "62 650.712128 658.018251 [] \n", "239 1768.766277 1771.885580 [1771.5686300797388] \n", "497 3736.683052 3743.972490 [] \n", "463 3443.887593 3451.193661 [] \n", "\n", " reward_time reward_volume hit false_alarm miss \\\n", "trials_id \n", "133 NaN 0.0 False False False \n", "62 NaN 0.0 False False True \n", "239 NaN 0.0 False False False \n", "497 NaN 0.0 False False True \n", "463 NaN 0.0 False False True \n", "\n", " stimulus_change aborted go catch auto_rewarded \\\n", "trials_id \n", "133 False True False False False \n", "62 True False True False False \n", "239 False True False False False \n", "497 True False True False False \n", "463 True False True False False \n", "\n", " correct_reject trial_length response_time change_frame \\\n", "trials_id \n", "133 False 2.585569 NaN NaN \n", "62 False 7.306123 NaN 39191.0 \n", "239 False 3.119302 NaN NaN \n", "497 False 7.289437 NaN 224193.0 \n", "463 False 7.306068 NaN 206640.0 \n", "\n", " change_time response_latency initial_image_name change_image_name \n", "trials_id \n", "133 NaN NaN im065 im065 \n", "62 653.752495 inf im063 im061 \n", "239 NaN NaN im066 im066 \n", "497 3739.723400 inf im061 im063 \n", "463 3446.927890 inf im062 im065 " ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset.trials.sample(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### we can examine one trial in some detail. Let's randomly select a hit trial. \n", "Some things to note:\n", "* The trial started at 831.2635398912244 seconds (`start_time`) relative to the start of the session.\n", "* The stimulus changed from 'im063' (`intial_image_name`) to 'im069' (`change_image_name`) at t = 834.287206646593 seconds (`change_time`) relative to the start of the session.\n", "* The animal's first lick (`lick_times[0]`) and `response_time` was at t = 834.69975263 seconds relative to the start of the session.\n", "* The `response_latency`, which is `response_time` - `change_time`, was 0.41254598174464263 seconds.\n", "* A reward (`reward_time`) was delivered at 834.6997526283376 seconds relative to the start of the session. This was coincident with the first lick." ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'start_time': 831.2635398912244,\n", " 'stop_time': 838.5529783256352,\n", " 'lick_times': array([834.69975263, 834.81651755, 835.1001309 , 835.25021287,\n", " 835.40033855, 835.53378616, 835.68391515, 835.83403254,\n", " 836.01752922, 836.16765357, 836.33444306, 836.51795332,\n", " 836.6513857 ]),\n", " 'reward_time': 834.6997526283376,\n", " 'reward_volume': 0.007,\n", " 'hit': True,\n", " 'false_alarm': False,\n", " 'miss': False,\n", " 'stimulus_change': True,\n", " 'aborted': False,\n", " 'go': True,\n", " 'catch': False,\n", " 'auto_rewarded': False,\n", " 'correct_reject': False,\n", " 'trial_length': 7.28943843441084,\n", " 'response_time': 834.6997526283376,\n", " 'change_frame': 50014.0,\n", " 'change_time': 834.287206646593,\n", " 'response_latency': 0.41254598174464263,\n", " 'initial_image_name': 'im063',\n", " 'change_image_name': 'im069'}]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dataset.trials.query('hit').sample(random_state=0).to_dict('records')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## One useful method is the `get_performance_metrics` method, which returns some summary metrics on the session, derived from the 'rolling_performance_df'" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'trial_count': 516,\n", " 'go_trial_count': 285,\n", " 'catch_trial_count': 41,\n", " 'hit_trial_count': 112,\n", " 'miss_trial_count': 173,\n", " 'false_alarm_trial_count': 4,\n", " 'correct_reject_trial_count': 37,\n", " 'auto_rewarded_trial_count': 5,\n", " 'rewarded_trial_count': 112,\n", " 'total_reward_count': 117,\n", " 'total_reward_volume': 0.8090000000000003,\n", " 'maximum_reward_rate': 4.538096320942588,\n", " 'engaged_trial_count': 286,\n", " 'mean_hit_rate': 0.5083809219533421,\n", " 'mean_hit_rate_uncorrected': 0.5117040303378002,\n", " 'mean_hit_rate_engaged': 0.8257788159919642,\n", " 'mean_false_alarm_rate': 0.149303880370626,\n", " 'mean_false_alarm_rate_uncorrected': 0.14679636896218598,\n", " 'mean_false_alarm_rate_engaged': 0.26905802530802525,\n", " 'mean_dprime': 1.1510474492903153,\n", " 'mean_dprime_engaged': 1.6017817039091797,\n", " 'max_dprime': 2.1577849816633154,\n", " 'max_dprime_engaged': 2.1577849816633154}" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "behavior_session_dict[behavior_session_id].get_performance_metrics()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## we can build out a new table that has all performance data for every session as follows:\n", "This might take a minute or so. The AllenSDK will be extracting the performance data from the NWB file for every session individually." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "behavior_performance_table = pd.DataFrame(\n", " [behavior_session_dict[behavior_session_id].get_performance_metrics() for behavior_session_id in behavior_session_ids]\n", ").set_index(behavior_session_ids)" ] }, { "cell_type": "code", "execution_count": 24, "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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
trial_countgo_trial_countcatch_trial_counthit_trial_countmiss_trial_countfalse_alarm_trial_countcorrect_reject_trial_countauto_rewarded_trial_countrewarded_trial_counttotal_reward_counttotal_reward_volumemaximum_reward_rateengaged_trial_countmean_hit_ratemean_hit_rate_uncorrectedmean_hit_rate_engagedmean_false_alarm_ratemean_false_alarm_rate_uncorrectedmean_false_alarm_rate_engagedmean_dprimemean_dprime_engagedmax_dprimemax_dprime_engaged
83765885411800000011801180.5904.852157101NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
838515247140513313106276751061111.0855.2945453460.8089460.8197260.8222120.5743810.6240390.4219060.6620531.1454071.8322801.832280
83921984145133561482871602948770.6255.015095490.2311150.2337780.8099560.0595020.0251650.1764630.4526451.8757962.2882112.288211
83956542268326941107162437151071221.1455.3931134030.5236210.5292130.8773140.1923310.1698700.3771711.2083911.5991802.2014082.201408
8399123169661742010371614101031131.0803.8336455830.7786700.7858130.9194660.4396180.5118790.5865581.1640351.2405941.6796611.644854
\n", "
" ], "text/plain": [ " trial_count go_trial_count catch_trial_count hit_trial_count \\\n", "837658854 118 0 0 0 \n", "838515247 1405 133 13 106 \n", "839219841 451 335 61 48 \n", "839565422 683 269 41 107 \n", "839912316 966 174 20 103 \n", "\n", " miss_trial_count false_alarm_trial_count \\\n", "837658854 0 0 \n", "838515247 27 6 \n", "839219841 287 1 \n", "839565422 162 4 \n", "839912316 71 6 \n", "\n", " correct_reject_trial_count auto_rewarded_trial_count \\\n", "837658854 0 118 \n", "838515247 7 5 \n", "839219841 60 29 \n", "839565422 37 15 \n", "839912316 14 10 \n", "\n", " rewarded_trial_count total_reward_count total_reward_volume \\\n", "837658854 0 118 0.590 \n", "838515247 106 111 1.085 \n", "839219841 48 77 0.625 \n", "839565422 107 122 1.145 \n", "839912316 103 113 1.080 \n", "\n", " maximum_reward_rate engaged_trial_count mean_hit_rate \\\n", "837658854 4.852157 101 NaN \n", "838515247 5.294545 346 0.808946 \n", "839219841 5.015095 49 0.231115 \n", "839565422 5.393113 403 0.523621 \n", "839912316 3.833645 583 0.778670 \n", "\n", " mean_hit_rate_uncorrected mean_hit_rate_engaged \\\n", "837658854 NaN NaN \n", "838515247 0.819726 0.822212 \n", "839219841 0.233778 0.809956 \n", "839565422 0.529213 0.877314 \n", "839912316 0.785813 0.919466 \n", "\n", " mean_false_alarm_rate mean_false_alarm_rate_uncorrected \\\n", "837658854 NaN NaN \n", "838515247 0.574381 0.624039 \n", "839219841 0.059502 0.025165 \n", "839565422 0.192331 0.169870 \n", "839912316 0.439618 0.511879 \n", "\n", " mean_false_alarm_rate_engaged mean_dprime mean_dprime_engaged \\\n", "837658854 NaN NaN NaN \n", "838515247 0.421906 0.662053 1.145407 \n", "839219841 0.176463 0.452645 1.875796 \n", "839565422 0.377171 1.208391 1.599180 \n", "839912316 0.586558 1.164035 1.240594 \n", "\n", " max_dprime max_dprime_engaged \n", "837658854 NaN NaN \n", "838515247 1.832280 1.832280 \n", "839219841 2.288211 2.288211 \n", "839565422 2.201408 2.201408 \n", "839912316 1.679661 1.644854 " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "behavior_performance_table.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## for convenience, we should merge this with the existing table we built for this mouse" ] }, { "cell_type": "code", "execution_count": 25, "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", " \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", " \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", " \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", " \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", " \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", " \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", "
equipment_namefull_genotypemouse_idreporter_linedriver_linesexage_in_dayssession_typecre_lineindicatorsession_numberprior_exposures_to_session_typeprior_exposures_to_image_setprior_exposures_to_omissionsophys_session_idophys_experiment_idophys_container_idproject_codedate_of_acquisitionfile_idtrial_countgo_trial_countcatch_trial_counthit_trial_countmiss_trial_countfalse_alarm_trial_countcorrect_reject_trial_countauto_rewarded_trial_countrewarded_trial_counttotal_reward_counttotal_reward_volumemaximum_reward_rateengaged_trial_countmean_hit_ratemean_hit_rate_uncorrectedmean_hit_rate_engagedmean_false_alarm_ratemean_false_alarm_rate_uncorrectedmean_false_alarm_rate_engagedmean_dprimemean_dprime_engagedmax_dprimemax_dprime_engaged
behavior_session_id
837658854BEH.B-Box3Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M72.0TRAINING_0_gratings_autorewards_15minSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-15 14:49:24.0151.085362e+0911800000011801180.5904.852157101NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN
838515247BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M75.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-18 13:44:01.4741.085362e+09140513313106276751061111.0855.2945453460.8089460.8197260.8222120.5743810.6240390.4219060.6620531.1454071.8322801.832280
839219841BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M76.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN1NaN0NaNNaNNaNNaN2019-03-19 12:50:12.0681.085362e+0945133561482871602948770.6255.015095490.2311150.2337780.8099560.0595020.0251650.1764630.4526451.8757962.2882112.288211
839565422BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M77.0TRAINING_1_gratingsSlc17a7-IRES2-CreGCaMP6fNaN2NaN0NaNNaNNaNNaN2019-03-20 13:16:44.4611.085362e+0968326941107162437151071221.1455.3931134030.5236210.5292130.8773140.1923310.1698700.3771711.2083911.5991802.2014082.201408
839912316BEH.B-Box1Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G...445002Ai93(TITL-GCaMP6f)[Slc17a7-IRES2-Cre, Camk2a-tTA]M78.0TRAINING_2_gratings_flashedSlc17a7-IRES2-CreGCaMP6fNaN0NaN0NaNNaNNaNNaN2019-03-21 12:54:25.3881.081589e+099661742010371614101031131.0803.8336455830.7786700.7858130.9194660.4396180.5118790.5865581.1640351.2405941.6796611.644854
\n", "
" ], "text/plain": [ " equipment_name \\\n", "behavior_session_id \n", "837658854 BEH.B-Box3 \n", "838515247 BEH.B-Box1 \n", "839219841 BEH.B-Box1 \n", "839565422 BEH.B-Box1 \n", "839912316 BEH.B-Box1 \n", "\n", " full_genotype \\\n", "behavior_session_id \n", "837658854 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "838515247 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "839219841 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "839565422 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "839912316 Slc17a7-IRES2-Cre/wt;Camk2a-tTA/wt;Ai93(TITL-G... \n", "\n", " mouse_id reporter_line \\\n", "behavior_session_id \n", "837658854 445002 Ai93(TITL-GCaMP6f) \n", "838515247 445002 Ai93(TITL-GCaMP6f) \n", "839219841 445002 Ai93(TITL-GCaMP6f) \n", "839565422 445002 Ai93(TITL-GCaMP6f) \n", "839912316 445002 Ai93(TITL-GCaMP6f) \n", "\n", " driver_line sex age_in_days \\\n", "behavior_session_id \n", "837658854 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 72.0 \n", "838515247 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 75.0 \n", "839219841 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 76.0 \n", "839565422 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 77.0 \n", "839912316 [Slc17a7-IRES2-Cre, Camk2a-tTA] M 78.0 \n", "\n", " session_type cre_line \\\n", "behavior_session_id \n", "837658854 TRAINING_0_gratings_autorewards_15min Slc17a7-IRES2-Cre \n", "838515247 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "839219841 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "839565422 TRAINING_1_gratings Slc17a7-IRES2-Cre \n", "839912316 TRAINING_2_gratings_flashed Slc17a7-IRES2-Cre \n", "\n", " indicator session_number \\\n", "behavior_session_id \n", "837658854 GCaMP6f NaN \n", "838515247 GCaMP6f NaN \n", "839219841 GCaMP6f NaN \n", "839565422 GCaMP6f NaN \n", "839912316 GCaMP6f NaN \n", "\n", " prior_exposures_to_session_type \\\n", "behavior_session_id \n", "837658854 0 \n", "838515247 0 \n", "839219841 1 \n", "839565422 2 \n", "839912316 0 \n", "\n", " prior_exposures_to_image_set \\\n", "behavior_session_id \n", "837658854 NaN \n", "838515247 NaN \n", "839219841 NaN \n", "839565422 NaN \n", "839912316 NaN \n", "\n", " prior_exposures_to_omissions ophys_session_id \\\n", "behavior_session_id \n", "837658854 0 NaN \n", "838515247 0 NaN \n", "839219841 0 NaN \n", "839565422 0 NaN \n", "839912316 0 NaN \n", "\n", " ophys_experiment_id ophys_container_id project_code \\\n", "behavior_session_id \n", "837658854 NaN NaN NaN \n", "838515247 NaN NaN NaN \n", "839219841 NaN NaN NaN \n", "839565422 NaN NaN NaN \n", "839912316 NaN NaN NaN \n", "\n", " date_of_acquisition file_id trial_count \\\n", "behavior_session_id \n", "837658854 2019-03-15 14:49:24.015 1.085362e+09 118 \n", "838515247 2019-03-18 13:44:01.474 1.085362e+09 1405 \n", "839219841 2019-03-19 12:50:12.068 1.085362e+09 451 \n", "839565422 2019-03-20 13:16:44.461 1.085362e+09 683 \n", "839912316 2019-03-21 12:54:25.388 1.081589e+09 966 \n", "\n", " go_trial_count catch_trial_count hit_trial_count \\\n", "behavior_session_id \n", "837658854 0 0 0 \n", "838515247 133 13 106 \n", "839219841 335 61 48 \n", "839565422 269 41 107 \n", "839912316 174 20 103 \n", "\n", " miss_trial_count false_alarm_trial_count \\\n", "behavior_session_id \n", "837658854 0 0 \n", "838515247 27 6 \n", "839219841 287 1 \n", "839565422 162 4 \n", "839912316 71 6 \n", "\n", " correct_reject_trial_count auto_rewarded_trial_count \\\n", "behavior_session_id \n", "837658854 0 118 \n", "838515247 7 5 \n", "839219841 60 29 \n", "839565422 37 15 \n", "839912316 14 10 \n", "\n", " rewarded_trial_count total_reward_count \\\n", "behavior_session_id \n", "837658854 0 118 \n", "838515247 106 111 \n", "839219841 48 77 \n", "839565422 107 122 \n", "839912316 103 113 \n", "\n", " total_reward_volume maximum_reward_rate \\\n", "behavior_session_id \n", "837658854 0.590 4.852157 \n", "838515247 1.085 5.294545 \n", "839219841 0.625 5.015095 \n", "839565422 1.145 5.393113 \n", "839912316 1.080 3.833645 \n", "\n", " engaged_trial_count mean_hit_rate \\\n", "behavior_session_id \n", "837658854 101 NaN \n", "838515247 346 0.808946 \n", "839219841 49 0.231115 \n", "839565422 403 0.523621 \n", "839912316 583 0.778670 \n", "\n", " mean_hit_rate_uncorrected mean_hit_rate_engaged \\\n", "behavior_session_id \n", "837658854 NaN NaN \n", "838515247 0.819726 0.822212 \n", "839219841 0.233778 0.809956 \n", "839565422 0.529213 0.877314 \n", "839912316 0.785813 0.919466 \n", "\n", " mean_false_alarm_rate mean_false_alarm_rate_uncorrected \\\n", "behavior_session_id \n", "837658854 NaN NaN \n", "838515247 0.574381 0.624039 \n", "839219841 0.059502 0.025165 \n", "839565422 0.192331 0.169870 \n", "839912316 0.439618 0.511879 \n", "\n", " mean_false_alarm_rate_engaged mean_dprime \\\n", "behavior_session_id \n", "837658854 NaN NaN \n", "838515247 0.421906 0.662053 \n", "839219841 0.176463 0.452645 \n", "839565422 0.377171 1.208391 \n", "839912316 0.586558 1.164035 \n", "\n", " mean_dprime_engaged max_dprime max_dprime_engaged \n", "behavior_session_id \n", "837658854 NaN NaN NaN \n", "838515247 1.145407 1.832280 1.832280 \n", "839219841 1.875796 2.288211 2.288211 \n", "839565422 1.599180 2.201408 2.201408 \n", "839912316 1.240594 1.679661 1.644854 " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "this_mouse_table = this_mouse_table.merge(\n", " behavior_performance_table,\n", " left_index = True,\n", " right_index = True,\n", ")\n", "this_mouse_table.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Remove negative d' values for for passive sessions\n", "One issue with the way that d' is calculated is that it relies on the rolling hit and false alarm rates, but applies a correction to each that avoids letting their values approach 0 or 1 for low trial counts. In fact, they can only be uniquely 0 or 1 for infinite trial counts, which we of course never have. See a discussion here: \n", "https://github.com/AllenInstitute/AllenSDK/blob/master/allensdk/brain_observatory/behavior/dprime_readme.md\n", "\n", "Thus, the rolling hit and false alarm rates are not 0 in passive sessions, even though the animal is not responding by default. In addition, because the task design has inbalanced go/catch trials, the false alarm rate is generally more restricted by this trial count limit. This leads to a negative d' value. \n", "\n", "Since this really doesn't make sense, we'll just set mean_dprime and max_dprime to 0 here" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "passive_sessions = this_mouse_table[this_mouse_table['session_type'].str.contains('passive')]\n", "this_mouse_table.at[passive_sessions.index, 'max_dprime'] = 0\n", "this_mouse_table.at[passive_sessions.index, 'mean_dprime'] = 0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Now we can plot the `max_dprime` value for every session\n", "We can see that this particular mouse performed relatively consistently for every session as it progressed through training." ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "/* global mpl */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function () {\n", " if (typeof WebSocket !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof MozWebSocket !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert(\n", " 'Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.'\n", " );\n", " }\n", "};\n", "\n", "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = this.ws.binaryType !== undefined;\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById('mpl-warnings');\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent =\n", " 'This browser does not support binary websocket messages. ' +\n", " 'Performance may be slow.';\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = document.createElement('div');\n", " this.root.setAttribute('style', 'display: inline-block');\n", " this._root_extra_style(this.root);\n", "\n", " parent_element.appendChild(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message('supports_binary', { value: fig.supports_binary });\n", " fig.send_message('send_image_mode', {});\n", " if (fig.ratio !== 1) {\n", " fig.send_message('set_dpi_ratio', { dpi_ratio: fig.ratio });\n", " }\n", " fig.send_message('refresh', {});\n", " };\n", "\n", " this.imageObj.onload = function () {\n", " if (fig.image_mode === 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function () {\n", " fig.ws.close();\n", " };\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "};\n", "\n", "mpl.figure.prototype._init_header = function () {\n", " var titlebar = document.createElement('div');\n", " titlebar.classList =\n", " 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n", " var titletext = document.createElement('div');\n", " titletext.classList = 'ui-dialog-title';\n", " titletext.setAttribute(\n", " 'style',\n", " 'width: 100%; text-align: center; padding: 3px;'\n", " );\n", " titlebar.appendChild(titletext);\n", " this.root.appendChild(titlebar);\n", " this.header = titletext;\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._init_canvas = function () {\n", " var fig = this;\n", "\n", " var canvas_div = (this.canvas_div = document.createElement('div'));\n", " canvas_div.setAttribute(\n", " 'style',\n", " 'border: 1px solid #ddd;' +\n", " 'box-sizing: content-box;' +\n", " 'clear: both;' +\n", " 'min-height: 1px;' +\n", " 'min-width: 1px;' +\n", " 'outline: 0;' +\n", " 'overflow: hidden;' +\n", " 'position: relative;' +\n", " 'resize: both;'\n", " );\n", "\n", " function on_keyboard_event_closure(name) {\n", " return function (event) {\n", " return fig.key_event(event, name);\n", " };\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'keydown',\n", " on_keyboard_event_closure('key_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'keyup',\n", " on_keyboard_event_closure('key_release')\n", " );\n", "\n", " this._canvas_extra_style(canvas_div);\n", " this.root.appendChild(canvas_div);\n", "\n", " var canvas = (this.canvas = document.createElement('canvas'));\n", " canvas.classList.add('mpl-canvas');\n", " canvas.setAttribute('style', 'box-sizing: content-box;');\n", "\n", " this.context = canvas.getContext('2d');\n", "\n", " var backingStore =\n", " this.context.backingStorePixelRatio ||\n", " this.context.webkitBackingStorePixelRatio ||\n", " this.context.mozBackingStorePixelRatio ||\n", " this.context.msBackingStorePixelRatio ||\n", " this.context.oBackingStorePixelRatio ||\n", " this.context.backingStorePixelRatio ||\n", " 1;\n", "\n", " this.ratio = (window.devicePixelRatio || 1) / backingStore;\n", " if (this.ratio !== 1) {\n", " fig.send_message('set_dpi_ratio', { dpi_ratio: this.ratio });\n", " }\n", "\n", " var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n", " 'canvas'\n", " ));\n", " rubberband_canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box; position: absolute; left: 0; top: 0; z-index: 1;'\n", " );\n", "\n", " var resizeObserver = new ResizeObserver(function (entries) {\n", " var nentries = entries.length;\n", " for (var i = 0; i < nentries; i++) {\n", " var entry = entries[i];\n", " var width, height;\n", " if (entry.contentBoxSize) {\n", " if (entry.contentBoxSize instanceof Array) {\n", " // Chrome 84 implements new version of spec.\n", " width = entry.contentBoxSize[0].inlineSize;\n", " height = entry.contentBoxSize[0].blockSize;\n", " } else {\n", " // Firefox implements old version of spec.\n", " width = entry.contentBoxSize.inlineSize;\n", " height = entry.contentBoxSize.blockSize;\n", " }\n", " } else {\n", " // Chrome <84 implements even older version of spec.\n", " width = entry.contentRect.width;\n", " height = entry.contentRect.height;\n", " }\n", "\n", " // Keep the size of the canvas and rubber band canvas in sync with\n", " // the canvas container.\n", " if (entry.devicePixelContentBoxSize) {\n", " // Chrome 84 implements new version of spec.\n", " canvas.setAttribute(\n", " 'width',\n", " entry.devicePixelContentBoxSize[0].inlineSize\n", " );\n", " canvas.setAttribute(\n", " 'height',\n", " entry.devicePixelContentBoxSize[0].blockSize\n", " );\n", " } else {\n", " canvas.setAttribute('width', width * fig.ratio);\n", " canvas.setAttribute('height', height * fig.ratio);\n", " }\n", " canvas.setAttribute(\n", " 'style',\n", " 'width: ' + width + 'px; height: ' + height + 'px;'\n", " );\n", "\n", " rubberband_canvas.setAttribute('width', width);\n", " rubberband_canvas.setAttribute('height', height);\n", "\n", " // And update the size in Python. We ignore the initial 0/0 size\n", " // that occurs as the element is placed into the DOM, which should\n", " // otherwise not happen due to the minimum size styling.\n", " if (width != 0 && height != 0) {\n", " fig.request_resize(width, height);\n", " }\n", " }\n", " });\n", " resizeObserver.observe(canvas_div);\n", "\n", " function on_mouse_event_closure(name) {\n", " return function (event) {\n", " return fig.mouse_event(event, name);\n", " };\n", " }\n", "\n", " rubberband_canvas.addEventListener(\n", " 'mousedown',\n", " on_mouse_event_closure('button_press')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'mouseup',\n", " on_mouse_event_closure('button_release')\n", " );\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband_canvas.addEventListener(\n", " 'mousemove',\n", " on_mouse_event_closure('motion_notify')\n", " );\n", "\n", " rubberband_canvas.addEventListener(\n", " 'mouseenter',\n", " on_mouse_event_closure('figure_enter')\n", " );\n", " rubberband_canvas.addEventListener(\n", " 'mouseleave',\n", " on_mouse_event_closure('figure_leave')\n", " );\n", "\n", " canvas_div.addEventListener('wheel', function (event) {\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " on_mouse_event_closure('scroll')(event);\n", " });\n", "\n", " canvas_div.appendChild(canvas);\n", " canvas_div.appendChild(rubberband_canvas);\n", "\n", " this.rubberband_context = rubberband_canvas.getContext('2d');\n", " this.rubberband_context.strokeStyle = '#000000';\n", "\n", " this._resize_canvas = function (width, height, forward) {\n", " if (forward) {\n", " canvas_div.style.width = width + 'px';\n", " canvas_div.style.height = height + 'px';\n", " }\n", " };\n", "\n", " // Disable right mouse context menu.\n", " this.rubberband_canvas.addEventListener('contextmenu', function (_e) {\n", " event.preventDefault();\n", " return false;\n", " });\n", "\n", " function set_focus() {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'mpl-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " continue;\n", " }\n", "\n", " var button = (fig.buttons[name] = document.createElement('button'));\n", " button.classList = 'mpl-widget';\n", " button.setAttribute('role', 'button');\n", " button.setAttribute('aria-disabled', 'false');\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", "\n", " var icon_img = document.createElement('img');\n", " icon_img.src = '_images/' + image + '.png';\n", " icon_img.srcset = '_images/' + image + '_large.png 2x';\n", " icon_img.alt = tooltip;\n", " button.appendChild(icon_img);\n", "\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " var fmt_picker = document.createElement('select');\n", " fmt_picker.classList = 'mpl-widget';\n", " toolbar.appendChild(fmt_picker);\n", " this.format_dropdown = fmt_picker;\n", "\n", " for (var ind in mpl.extensions) {\n", " var fmt = mpl.extensions[ind];\n", " var option = document.createElement('option');\n", " option.selected = fmt === mpl.default_extension;\n", " option.innerHTML = fmt;\n", " fmt_picker.appendChild(option);\n", " }\n", "\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "};\n", "\n", "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n", " // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n", " // which will in turn request a refresh of the image.\n", " this.send_message('resize', { width: x_pixels, height: y_pixels });\n", "};\n", "\n", "mpl.figure.prototype.send_message = function (type, properties) {\n", " properties['type'] = type;\n", " properties['figure_id'] = this.id;\n", " this.ws.send(JSON.stringify(properties));\n", "};\n", "\n", "mpl.figure.prototype.send_draw_message = function () {\n", " if (!this.waiting) {\n", " this.waiting = true;\n", " this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " var format_dropdown = fig.format_dropdown;\n", " var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n", " fig.ondownload(fig, format);\n", "};\n", "\n", "mpl.figure.prototype.handle_resize = function (fig, msg) {\n", " var size = msg['size'];\n", " if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n", " fig._resize_canvas(size[0], size[1], msg['forward']);\n", " fig.send_message('refresh', {});\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n", " var x0 = msg['x0'] / fig.ratio;\n", " var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n", " var x1 = msg['x1'] / fig.ratio;\n", " var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", " y1 = Math.floor(y1) + 0.5;\n", " var min_x = Math.min(x0, x1);\n", " var min_y = Math.min(y0, y1);\n", " var width = Math.abs(x1 - x0);\n", " var height = Math.abs(y1 - y0);\n", "\n", " fig.rubberband_context.clearRect(\n", " 0,\n", " 0,\n", " fig.canvas.width / fig.ratio,\n", " fig.canvas.height / fig.ratio\n", " );\n", "\n", " fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n", "};\n", "\n", "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n", " // Updates the figure title.\n", " fig.header.textContent = msg['label'];\n", "};\n", "\n", "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n", " var cursor = msg['cursor'];\n", " switch (cursor) {\n", " case 0:\n", " cursor = 'pointer';\n", " break;\n", " case 1:\n", " cursor = 'default';\n", " break;\n", " case 2:\n", " cursor = 'crosshair';\n", " break;\n", " case 3:\n", " cursor = 'move';\n", " break;\n", " }\n", " fig.rubberband_canvas.style.cursor = cursor;\n", "};\n", "\n", "mpl.figure.prototype.handle_message = function (fig, msg) {\n", " fig.message.textContent = msg['message'];\n", "};\n", "\n", "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n", " // Request the server to send over a new figure.\n", " fig.send_draw_message();\n", "};\n", "\n", "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n", " fig.image_mode = msg['mode'];\n", "};\n", "\n", "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n", " for (var key in msg) {\n", " if (!(key in fig.buttons)) {\n", " continue;\n", " }\n", " fig.buttons[key].disabled = !msg[key];\n", " fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n", " if (msg['mode'] === 'PAN') {\n", " fig.buttons['Pan'].classList.add('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " } else if (msg['mode'] === 'ZOOM') {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.add('active');\n", " } else {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " }\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Called whenever the canvas gets updated.\n", " this.send_message('ack', {});\n", "};\n", "\n", "// A function to construct a web socket function for onmessage handling.\n", "// Called in the figure constructor.\n", "mpl.figure.prototype._make_on_message_function = function (fig) {\n", " return function socket_on_message(evt) {\n", " if (evt.data instanceof Blob) {\n", " /* FIXME: We get \"Resource interpreted as Image but\n", " * transferred with MIME type text/plain:\" errors on\n", " * Chrome. But how to set the MIME type? It doesn't seem\n", " * to be part of the websocket stream */\n", " evt.data.type = 'image/png';\n", "\n", " /* Free the memory for the previous frames */\n", " if (fig.imageObj.src) {\n", " (window.URL || window.webkitURL).revokeObjectURL(\n", " fig.imageObj.src\n", " );\n", " }\n", "\n", " fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n", " evt.data\n", " );\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " } else if (\n", " typeof evt.data === 'string' &&\n", " evt.data.slice(0, 21) === 'data:image/png;base64'\n", " ) {\n", " fig.imageObj.src = evt.data;\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " }\n", "\n", " var msg = JSON.parse(evt.data);\n", " var msg_type = msg['type'];\n", "\n", " // Call the \"handle_{type}\" callback, which takes\n", " // the figure and JSON message as its only arguments.\n", " try {\n", " var callback = fig['handle_' + msg_type];\n", " } catch (e) {\n", " console.log(\n", " \"No handler for the '\" + msg_type + \"' message type: \",\n", " msg\n", " );\n", " return;\n", " }\n", "\n", " if (callback) {\n", " try {\n", " // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n", " callback(fig, msg);\n", " } catch (e) {\n", " console.log(\n", " \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n", " e,\n", " e.stack,\n", " msg\n", " );\n", " }\n", " }\n", " };\n", "};\n", "\n", "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n", "mpl.findpos = function (e) {\n", " //this section is from http://www.quirksmode.org/js/events_properties.html\n", " var targ;\n", " if (!e) {\n", " e = window.event;\n", " }\n", " if (e.target) {\n", " targ = e.target;\n", " } else if (e.srcElement) {\n", " targ = e.srcElement;\n", " }\n", " if (targ.nodeType === 3) {\n", " // defeat Safari bug\n", " targ = targ.parentNode;\n", " }\n", "\n", " // pageX,Y are the mouse positions relative to the document\n", " var boundingRect = targ.getBoundingClientRect();\n", " var x = e.pageX - (boundingRect.left + document.body.scrollLeft);\n", " var y = e.pageY - (boundingRect.top + document.body.scrollTop);\n", "\n", " return { x: x, y: y };\n", "};\n", "\n", "/*\n", " * return a copy of an object with only non-object keys\n", " * we need this to avoid circular references\n", " * http://stackoverflow.com/a/24161582/3208463\n", " */\n", "function simpleKeys(original) {\n", " return Object.keys(original).reduce(function (obj, key) {\n", " if (typeof original[key] !== 'object') {\n", " obj[key] = original[key];\n", " }\n", " return obj;\n", " }, {});\n", "}\n", "\n", "mpl.figure.prototype.mouse_event = function (event, name) {\n", " var canvas_pos = mpl.findpos(event);\n", "\n", " if (name === 'button_press') {\n", " this.canvas.focus();\n", " this.canvas_div.focus();\n", " }\n", "\n", " var x = canvas_pos.x * this.ratio;\n", " var y = canvas_pos.y * this.ratio;\n", "\n", " this.send_message(name, {\n", " x: x,\n", " y: y,\n", " button: event.button,\n", " step: event.step,\n", " guiEvent: simpleKeys(event),\n", " });\n", "\n", " /* This prevents the web browser from automatically changing to\n", " * the text insertion cursor when the button is pressed. We want\n", " * to control all of the cursor setting manually through the\n", " * 'cursor' event from matplotlib */\n", " event.preventDefault();\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n", " // Handle any extra behaviour associated with a key event\n", "};\n", "\n", "mpl.figure.prototype.key_event = function (event, name) {\n", " // Prevent repeat events\n", " if (name === 'key_press') {\n", " if (event.which === this._key) {\n", " return;\n", " } else {\n", " this._key = event.which;\n", " }\n", " }\n", " if (name === 'key_release') {\n", " this._key = null;\n", " }\n", "\n", " var value = '';\n", " if (event.ctrlKey && event.which !== 17) {\n", " value += 'ctrl+';\n", " }\n", " if (event.altKey && event.which !== 18) {\n", " value += 'alt+';\n", " }\n", " if (event.shiftKey && event.which !== 16) {\n", " value += 'shift+';\n", " }\n", "\n", " value += 'k';\n", " value += event.which.toString();\n", "\n", " this._key_event_extra(event, name);\n", "\n", " this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n", " if (name === 'download') {\n", " this.handle_save(this, null);\n", " } else {\n", " this.send_message('toolbar_button', { name: name });\n", " }\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n", "\n", "mpl.default_extension = \"png\";/* global mpl */\n", "\n", "var comm_websocket_adapter = function (comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", " // object with the appropriate methods. Currently this is a non binary\n", " // socket, so there is still some room for performance tuning.\n", " var ws = {};\n", "\n", " ws.close = function () {\n", " comm.close();\n", " };\n", " ws.send = function (m) {\n", " //console.log('sending', m);\n", " comm.send(m);\n", " };\n", " // Register the callback with on_msg.\n", " comm.on_msg(function (msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(msg['content']['data']);\n", " });\n", " return ws;\n", "};\n", "\n", "mpl.mpl_figure_comm = function (comm, msg) {\n", " // This is the function which gets called when the mpl process\n", " // starts-up an IPython Comm through the \"matplotlib\" channel.\n", "\n", " var id = msg.content.data.id;\n", " // Get hold of the div created by the display call when the Comm\n", " // socket was opened in Python.\n", " var element = document.getElementById(id);\n", " var ws_proxy = comm_websocket_adapter(comm);\n", "\n", " function ondownload(figure, _format) {\n", " window.open(figure.canvas.toDataURL());\n", " }\n", "\n", " var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n", "\n", " // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n", " // web socket which is closed, not our websocket->open comm proxy.\n", " ws_proxy.onopen();\n", "\n", " fig.parent_element = element;\n", " fig.cell_info = mpl.find_output_cell(\"
\");\n", " if (!fig.cell_info) {\n", " console.error('Failed to find cell for figure', id, fig);\n", " return;\n", " }\n", " fig.cell_info[0].output_area.element.one(\n", " 'cleared',\n", " { fig: fig },\n", " fig._remove_fig_handler\n", " );\n", "};\n", "\n", "mpl.figure.prototype.handle_close = function (fig, msg) {\n", " var width = fig.canvas.width / fig.ratio;\n", " fig.cell_info[0].output_area.element.off(\n", " 'cleared',\n", " fig._remove_fig_handler\n", " );\n", "\n", " // Update the output cell to use the data from the current canvas.\n", " fig.push_to_output();\n", " var dataURL = fig.canvas.toDataURL();\n", " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable();\n", " fig.parent_element.innerHTML =\n", " '';\n", " fig.close_ws(fig, msg);\n", "};\n", "\n", "mpl.figure.prototype.close_ws = function (fig, msg) {\n", " fig.send_message('closing', msg);\n", " // fig.ws.close()\n", "};\n", "\n", "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", " var width = this.canvas.width / this.ratio;\n", " var dataURL = this.canvas.toDataURL();\n", " this.cell_info[1]['text/html'] =\n", " '';\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Tell IPython that the notebook contents must change.\n", " IPython.notebook.set_dirty(true);\n", " this.send_message('ack', {});\n", " var fig = this;\n", " // Wait a second, then push the new image to the DOM so\n", " // that it is saved nicely (might be nice to debounce this).\n", " setTimeout(function () {\n", " fig.push_to_output();\n", " }, 1000);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'btn-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " var button;\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " continue;\n", " }\n", "\n", " button = fig.buttons[name] = document.createElement('button');\n", " button.classList = 'btn btn-default';\n", " button.href = '#';\n", " button.title = name;\n", " button.innerHTML = '';\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message pull-right';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "\n", " // Add the close button to the window.\n", " var buttongrp = document.createElement('div');\n", " buttongrp.classList = 'btn-group inline pull-right';\n", " button = document.createElement('button');\n", " button.classList = 'btn btn-mini btn-primary';\n", " button.href = '#';\n", " button.title = 'Stop Interaction';\n", " button.innerHTML = '';\n", " button.addEventListener('click', function (_evt) {\n", " fig.handle_close(fig, {});\n", " });\n", " button.addEventListener(\n", " 'mouseover',\n", " on_mouseover_closure('Stop Interaction')\n", " );\n", " buttongrp.appendChild(button);\n", " var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n", " titlebar.insertBefore(buttongrp, titlebar.firstChild);\n", "};\n", "\n", "mpl.figure.prototype._remove_fig_handler = function (event) {\n", " var fig = event.data.fig;\n", " fig.close_ws(fig, {});\n", "};\n", "\n", "mpl.figure.prototype._root_extra_style = function (el) {\n", " el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (el) {\n", " // this is important to make the div 'focusable\n", " el.setAttribute('tabindex', 0);\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " } else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (event, _name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager) {\n", " manager = IPython.keyboard_manager;\n", " }\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which === 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " fig.ondownload(fig, null);\n", "};\n", "\n", "mpl.find_output_cell = function (html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i = 0; i < ncells; i++) {\n", " var cell = cells[i];\n", " if (cell.cell_type === 'code') {\n", " for (var j = 0; j < cell.output_area.outputs.length; j++) {\n", " var data = cell.output_area.outputs[j];\n", " if (data.data) {\n", " // IPython >= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] === html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "};\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel !== null) {\n", " IPython.notebook.kernel.comm_manager.register_target(\n", " 'matplotlib',\n", " mpl.mpl_figure_comm\n", " );\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig, ax = plt.subplots(figsize = (15,5))\n", "\n", "ax.plot(\n", " np.arange(len(this_mouse_table)),\n", " this_mouse_table['max_dprime'],\n", " marker = 'o'\n", ")\n", "ax.set_xticks(range(len(this_mouse_table)))\n", "ax.set_xticklabels(list(this_mouse_table['session_type'].values),rotation = 30, ha='right')\n", "\n", "# make alternating black/gray vspans for visual clarity\n", "colors = ['black', 'gray']\n", "for ii in range(len(this_mouse_table)):\n", " ax.axvspan(ii - 0.5, ii + 0.5, color = colors[ii%2], alpha=0.25)\n", "\n", "ax.set_xlim(-0.5, len(this_mouse_table) - 0.5)\n", "ax.set_ylabel('dprime')\n", "ax.set_xlabel('session type')\n", "ax.set_title(\"Max of rolling d' for every session for mouse {}\".format(mouse_id))\n", "fig.tight_layout()" ] }, { "cell_type": "code", "execution_count": 33, "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", " \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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
mouse_iddate_of_acquisitionsession_typeprior_exposures_to_session_typeprior_exposures_to_image_set
behavior_session_id
8376588544450022019-03-15 14:49:24.015TRAINING_0_gratings_autorewards_15min0NaN
8385152474450022019-03-18 13:44:01.474TRAINING_1_gratings0NaN
8392198414450022019-03-19 12:50:12.068TRAINING_1_gratings1NaN
8395654224450022019-03-20 13:16:44.461TRAINING_1_gratings2NaN
8399123164450022019-03-21 12:54:25.388TRAINING_2_gratings_flashed0NaN
8405818274450022019-03-22 12:56:37.162TRAINING_2_gratings_flashed1NaN
8414268324450022019-03-25 13:33:53.275TRAINING_3_images_A_10uL_reward0NaN
8418277744450022019-03-26 12:43:01.470TRAINING_3_images_A_10uL_reward1NaN
8423852774450022019-03-27 12:13:04.923TRAINING_3_images_A_10uL_reward2NaN
8428199334450022019-03-28 12:11:36.413TRAINING_4_images_A_training0NaN
8434004534450022019-03-29 13:03:16.029TRAINING_5_images_A_epilogue0NaN
8441997584450022019-04-01 11:59:06.026TRAINING_5_images_A_handoff_ready0NaN
8449082614450022019-04-02 12:34:16.170TRAINING_5_images_A_handoff_ready1NaN
8455720444450022019-04-03 12:16:13.522TRAINING_5_images_A_handoff_ready2NaN
8463314234450022019-04-04 13:13:13.399OPHYS_0_images_A_habituation00.0
8470363284450022019-04-05 12:47:32.422OPHYS_0_images_A_habituation11.0
8478749404450022019-04-08 13:27:21.095OPHYS_0_images_A_habituation22.0
8486134064450022019-04-09 13:26:26.372OPHYS_1_images_A03.0
8491476764450022019-04-10 13:34:39.264OPHYS_2_images_A_passive04.0
8496512754450022019-04-11 12:31:50.074OPHYS_3_images_A05.0
8509898324450022019-04-12 13:30:27.946OPHYS_4_images_B00.0
8517739284450022019-04-15 12:20:00.123OPHYS_5_images_B_passive01.0
8524515674450022019-04-16 12:24:46.804OPHYS_6_images_B02.0
8552002294450022019-04-22 09:01:33.022OPHYS_5_images_B_passive13.0
\n", "
" ], "text/plain": [ " mouse_id date_of_acquisition \\\n", "behavior_session_id \n", "837658854 445002 2019-03-15 14:49:24.015 \n", "838515247 445002 2019-03-18 13:44:01.474 \n", "839219841 445002 2019-03-19 12:50:12.068 \n", "839565422 445002 2019-03-20 13:16:44.461 \n", "839912316 445002 2019-03-21 12:54:25.388 \n", "840581827 445002 2019-03-22 12:56:37.162 \n", "841426832 445002 2019-03-25 13:33:53.275 \n", "841827774 445002 2019-03-26 12:43:01.470 \n", "842385277 445002 2019-03-27 12:13:04.923 \n", "842819933 445002 2019-03-28 12:11:36.413 \n", "843400453 445002 2019-03-29 13:03:16.029 \n", "844199758 445002 2019-04-01 11:59:06.026 \n", "844908261 445002 2019-04-02 12:34:16.170 \n", "845572044 445002 2019-04-03 12:16:13.522 \n", "846331423 445002 2019-04-04 13:13:13.399 \n", "847036328 445002 2019-04-05 12:47:32.422 \n", "847874940 445002 2019-04-08 13:27:21.095 \n", "848613406 445002 2019-04-09 13:26:26.372 \n", "849147676 445002 2019-04-10 13:34:39.264 \n", "849651275 445002 2019-04-11 12:31:50.074 \n", "850989832 445002 2019-04-12 13:30:27.946 \n", "851773928 445002 2019-04-15 12:20:00.123 \n", "852451567 445002 2019-04-16 12:24:46.804 \n", "855200229 445002 2019-04-22 09:01:33.022 \n", "\n", " session_type \\\n", "behavior_session_id \n", "837658854 TRAINING_0_gratings_autorewards_15min \n", "838515247 TRAINING_1_gratings \n", "839219841 TRAINING_1_gratings \n", "839565422 TRAINING_1_gratings \n", "839912316 TRAINING_2_gratings_flashed \n", "840581827 TRAINING_2_gratings_flashed \n", "841426832 TRAINING_3_images_A_10uL_reward \n", "841827774 TRAINING_3_images_A_10uL_reward \n", "842385277 TRAINING_3_images_A_10uL_reward \n", "842819933 TRAINING_4_images_A_training \n", "843400453 TRAINING_5_images_A_epilogue \n", "844199758 TRAINING_5_images_A_handoff_ready \n", "844908261 TRAINING_5_images_A_handoff_ready \n", "845572044 TRAINING_5_images_A_handoff_ready \n", "846331423 OPHYS_0_images_A_habituation \n", "847036328 OPHYS_0_images_A_habituation \n", "847874940 OPHYS_0_images_A_habituation \n", "848613406 OPHYS_1_images_A \n", "849147676 OPHYS_2_images_A_passive \n", "849651275 OPHYS_3_images_A \n", "850989832 OPHYS_4_images_B \n", "851773928 OPHYS_5_images_B_passive \n", "852451567 OPHYS_6_images_B \n", "855200229 OPHYS_5_images_B_passive \n", "\n", " prior_exposures_to_session_type \\\n", "behavior_session_id \n", "837658854 0 \n", "838515247 0 \n", "839219841 1 \n", "839565422 2 \n", "839912316 0 \n", "840581827 1 \n", "841426832 0 \n", "841827774 1 \n", "842385277 2 \n", "842819933 0 \n", "843400453 0 \n", "844199758 0 \n", "844908261 1 \n", "845572044 2 \n", "846331423 0 \n", "847036328 1 \n", "847874940 2 \n", "848613406 0 \n", "849147676 0 \n", "849651275 0 \n", "850989832 0 \n", "851773928 0 \n", "852451567 0 \n", "855200229 1 \n", "\n", " prior_exposures_to_image_set \n", "behavior_session_id \n", "837658854 NaN \n", "838515247 NaN \n", "839219841 NaN \n", "839565422 NaN \n", "839912316 NaN \n", "840581827 NaN \n", "841426832 NaN \n", "841827774 NaN \n", "842385277 NaN \n", "842819933 NaN \n", "843400453 NaN \n", "844199758 NaN \n", "844908261 NaN \n", "845572044 NaN \n", "846331423 0.0 \n", "847036328 1.0 \n", "847874940 2.0 \n", "848613406 3.0 \n", "849147676 4.0 \n", "849651275 5.0 \n", "850989832 0.0 \n", "851773928 1.0 \n", "852451567 2.0 \n", "855200229 3.0 " ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "this_mouse_table[['mouse_id','date_of_acquisition','session_type','prior_exposures_to_session_type', 'prior_exposures_to_image_set']]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "allensdk", "language": "python", "name": "allensdk" }, "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }