コード例 #1
0
16 Jan 2020
"""

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from os.path import join
import seaborn as sns
from paper_behavior_functions import (query_subjects, seaborn_style, institution_map,
                                      group_colors, figpath)
from ibl_pipeline.analyses import behavior as behavior_analysis
from scipy import stats
import scikit_posthocs as sp

# Settings
fig_path = figpath()

# Query sessions
use_subjects = query_subjects()
ses = (use_subjects * behavior_analysis.SessionTrainingStatus * behavior_analysis.PsychResults
       & 'training_status = "in_training" OR training_status = "untrainable"').proj(
               'subject_nickname', 'n_trials_stim', 'institution_short').fetch(format='frame')
ses = ses.reset_index()
ses['n_trials'] = [sum(i) for i in ses['n_trials_stim']]

# Construct dataframe
training_time = pd.DataFrame(columns=['sessions'], data=ses.groupby('subject_nickname').size())
training_time['trials'] = ses.groupby('subject_nickname').sum()
training_time['lab'] = ses.groupby('subject_nickname')['institution_short'].apply(list).str[0]

# Change lab name into lab number
コード例 #2
0
@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
b2 = b.proj('institution_short', 'subject_nickname', 'task_protocol',
コード例 #3
0
figure3f_decoding_lab_membership_basic and figure3f_decoding_lab_membership_full

Guido Meijer
18 Jun 2020
"""

import pandas as pd
import numpy as np
import seaborn as sns
from os.path import join
import matplotlib.pyplot as plt
from paper_behavior_functions import seaborn_style, figpath, datapath, FIGURE_WIDTH, FIGURE_HEIGHT

# Settings
DECODER = 'bayes'
FIG_PATH = figpath()
colors = [[1, 1, 1], [1, 1, 1], [0.6, 0.6, 0.6]]
seaborn_style()

# Load in results from csv file
decoding_result = pd.read_pickle(join(datapath(),
                                          'classification_results_perf_%s.pkl' % DECODER))

# Calculate if decoder performs above chance
chance_level = decoding_result['original_shuffled'].mean()
significance = np.percentile(decoding_result['original'], 2.5)
sig_control = np.percentile(decoding_result['control'], 0.001)
if chance_level > significance:
    print('\n%s classifier did not perform above chance' % DECODER)
    print('Chance level: %.2f (F1 score)' % chance_level)
else:
コード例 #4
0
Miles  Wells, UCL, 2019
"""
import os

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

import datajoint as dj
from ibl_pipeline import acquisition
from paper_behavior_functions import \
    (figpath, query_sessions, query_subjects, group_colors, seaborn_style,
     FIGURE_HEIGHT, FIGURE_WIDTH)

# Set default figure size.
save_path = figpath()  # Our figure save path
colors = group_colors()
seaborn_style()

endcriteria = dj.create_virtual_module('SessionEndCriteriaImplemented',
                                       'group_shared_end_criteria')
sessions = query_sessions().proj(session_start_date='date(session_start_time)')
subj_crit = query_subjects().aggr(
    acquisition.Session(),
    first_day='min(date(session_start_time))').proj('first_day')
session_num = (sessions *
               subj_crit).proj(n='DATEDIFF(session_start_date, first_day)')

df = (endcriteria.SessionEndCriteriaImplemented * session_num).fetch(
    format='frame')  # Fetch data
コード例 #5
0
# 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')
xlims = [pd.Timestamp('2019-08-04T00'), pd.Timestamp('2019-08-31T00')]
コード例 #6
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Create list of UUIDs used in the paper

@author: Alex Pan
"""

import numpy as np
from os.path import join
from ibl_pipeline import reference, subject, acquisition, behavior
from ibl_pipeline.analyses import behavior as behavior_analysis
from paper_behavior_functions import query_subjects, query_sessions_around_criterion, figpath

# Get path to save
SAVE_PATH = figpath()

# All subjects
subjects = query_subjects(as_dataframe=True)

# Create dataframe with behavioral metrics of all mice
ses_2b = []
for i, nickname in enumerate(subjects['subject_nickname']):
    if np.mod(i + 1, 10) == 0:
        print('Loading data of subject %d of %d' %
              (i + 1, len(subjects['subject_nickname'])))

    # Get sessions and trials which are flagged as in_training
    ses_start = (
        acquisition.Session * subject.Subject *
        behavior_analysis.SessionTrainingStatus
コード例 #7
0
Created on 2020-07-20
@author: Anne Urai
"""
from pathlib import Path

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats

from paper_behavior_functions import (seaborn_style, institution_map,
                                      group_colors, figpath, load_csv,
                                      FIGURE_WIDTH, FIGURE_HEIGHT, num_star)

# Load some things from paper_behavior_functions
figpath = Path(figpath())
seaborn_style()
institution_map, col_names = institution_map()
pal = group_colors()
cmap = sns.diverging_palette(20, 220, n=3, center="dark")

# ========================================== #
#%% 1. GET GLM FITS FOR ALL MICE
# ========================================== #

print('loading model from disk...')
params_basic = load_csv('model_results', 'params_basic.csv')
params_full = load_csv('model_results', 'params_full.csv')
combined = params_basic.merge(params_full,
                              on=['institution_code', 'subject_nickname'])