-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigure7.py
206 lines (168 loc) · 4.92 KB
/
Figure7.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
import random
import sklearn
import seaborn as sns
import scipy as sp
from matplotlib import rc
import matplotlib.ticker as mtick
import matplotlib as mpl
from scipy import signal
from sklearn.linear_model import LinearRegression
from sklearn.impute import SimpleImputer
from sklearn.linear_model import ElasticNet
from sklearn.linear_model import ElasticNetCV
from sklearn.datasets import make_regression
from sklearn.decomposition import PCA
from sklearn.linear_model import RidgeCV
from sklearn.linear_model import Lasso
from sklearn.model_selection import train_test_split
import os
import glob
import pickle
import statsmodels.api as sm
from statsmodels.formula.api import ols
from statsmodels.tsa.stattools import acf
from statsmodels.stats.multicomp import pairwise_tukeyhsd
import statsmodels.formula.api as smf
# from FileManagement import *
# from GlmModule import *
from DataProcessing import *
from Visualisation import *
from GeneralRunners import *
from PCA import *
from StatTests import *
from Controls import *
from Behaviour import GetChoicePerAnimal
#%%Panels A, D
saveDir = "C:\\TaskProject\\2pData\\"
if not os.path.isdir(saveDir):
os.makedirs(saveDir)
mpl.rcParams["pdf.fonttype"] = 42
mpl.rcParams["ps.fonttype"] = 42
mpl.rcParams["font.family"] = "Arial"
AllData, AllSubjects, AllSessions = LoadAllFiles("D:\\task_2p\\")
for i in range(17, 23):
AllData[i]["planeDelays"] = AllData[i]["planeDelays"].T
sessId, nId = GetNeuronDetails(AllData)
tups = np.vstack((sessId, nId)).T
tups = list(tuple(map(tuple, tups)))
res, metadata = TestResponsiveness(AllData, 0.5, 0.5)
resp = res["Resp"]
p = res["pVals"]
z = res["zScores"]
r = p <= 0.05 / 8
plt.close("all")
sigs, sortInd = PrintPopulationResponsiveness(
AllData, sortBy=r, addLines=False, returnIndex=True
) #
getResponsivnessStats(r)
#%% Panels B, E
import numpy as np
from matplotlib import pyplot as plt
import matplotlib as mpl
import random
import sklearn
import scipy as sp
import matplotlib.ticker as mtick
import matplotlib as mpl
from scipy import signal
from sklearn.linear_model import LinearRegression
from sklearn.impute import SimpleImputer
from sklearn.linear_model import ElasticNet
from sklearn.linear_model import ElasticNetCV
from sklearn.datasets import make_regression
from sklearn.decomposition import PCA
from sklearn.linear_model import RidgeCV
from sklearn.linear_model import Lasso
from sklearn.model_selection import train_test_split
import os
import glob
import pickle
from FileManagement import *
# from GlmModule import *
from DataProcessing import *
from Visualisation import *
from GeneralRunners import *
from PCA import *
from StatTests import *
saveDir = "D:\\TaskProject\\EphysData\\"
if not os.path.isdir(saveDir):
os.makedirs(saveDir)
plt.close("all")
mpl.rcParams["pdf.fonttype"] = 42
mpl.rcParams["ps.fonttype"] = 42
mpl.rcParams["font.family"] = "Arial"
AllData, AllSubjects, AllSessions = LoadAllFiles(
"D:\\ProjectTask\\Ephys\\", ephys=True
)
sessId, pId, nId = GetNeuronDetails(AllData, ephys=True)
res, m = TestResponsivenessEphys(AllData, 0.5, 0.5)
resp = res["Resp"]
p = res["pVals"]
z = res["zScores"]
r = p <= 0.05 / 8
dpa = {
"SS087": -298,
"SS088": -330,
"SS089": -338,
"SS091": -314,
"SS092": -310,
"SS093": -277,
}
animals = np.vstack(AllSubjects.values())
super_border = [dpa[x] for x in np.squeeze(animals)]
d = [0, 1000]
sigs = PrintPopulationResponsivenessEphys(
AllData,
sortBy=sortby,
addLines=False,
w=40,
depth=d,
depthList=super_border,
)
depths = sigs[-1]
indDepths = np.where((depths >= d[0]) & (depths <= d[1]))[0]
rDepth = r[:, indDepths]
getResponsivnessStats(rDepth)
#%% Panels C, F
saveDir = "D:\\TaskProject\\EphysData\\"
if not os.path.isdir(saveDir):
os.makedirs(saveDir)
plt.close("all")
mpl.rcParams["pdf.fonttype"] = 42
mpl.rcParams["ps.fonttype"] = 42
mpl.rcParams["font.family"] = "Arial"
AllData, AllSubjects, AllSessions = LoadAllFiles(
"D:\\ProjectTask\\Ephys\\", ephys=True
)
sessId, pId, nId = GetNeuronDetails(AllData, ephys=True)
res, m = TestResponsivenessEphys(AllData, 0.5, 0.5)
resp = res["Resp"]
p = res["pVals"]
z = res["zScores"]
r = p <= 0.05 / 8
dpa = {
"SS087": -298,
"SS088": -330,
"SS089": -338,
"SS091": -314,
"SS092": -310,
"SS093": -277,
}
animals = np.vstack(AllSubjects.values())
super_border = [dpa[x] for x in np.squeeze(animals)]
d = [-1000, -0.00001]
sigs = PrintPopulationResponsivenessEphys(
AllData,
sortBy=sortby,
addLines=False,
w=40,
depth=d,
depthList=super_border,
)
depths = sigs[-1]
indDepths = np.where((depths >= d[0]) & (depths <= d[1]))[0]
rDepth = r[:, indDepths]
getResponsivnessStats(rDepth)