@author: Anne Urai
15 January 2020
"""
import seaborn as sns
import os
import matplotlib.pyplot as plt
from paper_behavior_functions import (figpath, seaborn_style, group_colors,
                                      query_sessions_around_criterion,
                                      institution_map)
# import wrappers etc
from ibl_pipeline import reference, subject, behavior
from dj_tools import plot_psychometric, dj2pandas

# INITIALIZE A FEW THINGS
seaborn_style()
figpath = figpath()
pal = group_colors()
institution_map, col_names = institution_map()
col_names = col_names[:-1]

# ================================= #
# GET DATA FROM TRAINED ANIMALS
# ================================= #

use_sessions, use_days = query_sessions_around_criterion(
    criterion='trained', days_from_criterion=[2, 0], as_dataframe=False)
# restrict by list of dicts with uuids for these sessions
b = use_sessions * subject.Subject * subject.SubjectLab * reference.Lab * \
    behavior.TrialSet.Trial
# reduce the size of the fetch
# (this is a tricky dependency, as is it can not be run in a python shell, it makes the whole file
# need to run as an executable eg. >>> python figure1_training.py in windows command prompt)
# sys.path.append(os.path.join(os.path.dirname(__file__),
#                              '../IBL-pipeline/prelim_analyses/behavioral_snapshots/'))
# import ibl_pipeline.prelim_analyses.behavioral_snapshots.behavior_plots  # noqa

# this only works if conda develop ./IBL-pipeline/prelim_analyses/behavioral_snapshots/ has been added to iblenv
import load_mouse_data_datajoint, behavior_plots
import dj_tools
from paper_behavior_functions import seaborn_style, figpath

# ================================= #
# INITIALIZE A FEW THINGS
# ================================= #

seaborn_style()  # noqa
figpath = figpath()  # noqa
plt.close('all')

# ================================= #
# pick an example mouse
# ================================= #

mouse = 'KS014'
lab = 'cortexlab'

# ==================================================
# CONTRAST HEATMAP
# ================================= #

plt.close('all')