-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path3_comparisons.py
135 lines (106 loc) · 5.49 KB
/
3_comparisons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import os, itertools
import numpy as np
import pandas as pd
import scipy as sp
from scipy import stats
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import statsmodels.api as sm
from statsmodels.stats.anova import AnovaRM
from joblib import Parallel, delayed
from IPython import embed as shell
from tools_mcginley import utils
import analyses_tools
from accumodels import hddm_tools
project_dir = '/home/jwdegee/repos/2020_eLife_pupil_bias/'
# exp_names = ['yesno_audio', 'bias_manipulation_30', 'bias_manipulation_70', 'image_recognition', 'bias_manipulation',]
# bin_measures = ['pupil_resp_1s', 'pupil_resp_1s', 'pupil_resp_1s', 'pupil_resp_1s', 'pupil_resp_1s']
# nrs_bins = [5,3,3,2,3]
exp_names = ['gonogo_audio_mouse', 'gonogo_audio_human', 'yesno_audio', 'bias_manipulation_30', 'bias_manipulation_70', 'image_recognition']
bin_measures = ['pupil_stim_1s', 'pupil_stim_1s', 'pupil_resp_1s', 'pupil_resp_1s', 'pupil_resp_1s', 'pupil_resp_1s']
nrs_bins = [5,5,5,3,3,2]
# go-nogo:
for exp_name in ['gonogo_audio_mouse', 'gonogo_audio_human']:
bics = []
for version in [9,10]:
bic = pd.read_csv(os.path.join(project_dir, 'fits', '{}_{}.csv'.format(exp_name, version)))
bic['model'] = version
bic['subj_idx'] = np.arange(bic.shape[0])
bics.append(bic[['bic', 'model', 'subj_idx']])
bics = pd.concat(bics)
# subtract bics:
subtract = np.array(bics.loc[bics['model']==bics['model'].min(), 'bic'])
for m in bics['model'].unique():
bics.loc[bics['model']==m, 'bic'] = np.array(bics.loc[bics['model']==m, 'bic']) - subtract
for version in [10]:
print('{}({}) --> {} ({})'.format(exp_name, version, round(bics.loc[bics['model']==version, 'bic'].mean(),2), round(bics.loc[bics['model']==version, 'bic'].sem(),2)))
fig = plt.figure(figsize=(1.5,1.5))
sns.barplot(x='model', y='bic', units='subj_idx', ci=66, errwidth=1, data=bics)
sns.stripplot(x='model', y='bic', jitter=False, data=bics)
plt.xticks([0,1], ['z', 'dc'])
sns.despine(offset=2, trim=True)
plt.tight_layout()
fig.savefig(os.path.join(project_dir, 'figs', 'ddm', 'comparisons_{}_{}.pdf'.format(exp_name, version)))
# yes/no bICs:
for exp_name in ['yesno_audio', 'bias_manipulation_30', 'bias_manipulation_70', 'image_recognition']:
bics = []
for version in [1,2,3]:
bic = pd.read_csv(os.path.join(project_dir, 'fits', '{}_{}.csv'.format(exp_name, version)))
bic['model'] = version
bic['subj_idx'] = np.arange(bic.shape[0])
bics.append(bic[['bic', 'model', 'subj_idx']])
bics = pd.concat(bics)
# subtract bics:
subtract = np.array(bics.loc[bics['model']==bics['model'].min(), 'bic'])
for m in bics['model'].unique():
bics.loc[bics['model']==m, 'bic'] = np.array(bics.loc[bics['model']==m, 'bic']) - subtract
for version in [1,2]:
print('{}({}) --> {} ({})'.format(exp_name, version, round(bics.loc[bics['model']==version, 'bic'].mean(),2), round(bics.loc[bics['model']==version, 'bic'].sem(),2)))
fig = plt.figure(figsize=(1.5,1.5))
sns.barplot(x='model', y='bic', units='subj_idx', ci=66, errwidth=1, data=bics)
sns.stripplot(x='model', y='bic', jitter=False, data=bics)
plt.xticks([0,1,2], ['z', 'dc', 'u'])
sns.despine(offset=2, trim=True)
plt.tight_layout()
fig.savefig(os.path.join(project_dir, 'figs', 'ddm', 'comparisons_{}_{}.pdf'.format(exp_name, version)))
bics = []
for version in [5,6,7]:
bic = pd.read_csv(os.path.join(project_dir, 'fits', '{}_{}.csv'.format(exp_name, version)))
bic['model'] = version
bic['subj_idx'] = np.arange(bic.shape[0])
bics.append(bic[['bic', 'model', 'subj_idx']])
bics = pd.concat(bics)
# subtract bics:
subtract = np.array(bics.loc[bics['model']==bics['model'].min(), 'bic'])
for m in bics['model'].unique():
bics.loc[bics['model']==m, 'bic'] = np.array(bics.loc[bics['model']==m, 'bic']) - subtract
for version in [5,6]:
print('{}({}) --> {} ({})'.format(exp_name, version, round(bics.loc[bics['model']==version, 'bic'].mean(),2), round(bics.loc[bics['model']==version, 'bic'].sem(),2)))
fig = plt.figure(figsize=(1.5,1.5))
sns.barplot(x='model', y='bic', units='subj_idx', ci=66, errwidth=1, data=bics)
sns.stripplot(x='model', y='bic', jitter=False, data=bics)
plt.xticks([0,1,2], ['z', 'dc', 'u'])
sns.despine(offset=2, trim=True)
plt.tight_layout()
fig.savefig(os.path.join(project_dir, 'figs', 'ddm', 'comparisons_{}_{}.pdf'.format(exp_name, version)))
# yes/no DICs:
for exp_name in ['yesno_audio', 'bias_manipulation_30', 'bias_manipulation_70', 'image_recognition']:
dics = []
for version in [9,10,11]:
m = hddm_tools.load_ddm_per_group(os.path.join(project_dir, 'fits'), '{}_{}'.format(exp_name, version), n_models=1)[0]
dics.append(m.dic)
dics = pd.DataFrame(dics)
dics['model'] = np.array([9,10,11])
dics.columns = ['dic', 'model']
dics['dic'] = dics['dic'] - dics['dic'].iloc[0]
fig = plt.figure(figsize=(1.5,1.5))
sns.barplot(x='model', y='dic', ci=66, errwidth=1, data=dics)
sns.stripplot(x='model', y='dic', jitter=False, data=dics)
plt.xticks([0,1,2], ['z', 'dc', 'full'])
sns.despine(offset=2, trim=True)
plt.tight_layout()
fig.savefig(os.path.join(project_dir, 'figs', 'ddm', 'comparisons_{}_{}.pdf'.format(exp_name, version)))
shell()
dics = dics-dics[0]
print('{}({}) --> {}'.format(exp_name, version, dics))