-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBehaviourPaperLog.py
More file actions
249 lines (154 loc) · 8.2 KB
/
Copy pathBehaviourPaperLog.py
File metadata and controls
249 lines (154 loc) · 8.2 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 16 11:18:01 2018
@author: u1490431
"""
''' 16/04/18 '''
# Made new script and added ideas / instructions for analysis
# Try to make documentation very clear as you go along
# Eventually transfer all of this to a Jupyter notebook
Medfilereader
Check what it extracts then make huge meta file for ALL dpcp data (split by sal/pcp)
''' 21/04/18 '''
# Instructions
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 16 11:18:00 2018
@author: u1490431
"""
###
1) Read in all 3 cohorts (individually) DPCP1, DPCP2, DPCP3
2) Separate into PCP and SALINE animals (possible to just look at saline)
3) Separate into lick day data (all and last) and distraction day data (main and hab)
4) Work out basic parameters for groups and days
(a) Number of bursts, clusters, runs
(b) Palatability for saccharin score based on these
(c) Mean. median number and length of bursts/etc
5) Predictive correlations or linear regression
6) Machine learning, support vector machines (with scores from lick day to predict distractedness)
7) Scores from distraction day to predict group membership (are they PCP or SAL)
8) Subtle differences in PCP, timings and intervals of licks on licks day
9) Different classifications of distracted or not?
10) Variables for statistical comparison
11) If no PCP effect, clear analysis of distraction behaviour
(a) What it does to bursts and licks
(b) How it affects consumption in general (is this still stable but structurally different)
# All data on R drive, move to hard drive for access and add the med files to git
# in 3 folders of DPCP1, DPCP2, DPCP3
# No metafile dor DPCP3!!
# Which is male and female? Checking over "sheets"
Medfilereader
Check what it extracts then make huge meta file for ALL dpcp data (split by sal/pcp)
N = 16 - amphetamine effect, NOR
N = 16 - amphetamine effects, NOR
N = 24 (female) - amphetamine effects, NOR
Percentage distracted
Number of bursts, number of clusters analysis
Metrics for means, medians, etc.
Literature searching
For each rat scores: NOR deficit or NOR DI (sal and pcp)
For each rat - number of bursts, clusters and licks on last lick day
For each rat - percentage distracted
For each rat - mean PDP
For each rat - short, medium, long bursts
For each rat - percent distracted amphetamine day
For each rat - lick behaviour amphetamine day (numbers of bursts, clusters)
REALLY DEFINE BURSTS, CLUSTERS, RUNS ETC. and come up with a "score" for
distraction. Percent distracted, pause length (on distracted trials and non-dis)
mean pause length for each rat ! Mean pause length as a whole and mean pause length
for JUST distracted and JUST non-distracted trials in EACH RAT :
Then an average of these for groups saline, pcp (can aggregate 2 cohorts)
Then show the females also (separate cohort with different treatment)
On distraction day, habituation day and AMPHETAMINE! Show no effects on saline
Can we reverse, dehabituate the habituation effect with dopamnergic drugs???
In saline and PCP animals
Licking frequency within the bursts (expecting 6Hz) see if this is different
in PCP
INDIVIDUAL DIFFERENCES - saline only here (for now)
Correlations of individual features (could make an aggregated "score")
Can these descriptors accurately predict (1) Distraction, (2) PCP/SAL
Rats preference or palatability of saccharin and the distractibility in later trials
AND habituation level
For all rats (sal) - mean number of bursts, clusters, last lick day
For all rats (pcp) - mean number of bursts, clusters, last lick day
For all rats (sal) - percentage distracted
PDPs mean as group
Modelled distractors whether they would be distracted or not individual and as
groups
General licking patterns, microstructure differences on lick days
How do we know it isnt just licking difference rather than distractability?
''' 22/04/18 '''
# Edited Metafiles to fix issues
# Replaced rat dpcp2.5 day 4 (lick train) data with day 3 (as missing file)
# changed date and day numbers to 06 and 4 (not 04 and 3) to fit with Python indices
# Double check the files can be very easily indexed (file licks linked to ratID and day)
# Editing MetaExtractor to read correct cols in Metafiles as saved
# Thinking and testing code to compare groups but also keep track of which
# individual rat is which (for matching in correlations) - be careful not
# to move/subset data in a way that losing access to rat ID
''' 23/04/17 '''
# Analyse all at a group level first, licking and distraction measures
# Then, use individual data to look at correlations and individual differences
# Need to analyse all NOR videos again and compare by goup
# Can also get the DI and add this to machine learning or group analysis
# Think about which figures to produce and include
# What is being compared to what and how can you show this graphically
''' 25/04/18 '''
# Issue with males code, something wrong with the OR and AND statements
# Is not always triggering the and (maybe need it twice)
# Female code works and does not have the or statement
# Debug by adding Drug info to the output
''' 27/04/18 '''
# Checked last lick day - correct subsetting against metafile for pcp/sal/m/f YES
# Check distraction day
# Check hab1, hab2, amph
# Added lickCalc loop, need to save all in massive list structure and average stuff!
''' 28/04/18 '''
# Fixed name issues in metafile, correct rat IDs on all
# Decide which variables to analyse from lick calc, compare mean and individual :
# lick frequency
# add bMed and rMed to lickCalc = np.median(lickData['bLicks']) --> KP 28/04 add this to runs too
# add rMean and similar to burst code to run code
'''
Make functions of the repeated code, for sal,pcp,m,f
Think about the outputs produced by the functions that you want
'''
''' 10/05/18 '''
# Supervisor meeting - discussing how to separate distractors by modality
# Work on adding this to the script later today (evening)
# Wrote some code for single rat, integrate this into the main script
# and using med file / med programme file. Work out which distractors are which numbers
# Checking that med distractor times match calculated distractors
#plt.scatter(med_dis_times, discalc)
#
#diffs = [x for x in med_dis_times if x not in discalc]
#
#diff_between = np.asarray(med_dis_times) - np.asarray(discalc)
''' 11/05/18 '''
# Decided there probably IS enough data to test individual distractor types
# See if combined is more distracting than the others?
# Don't really want 6 variables, seems like a lot and differences wont be clear
# Figure out how to compare, have lists for diatracted and non-distracted trials
# info on types, how to compare number of types, percentage of distracted trials
# that are (1), (2) or (3) vs percentage non-distracted trials that are 1,2,3 etc.
# Calculated the percentage of distracted trials that were X-type and percentage of
# non distracted trials that were X-distractor type
# Perhaps better to calculate percentage distracted for each modality (ie out of all X-type
# how many distracted)
# Thoughts: ----------------------------------------------------------------
## What if there is a high percentage of distracted because the rat is ALWAYS distracted
## Not because of the particular modality
## Maybe need to express as a ratio or percentage zero/referenced to the total
# percent distracted????
## Will then also have to repeat this whole thing for (1) PCP males, (2) SAL females and (3) PCP females
## Sanity check the numbers of each presented stimulus ))in case more of one((
## Do this for all rats and all distracted and non-distracted trials together
''' 14/05/18 '''
# Thinking about pre distraction pauses, calculated the interval between distractor and previous lick
# Actually want the distractor and before the 3 previous licks (before they started licking to
# receive the distractor)
matplotlib.collections.PolyCollection
''' 15/05/18 '''
# Run all functionsB, then violin plots adjuster, then distractionbehaviour, then plotting