.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_figure_1_c.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_figure_1_c.py: Figure 1 C ============================================================== recreate figure 1C from the paper .. GENERATED FROM PYTHON SOURCE LINES 9-20 .. code-block:: default # This notebook compares the psychometric performance of mice on the cloud of tones task, # according to muscimol injections in the tail of the striatum and dorsomedial striatum # Commented out IPython magic to ensure Python compatibility. # run this on Colab # !rm -rf APE_paper/ # !git clone https://github.com/HernandoMV/APE_paper.git # %pip install mouse-behavior-analysis-tools # %cd APE_paper/docs/figures_notebooks .. GENERATED FROM PYTHON SOURCE LINES 21-26 1. Import libraries ~~~~~~~~~~~~~~~~~~~~ Commented out IPython magic to ensure Python compatibility. %load_ext autoreload %autoreload 2 .. GENERATED FROM PYTHON SOURCE LINES 26-37 .. code-block:: default import pandas as pd import urllib.request from os.path import exists from mouse_behavior_analysis_tools.plot import make_figures from mouse_behavior_analysis_tools.utils import custom_functions as cuf from IPython.display import clear_output import warnings warnings.filterwarnings('ignore') .. GENERATED FROM PYTHON SOURCE LINES 38-40 2. Download data ~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 40-56 .. code-block:: default # download data from server dataset_name = 'Muscimol-injections_dataframe.csv' url = "https://zenodo.org/record/7261639/files/" + dataset_name dataset_path = '../data/' + dataset_name # download if data is not there if not exists(dataset_path): print('Downloading data...') urllib.request.urlretrieve(url, dataset_path) else: print('Data already in directory') # load mus_df = pd.read_csv(dataset_path, index_col=0) .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading data... .. GENERATED FROM PYTHON SOURCE LINES 57-59 3. Analyse the psychometric performance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 59-74 .. code-block:: default # Analyse the different conditions muscimol_conditions = ['StrTail-bilat-Control', 'StrTail-bilat', 'DMS-bilat'] # specify the text for the figure (this is the text that will appear in the legend) text_for_figure = ['Saline (str tail)', 'Muscimol (str tail)', 'Muscimol (DMS)'] PP_array = [] for muscond in muscimol_conditions: # process the psychometric performance predictDif, PsyPer, fakePredictions, predictPer, EB = \ cuf.PP_ProcessExperiment(mus_df[mus_df['Muscimol'] == muscond], 500, error_bars='SessionTime') # save to array PP_array.append([predictDif, PsyPer, fakePredictions, predictPer, EB]) clear_output() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 75-77 4. Create **Figures 1 C** from the paper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 77-89 .. code-block:: default # prepare colors colorlist = [(0.24715576, 0.49918708, 0.57655991), (160/255, 11/255 , 11/255), (46/255, 122/255 , 11/255)] fig = make_figures.make_figure_muscimol_psychometric(PP_array, text_for_figure, colorlist) fig # uncomment here to save the plot # data_directory = '' # plt.savefig(data_directory + 'Figure1C.pdf', # transparent=True, bbox_inches='tight') .. image-sg:: /auto_examples/images/sphx_glr_plot_figure_1_c_001.png :alt: plot figure 1 c :srcset: /auto_examples/images/sphx_glr_plot_figure_1_c_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 90-92 5. See a summary of the training and performance of the mice ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 92-99 .. code-block:: default # see a summary of the dataset fig = make_figures.make_figure_muscimol_sessions_overview(mus_df) fig # uncomment here to save the plot # data_directory = '' # plt.savefig(data_directory + 'Muscimol-sessions-per-mouse.pdf', # transparent=True, bbox_inches='tight') .. image-sg:: /auto_examples/images/sphx_glr_plot_figure_1_c_002.png :alt: pdyn01 - ForMuscimol , pdyn03 - ForMuscimol , pdyn04 - ForMuscimol , T01 - ForMuscimol , T03 - ForMuscimol :srcset: /auto_examples/images/sphx_glr_plot_figure_1_c_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 1 minutes 44.644 seconds) .. _sphx_glr_download_auto_examples_plot_figure_1_c.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_figure_1_c.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_figure_1_c.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_