-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLongTimeCoursePhotoLicking.py
More file actions
320 lines (276 loc) · 12.3 KB
/
Copy pathLongTimeCoursePhotoLicking.py
File metadata and controls
320 lines (276 loc) · 12.3 KB
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 9 19:09:07 2019
@author: kate
"""
'''
MAKE
SURE
THAT
YOU HAVE RUN
THE CORRECT BLUE AND UV
SIGNALS (LICKING - 14 RATS)
AND
NOT
DISTRACTION / MODELLED OR HABITUATION
'''
## Functions and code to creat the long time course figures for distraction paper
# Step 1 - run the all functions file
# Step 2 - run the Ch4_analysis_licking and Ch4_analysis_distraction files
# Step 3 - change the snipper function to make longer snips and add this to this file
# Step 4 - copy over only the code that is needed from the licking and distraciton file
# - to make the long time course figures
#! ! ! Decide if you are going to use data from one representative rats or all of the animals
# Check back to MMIN18 and see whether you used group or individual data
# Maybe only need the blue signal or maybe also violet is useful
# Step 5 - make and save long timecourse figures
# Step 6 - subset the required data for the barscatter plots, decide which info is important
# Step 7 - calculate peaks within time region and look at these statistically
# Step 8 - check which figures and statistics from thesis / and corrections (time bins)
# - will be used
# Step 9 - make barscatter of 'probability' of distraction in 10 min time bins
# - averaged for all of the rats (make the percent for each and then average)
# - show statistically the lack of habituaiton effect within the session
## Step 10 - is it possible to make barscatters for average post distraction pauses
# - or other measure median then bin these into 10 mins as with percent distracted?
### Could plot all the rats as 1hr then as 30 mins to see which rat to use for long time course
# RAT3 - 10 minutes
fig9 = plt.figure(figsize=(12,2))
ax7 = plt.subplot(1,1,1)
plt.plot(allRatBlue[3], color='royalblue')
plt.plot(allRatUV[3] - 130, color='darkorchid') ### OFFSET THE UV
ax7.set_xticks([0,(10*60*allRatFS[0]),(20*60*allRatFS[0]),(30*60*allRatFS[0]),(40*60*allRatFS[0]),(50*60*allRatFS[0]),(60*60*allRatFS[0])] )
ax7.set_xticklabels([0,10,20,30,40,50,60])
ax7.set_xlabel('Mins', fontsize=14)
#ax7.set_xlim([500000,700000]) # looks really nice scale wise, approx 3 mins
ax7.set_xlim([122070.31494140625,732421.8896484375]) # 2 mins to 12 mins, a 10 min snip without noise at start
ax7.set_ylim([400,800])
multipliedLicks = []
for element in allRatLicks[3]:
multElement = element*allRatFS[0]
multipliedLicks.append([multElement])
xvals = multipliedLicks
yvals = [ax7.get_ylim()[1] - 10] * len(xvals)
ax7.scatter(xvals, yvals, marker='|', color='k', linewidth=0.2)
ax7.set(ylabel = '∆F')
ax7.yaxis.label.set_size(14)
ax7.xaxis.set_visible(False)
scalebar = 1*allRatFS[0]*60 # 1 minute
yrange = ax7.get_ylim()[1] - ax7.get_ylim()[0]
scalebary = (yrange / 10) + ax7.get_ylim()[0]
scalebarx = [ax7.get_xlim()[1] - scalebar, ax7.get_xlim()[1]]
ax7.plot(scalebarx, [scalebary, scalebary], c='k', linewidth=2)
ax7.text((scalebarx[0] + (scalebar/2)), scalebary-(yrange/50), '1 Min', ha='center',va='top', **Calibri, **Size)
ax7.spines['right'].set_visible(False)
ax7.spines['top'].set_visible(False)
ax7.spines['bottom'].set_visible(False)
#fig9.savefig('/Volumes/KPMSB352/PHOTOMETRY MMIN18/PDF figures/LongTimeCourse.pdf', bbox_inches="tight")
fig9.savefig('/Users/kate/Desktop/Peters, McCutcheon & Young, 2019/Draft 1/PLongTimeCourseRat3_10min.pdf', bbox_inches="tight")
## RAT 12
#fig9 = plt.figure(figsize=(12,2))
#ax7 = plt.subplot(1,1,1)
#plt.plot(allRatBlue[12], color='royalblue')
#plt.plot(allRatUV[12], color='darkorchid')
#ax7.set_xticks([0,(10*60*allRatFS[0]),(20*60*allRatFS[0]),(30*60*allRatFS[0]),(40*60*allRatFS[0]),(50*60*allRatFS[0]),(60*60*allRatFS[0])] )
#ax7.set_xticklabels([0,10,20,30,40,50,60])
#ax7.set_xlabel('Mins', fontsize=14)
##ax7.set_xlim([500000,700000]) # looks really nice scale wise, approx 3 mins
#ax7.set_xlim([122070.31494140625,732421.8896484375]) # 2 mins to 12 mins, a 10 min snip without noise at start
#ax7.set_ylim([300,800])
#
#
#
## Adding the scatter to long time course plot of photo signals
##allRatLicks.append(ratdata['licks'])
#multipliedLicks = []
#for element in allRatLicks[12]:
# multElement = element*allRatFS[0]
# multipliedLicks.append([multElement])
#
#xvals = multipliedLicks
#yvals = [ax7.get_ylim()[1] - 50] * len(xvals)
#ax7.scatter(xvals, yvals, marker='|', color='k', linewidth=0.2)
#
## Get rid of the spines and add labels and ticks to plot
## Add a 1 minute scale bar OR tick labels for mins
#ax7.set(ylabel = '∆F')
#ax7.yaxis.label.set_size(14)
#ax7.xaxis.set_visible(False)
#
#scalebar = 1*allRatFS[0]*60 # 1 minute
#
#yrange = ax7.get_ylim()[1] - ax7.get_ylim()[0]
#scalebary = (yrange / 10) + ax7.get_ylim()[0]
#scalebarx = [ax7.get_xlim()[1] - scalebar, ax7.get_xlim()[1]]
#ax7.plot(scalebarx, [scalebary, scalebary], c='k', linewidth=2)
#ax7.text((scalebarx[0] + (scalebar/2)), scalebary-(yrange/50), '1 Min', ha='center',va='top', **Calibri, **Size)
#ax7.spines['right'].set_visible(False)
#ax7.spines['top'].set_visible(False)
#ax7.spines['bottom'].set_visible(False)
##fig9.savefig('/Volumes/KPMSB352/PHOTOMETRY MMIN18/PDF figures/LongTimeCourse.pdf', bbox_inches="tight")
#
## RAT 3 ZOOMED SECITON 30 seconds
fig9 = plt.figure(figsize=(6,2))
ax7 = plt.subplot(1,1,1)
plt.plot(allRatBlue[3], color='royalblue')
#plt.plot(allRatUV[3], color='darkorchid')
ax7.set_xticks([0,(20*60*allRatFS[0]),(30*60*allRatFS[0])])
ax7.set_xticklabels([0,20,30])
ax7.set_xlabel('Mins', fontsize=14)
#ax7.set_xlim([500000,700000]) # looks really nice scale wise, approx 3 mins
ax7.set_xlim([228881.84051513672, 259399.41925048828]) # 2 mins to 12 mins, a 10 min snip without noise at start
ax7.set_ylim([500,800])
# 3.75 (45 seconds) and 4.25
## 4- 5
# Adding the scatter to long time course plot of photo signals
#allRatLicks.append(ratdata['licks'])
multipliedLicks = []
for element in allRatLicks[3]:
multElement = element*allRatFS[0]
multipliedLicks.append([multElement])
xvals = multipliedLicks
yvals = [ax7.get_ylim()[1] - 50] * len(xvals)
ax7.scatter(xvals, yvals, marker='|', color='k', linewidth=0.6)
# Get rid of the spines and add labels and ticks to plot
# Add a 1 minute scale bar OR tick labels for mins
ax7.set(ylabel = '∆F')
ax7.yaxis.label.set_size(14)
ax7.xaxis.set_visible(False)
scalebar = 1*allRatFS[0]*60 # 1 minute
yrange = ax7.get_ylim()[1] - ax7.get_ylim()[0]
scalebary = (yrange / 10) + ax7.get_ylim()[0]
scalebarx = [ax7.get_xlim()[1] - scalebar, ax7.get_xlim()[1]]
#ax7.plot(scalebarx, [scalebary, scalebary], c='k', linewidth=2)
#ax7.text((scalebarx[0] + (scalebar/2)), scalebary-(yrange/50), '30 Sec', ha='center',va='top', **Calibri, **Size)
ax7.spines['right'].set_visible(False)
ax7.spines['top'].set_visible(False)
ax7.spines['bottom'].set_visible(False)
#fig9.savefig('/Volumes/KPMSB352/PHOTOMETRY MMIN18/PDF figures/LongTimeCourse.pdf', bbox_inches="tight")
fig9.savefig('/Users/kate/Desktop/Peters, McCutcheon & Young, 2019/Draft 1/PLongTimeCourseRat3_30sec(1).pdf', bbox_inches="tight")
### RAT 3 ZOOMED SECITON
#fig9 = plt.figure(figsize=(4,2))
#ax7 = plt.subplot(1,1,1)
#plt.plot(allRatBlue[3], color='royalblue')
##plt.plot(allRatUV[3], color='darkorchid')
#ax7.set_xticks([0,(20*60*allRatFS[0]),(30*60*allRatFS[0])])
#ax7.set_xticklabels([0,20,30])
#ax7.set_xlabel('Mins', fontsize=14)
##ax7.set_xlim([500000,700000]) # looks really nice scale wise, approx 3 mins
#ax7.set_xlim([228881.84051513672, 289916.99798583984]) # 2 mins to 12 mins, a 10 min snip without noise at start
#ax7.set_ylim([300,800])
#
## 3.75 (45 seconds) and 4.75
#
### 4- 5
## Adding the scatter to long time course plot of photo signals
##allRatLicks.append(ratdata['licks'])
#multipliedLicks = []
#for element in allRatLicks[3]:
# multElement = element*allRatFS[0]
# multipliedLicks.append([multElement])
#
#xvals = multipliedLicks
#yvals = [ax7.get_ylim()[1] - 50] * len(xvals)
#ax7.scatter(xvals, yvals, marker='|', color='k', linewidth=0.2)
#
## Get rid of the spines and add labels and ticks to plot
## Add a 1 minute scale bar OR tick labels for mins
#ax7.set(ylabel = '∆F')
#ax7.yaxis.label.set_size(14)
#ax7.xaxis.set_visible(False)
#
#scalebar = 1*allRatFS[0]*60 # 1 minute
#
#yrange = ax7.get_ylim()[1] - ax7.get_ylim()[0]
#scalebary = (yrange / 10) + ax7.get_ylim()[0]
#scalebarx = [ax7.get_xlim()[1] - scalebar, ax7.get_xlim()[1]]
#ax7.plot(scalebarx, [scalebary, scalebary], c='k', linewidth=2)
#ax7.text((scalebarx[0] + (scalebar/2)), scalebary-(yrange/50), '1 Min', ha='center',va='top', **Calibri, **Size)
#ax7.spines['right'].set_visible(False)
#ax7.spines['top'].set_visible(False)
#ax7.spines['bottom'].set_visible(False)
##fig9.savefig('/Volumes/KPMSB352/PHOTOMETRY MMIN18/PDF figures/LongTimeCourse.pdf', bbox_inches="tight")
#
## RAT 3 ZOOMED SECITON 2 - 5.30 TO 6 - 30 seconds
fig9 = plt.figure(figsize=(6,2))
ax7 = plt.subplot(1,1,1)
plt.plot(allRatBlue[3], color='royalblue')
#plt.plot(allRatUV[3], color='darkorchid')
ax7.set_xticks([0,(20*60*allRatFS[0]),(30*60*allRatFS[0])])
ax7.set_xticklabels([0,20,30])
ax7.set_xlabel('Mins', fontsize=14)
#ax7.set_xlim([500000,700000]) # looks really nice scale wise, approx 3 mins
ax7.set_xlim([335693.3660888672, 366210.94482421875]) # 2 mins to 12 mins, a 10 min snip without noise at start
ax7.set_ylim([500,800])
## 4- 5
# Adding the scatter to long time course plot of photo signals
#allRatLicks.append(ratdata['licks'])
multipliedLicks = []
for element in allRatLicks[3]:
multElement = element*allRatFS[0]
multipliedLicks.append([multElement])
xvals = multipliedLicks
yvals = [ax7.get_ylim()[1] - 50] * len(xvals)
ax7.scatter(xvals, yvals, marker='|', color='k', linewidth=0.6) # Altered line width
# Get rid of the spines and add labels and ticks to plot
# Add a 1 minute scale bar OR tick labels for mins
ax7.set(ylabel = '∆F')
ax7.yaxis.label.set_size(14)
ax7.xaxis.set_visible(False)
scalebar = 1*allRatFS[0]*60 # 1 minute
yrange = ax7.get_ylim()[1] - ax7.get_ylim()[0]
scalebary = (yrange / 10) + ax7.get_ylim()[0]
scalebarx = [ax7.get_xlim()[1] - scalebar, ax7.get_xlim()[1]]
#ax7.plot(scalebarx, [scalebary, scalebary], c='k', linewidth=2)
#ax7.text((scalebarx[0] + (scalebar/2)), scalebary-(yrange/50), '1 Min', ha='center',va='top', **Calibri, **Size)
ax7.spines['right'].set_visible(False)
ax7.spines['top'].set_visible(False)
ax7.spines['bottom'].set_visible(False)
fig9.savefig('/Users/kate/Desktop/Peters, McCutcheon & Young, 2019/Draft 1/PLongTimeCourseRat3_30sec(2).pdf', bbox_inches="tight")
### RAT 12 ZOOMED SECTION
#
## RAT 12
#fig9 = plt.figure(figsize=(4,2))
#ax7 = plt.subplot(1,1,1)
#plt.plot(allRatBlue[12], color='royalblue')
##plt.plot(allRatUV[12], color='darkorchid')
#ax7.set_xticks([0,(20*60*allRatFS[0]),(30*60*allRatFS[0])])
#ax7.set_xticklabels([0,20,30])
#ax7.set_xlabel('Mins', fontsize=14)
##ax7.set_xlim([500000,700000]) # looks really nice scale wise, approx 3 mins
#
#ax7.set_xlim([213623.05114746094,274658.20861816406]) # 2 mins to 12 mins, a 10 min snip without noise at start
#ax7.set_ylim([300,800])
#
#
#
## Adding the scatter to long time course plot of photo signals
##allRatLicks.append(ratdata['licks'])
#multipliedLicks = []
#for element in allRatLicks[12]:
# multElement = element*allRatFS[0]
# multipliedLicks.append([multElement])
#
#xvals = multipliedLicks
#yvals = [ax7.get_ylim()[1] - 50] * len(xvals)
#ax7.scatter(xvals, yvals, marker='|', color='k', linewidth=0.2)
#
## Get rid of the spines and add labels and ticks to plot
## Add a 1 minute scale bar OR tick labels for mins
#ax7.set(ylabel = '∆F')
#ax7.yaxis.label.set_size(14)
#ax7.xaxis.set_visible(False)
#
#scalebar = 1*allRatFS[0]*60 # 1 minute
#
#yrange = ax7.get_ylim()[1] - ax7.get_ylim()[0]
#scalebary = (yrange / 10) + ax7.get_ylim()[0]
#scalebarx = [ax7.get_xlim()[1] - scalebar, ax7.get_xlim()[1]]
#ax7.plot(scalebarx, [scalebary, scalebary], c='k', linewidth=2)
#ax7.text((scalebarx[0] + (scalebar/2)), scalebary-(yrange/50), '1 Min', ha='center',va='top', **Calibri, **Size)
#ax7.spines['right'].set_visible(False)
#ax7.spines['top'].set_visible(False)
#ax7.spines['bottom'].set_visible(False)
##fig9.savefig('/Volumes/KPMSB352/PHOTOMETRY MMIN18/PDF figures/LongTimeCourse.pdf', bbox_inches="tight")
#