aind-dynamic-foraging-basic-analysis 0.3.3__py3-none-any.whl → 0.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aind_dynamic_foraging_basic_analysis/__init__.py +1 -1
- aind_dynamic_foraging_basic_analysis/licks/annotation.py +178 -12
- aind_dynamic_foraging_basic_analysis/licks/plot_interlick_interval.py +94 -0
- aind_dynamic_foraging_basic_analysis/plot/plot_session_scroller.py +41 -3
- aind_dynamic_foraging_basic_analysis/plot/style.py +9 -1
- {aind_dynamic_foraging_basic_analysis-0.3.3.dist-info → aind_dynamic_foraging_basic_analysis-0.3.4.dist-info}/METADATA +1 -1
- {aind_dynamic_foraging_basic_analysis-0.3.3.dist-info → aind_dynamic_foraging_basic_analysis-0.3.4.dist-info}/RECORD +10 -9
- {aind_dynamic_foraging_basic_analysis-0.3.3.dist-info → aind_dynamic_foraging_basic_analysis-0.3.4.dist-info}/WHEEL +1 -1
- {aind_dynamic_foraging_basic_analysis-0.3.3.dist-info → aind_dynamic_foraging_basic_analysis-0.3.4.dist-info}/LICENSE +0 -0
- {aind_dynamic_foraging_basic_analysis-0.3.3.dist-info → aind_dynamic_foraging_basic_analysis-0.3.4.dist-info}/top_level.txt +0 -0
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Tools for annotation of lick bouts
|
|
3
|
+
df_licks = annotate_licks(nwb)
|
|
3
4
|
df_licks = annotate_lick_bouts(nwb)
|
|
4
5
|
df_licks = annotate_rewards(nwb)
|
|
5
6
|
df_licks = annotate_cue_response(nwb)
|
|
7
|
+
df_licks = annotate_intertrial_choices(nwb)
|
|
8
|
+
df_licks = annotate_switches(nwb)
|
|
6
9
|
"""
|
|
7
10
|
|
|
8
11
|
import numpy as np
|
|
9
12
|
|
|
13
|
+
# Maximum time between a lick and a reward delivery to assign that reward to the lick
|
|
14
|
+
LICK_TO_REWARD_TOLERANCE = 0.25
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
# Maximum time between licks to label them as one bout
|
|
17
|
+
BOUT_THRESHOLD = 0.7
|
|
18
|
+
|
|
19
|
+
# Maximum time between go cue and first lick to label the lick as cue responsive
|
|
20
|
+
CUE_TO_LICK_TOLERANCE = 1
|
|
21
|
+
|
|
22
|
+
# Maximum time after the last go cue for a bout to start and be considered within the session
|
|
23
|
+
CUE_TO_SESSION_END_TOLERANCE = CUE_TO_LICK_TOLERANCE
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def annotate_licks(nwb):
|
|
27
|
+
"""
|
|
28
|
+
Adds all annotations
|
|
29
|
+
nwb is an object that has df_events as an attribute
|
|
30
|
+
"""
|
|
31
|
+
nwb.df_licks = annotate_lick_bouts(nwb)
|
|
32
|
+
nwb.df_licks = annotate_rewards(nwb)
|
|
33
|
+
nwb.df_licks = annotate_cue_response(nwb)
|
|
34
|
+
nwb.df_licks = annotate_intertrial_choices(nwb)
|
|
35
|
+
nwb.df_licks = annotate_switches(nwb)
|
|
36
|
+
nwb.df_licks = annotate_within_session(nwb)
|
|
37
|
+
return nwb.df_licks
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def annotate_lick_bouts(nwb):
|
|
12
41
|
"""
|
|
13
42
|
returns a dataframe of lick times with annotations
|
|
14
43
|
pre_ili, the elapsed time since the last lick (on either side)
|
|
@@ -17,8 +46,7 @@ def annotate_lick_bouts(nwb, bout_threshold=0.7):
|
|
|
17
46
|
bout_end (bool), whether this was the end of a lick bout)
|
|
18
47
|
bout_number (int), what lick bout this was a part of
|
|
19
48
|
|
|
20
|
-
nwb, an
|
|
21
|
-
bout_threshold is the ILI that determines bout segmentation
|
|
49
|
+
nwb, an object with attributes: df_events
|
|
22
50
|
"""
|
|
23
51
|
|
|
24
52
|
if not hasattr(nwb, "df_events"):
|
|
@@ -32,8 +60,8 @@ def annotate_lick_bouts(nwb, bout_threshold=0.7):
|
|
|
32
60
|
df_licks["post_ili"] = np.concatenate([np.diff(df_licks.timestamps.values), [np.nan]])
|
|
33
61
|
|
|
34
62
|
# Assign licks into bouts
|
|
35
|
-
df_licks["bout_start"] = df_licks["pre_ili"] >
|
|
36
|
-
df_licks["bout_end"] = df_licks["post_ili"] >
|
|
63
|
+
df_licks["bout_start"] = df_licks["pre_ili"] > BOUT_THRESHOLD
|
|
64
|
+
df_licks["bout_end"] = df_licks["post_ili"] > BOUT_THRESHOLD
|
|
37
65
|
df_licks.loc[df_licks["pre_ili"].isnull(), "bout_start"] = True
|
|
38
66
|
df_licks.loc[df_licks["post_ili"].isnull(), "bout_end"] = True
|
|
39
67
|
df_licks["bout_number"] = np.cumsum(df_licks["bout_start"])
|
|
@@ -51,11 +79,11 @@ def annotate_lick_bouts(nwb, bout_threshold=0.7):
|
|
|
51
79
|
def annotate_rewards(nwb):
|
|
52
80
|
"""
|
|
53
81
|
Annotates df_licks with which lick triggered each reward
|
|
54
|
-
|
|
82
|
+
rewarded (bool) did this lick trigger a reward
|
|
83
|
+
bout_rewarded (bool) did this lick bout trigger a reward
|
|
84
|
+
nwb, an object with attributes: df_licks, df_events
|
|
55
85
|
"""
|
|
56
86
|
|
|
57
|
-
LICK_TO_REWARD_TOLERANCE = 0.25
|
|
58
|
-
|
|
59
87
|
if not hasattr(nwb, "df_events"):
|
|
60
88
|
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
|
|
61
89
|
return
|
|
@@ -81,7 +109,6 @@ def annotate_rewards(nwb):
|
|
|
81
109
|
)[0]
|
|
82
110
|
if len(this_reward_lick_times) > 0:
|
|
83
111
|
df_licks.at[this_reward_lick_times[-1], "rewarded"] = True
|
|
84
|
-
# TODO, should check for licks that happened before the last go cue
|
|
85
112
|
# TODO, if we can't find a matching lick, should ensure this is manual or auto water
|
|
86
113
|
|
|
87
114
|
# Iterate left rewards, and find most recent lick within tolerance
|
|
@@ -113,11 +140,11 @@ def annotate_rewards(nwb):
|
|
|
113
140
|
def annotate_cue_response(nwb):
|
|
114
141
|
"""
|
|
115
142
|
Annotates df_licks with which lick was immediately after a go cue
|
|
116
|
-
|
|
143
|
+
cue_response (bool) was this lick immediately after a go cue
|
|
144
|
+
bout_cue_response (bool) was this licking bout immediately after a go cue
|
|
145
|
+
nwb, an object with attributes: df_licks, df_events
|
|
117
146
|
"""
|
|
118
147
|
|
|
119
|
-
CUE_TO_LICK_TOLERANCE = 1
|
|
120
|
-
|
|
121
148
|
if not hasattr(nwb, "df_events"):
|
|
122
149
|
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
|
|
123
150
|
return
|
|
@@ -140,6 +167,7 @@ def annotate_cue_response(nwb):
|
|
|
140
167
|
(df_licks.timestamps > row.timestamps)
|
|
141
168
|
& (df_licks.timestamps <= (row.timestamps + CUE_TO_LICK_TOLERANCE))
|
|
142
169
|
& ((df_licks.event == "right_lick_time") | (df_licks.event == "left_lick_time"))
|
|
170
|
+
& (df_licks.bout_start)
|
|
143
171
|
)[0]
|
|
144
172
|
if len(this_lick_times) > 0:
|
|
145
173
|
df_licks.at[this_lick_times[0], "cue_response"] = True
|
|
@@ -157,3 +185,141 @@ def annotate_cue_response(nwb):
|
|
|
157
185
|
df_licks["bout_cue_response"] = temp["bout_cue_response"]
|
|
158
186
|
|
|
159
187
|
return df_licks
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def annotate_intertrial_choices(nwb):
|
|
191
|
+
"""
|
|
192
|
+
annotate licks and lick bouts as intertrial choices if they are not cue_responsive
|
|
193
|
+
intertrial_choice (bool) was this lick the start of a non-cue-responsive bout
|
|
194
|
+
bout_intertrial_choice (bool) was this bout non-cue-responsive?
|
|
195
|
+
"""
|
|
196
|
+
# Add lick_bout annotation, and cue_response if not already added
|
|
197
|
+
if not hasattr(nwb, "df_events"):
|
|
198
|
+
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
|
|
199
|
+
return
|
|
200
|
+
if not hasattr(nwb, "df_licks"):
|
|
201
|
+
nwb.df_licks = annotate_lick_bouts(nwb)
|
|
202
|
+
if "cue_response" not in nwb.df_licks:
|
|
203
|
+
nwb.df_licks = annotate_cue_response(nwb)
|
|
204
|
+
|
|
205
|
+
# Make a copy
|
|
206
|
+
df_licks = nwb.df_licks.copy()
|
|
207
|
+
|
|
208
|
+
# Define intertrial choices
|
|
209
|
+
df_licks["intertrial_choice"] = df_licks["bout_start"] & ~df_licks["cue_response"]
|
|
210
|
+
|
|
211
|
+
# Annotate lick bouts as intertrial_choice
|
|
212
|
+
x = (
|
|
213
|
+
df_licks.groupby("bout_number")
|
|
214
|
+
.any("intertrial_choice")
|
|
215
|
+
.rename(columns={"intertrial_choice": "bout_intertrial_choice"})["bout_intertrial_choice"]
|
|
216
|
+
)
|
|
217
|
+
df_licks["bout_intertrial_choice"] = False
|
|
218
|
+
temp = df_licks.reset_index().set_index("bout_number").copy()
|
|
219
|
+
temp.update(x)
|
|
220
|
+
temp = temp.reset_index().set_index("index")
|
|
221
|
+
df_licks["bout_intertrial_choice"] = temp["bout_intertrial_choice"]
|
|
222
|
+
|
|
223
|
+
return df_licks
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def annotate_switches(nwb):
|
|
227
|
+
"""
|
|
228
|
+
cue_switch: this cue_choice differs from the previous cue_choice
|
|
229
|
+
iti_switch: this intertrial_choice differs from the previous choice (iti or cue)
|
|
230
|
+
"""
|
|
231
|
+
# Add lick_bout annotation, and cue_response if not already added
|
|
232
|
+
if not hasattr(nwb, "df_events"):
|
|
233
|
+
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
|
|
234
|
+
return
|
|
235
|
+
if not hasattr(nwb, "df_licks"):
|
|
236
|
+
nwb.df_licks = annotate_lick_bouts(nwb)
|
|
237
|
+
if "cue_response" not in nwb.df_licks:
|
|
238
|
+
nwb.df_licks = annotate_cue_response(nwb)
|
|
239
|
+
if "intertrial_choice" not in nwb.df_licks:
|
|
240
|
+
nwb.df_licks = annotate_intertrial_choices(nwb)
|
|
241
|
+
|
|
242
|
+
# Make a copy
|
|
243
|
+
df_licks = nwb.df_licks.copy()
|
|
244
|
+
|
|
245
|
+
# Compute cue_switch labels
|
|
246
|
+
df_cue_bouts = df_licks.query("bout_start").query("cue_response").copy()
|
|
247
|
+
if len(df_cue_bouts) > 0:
|
|
248
|
+
df_cue_bouts["cue_switch"] = (
|
|
249
|
+
df_cue_bouts["event"].shift(1, fill_value=df_cue_bouts.iloc[0]["event"])
|
|
250
|
+
!= df_cue_bouts["event"]
|
|
251
|
+
)
|
|
252
|
+
else:
|
|
253
|
+
df_cue_bouts["cue_switch"] = []
|
|
254
|
+
|
|
255
|
+
# Compute iti_switch labels
|
|
256
|
+
df_bouts = df_licks.query("bout_start").copy()
|
|
257
|
+
df_bouts["iti_switch"] = df_bouts["intertrial_choice"] & (
|
|
258
|
+
df_bouts["event"].shift(1, fill_value=df_bouts.iloc[0]["event"]) != df_bouts["event"]
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
# Add columns to df_licks
|
|
262
|
+
df_licks = df_licks.join(df_cue_bouts["cue_switch"], how="left")
|
|
263
|
+
df_licks = df_licks.join(df_bouts["iti_switch"], how="left")
|
|
264
|
+
|
|
265
|
+
# Fill NaNs as False
|
|
266
|
+
df_licks["cue_switch"] = df_licks["cue_switch"] == True # noqa: E712
|
|
267
|
+
df_licks["iti_switch"] = df_licks["iti_switch"] == True # noqa: E712
|
|
268
|
+
|
|
269
|
+
# Annotate lick bouts as cue_switch
|
|
270
|
+
x = (
|
|
271
|
+
df_licks.groupby("bout_number")
|
|
272
|
+
.any("cue_switch")
|
|
273
|
+
.rename(columns={"cue_switch": "bout_cue_switch"})["bout_cue_switch"]
|
|
274
|
+
)
|
|
275
|
+
df_licks["bout_cue_switch"] = False
|
|
276
|
+
temp = df_licks.reset_index().set_index("bout_number").copy()
|
|
277
|
+
temp.update(x)
|
|
278
|
+
temp = temp.reset_index().set_index("index")
|
|
279
|
+
df_licks["bout_cue_switch"] = temp["bout_cue_switch"]
|
|
280
|
+
|
|
281
|
+
# Annotate lick bouts as iti_switch
|
|
282
|
+
x = (
|
|
283
|
+
df_licks.groupby("bout_number")
|
|
284
|
+
.any("iti_switch")
|
|
285
|
+
.rename(columns={"iti_switch": "bout_iti_switch"})["bout_iti_switch"]
|
|
286
|
+
)
|
|
287
|
+
df_licks["bout_iti_switch"] = False
|
|
288
|
+
temp = df_licks.reset_index().set_index("bout_number").copy()
|
|
289
|
+
temp.update(x)
|
|
290
|
+
temp = temp.reset_index().set_index("index")
|
|
291
|
+
df_licks["bout_iti_switch"] = temp["bout_iti_switch"]
|
|
292
|
+
|
|
293
|
+
return df_licks
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def annotate_within_session(nwb):
|
|
297
|
+
"""
|
|
298
|
+
within_session: this lick happened after the first go cue,
|
|
299
|
+
or < CUE_TO_SESSION_END_TOLERANCE after the last go cue
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
if not hasattr(nwb, "df_events"):
|
|
303
|
+
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
|
|
304
|
+
return
|
|
305
|
+
|
|
306
|
+
# ensure we have df_licks
|
|
307
|
+
if not hasattr(nwb, "df_licks"):
|
|
308
|
+
print("annotating lick bouts")
|
|
309
|
+
nwb.df_licks = annotate_lick_bouts(nwb)
|
|
310
|
+
|
|
311
|
+
# make a copy of df licks
|
|
312
|
+
df_licks = nwb.df_licks.copy()
|
|
313
|
+
|
|
314
|
+
# Test for no go cues
|
|
315
|
+
goCues = nwb.df_events.query('event == "goCue_start_time"')
|
|
316
|
+
if len(goCues) == 0:
|
|
317
|
+
df_licks["within_session"] = False
|
|
318
|
+
else:
|
|
319
|
+
start_time = goCues.iloc[0]["timestamps"]
|
|
320
|
+
end_time = goCues.iloc[-1]["timestamps"] + CUE_TO_SESSION_END_TOLERANCE
|
|
321
|
+
df_licks["within_session"] = (start_time <= df_licks["timestamps"]) & (
|
|
322
|
+
df_licks["timestamps"] < end_time
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
return df_licks
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Compute and plot interlick interval, determine appropriate threshold for bout segmentation
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
7
|
+
from aind_dynamic_foraging_basic_analysis.licks import annotation as a
|
|
8
|
+
from aind_dynamic_foraging_basic_analysis.plot.style import STYLE
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def plot_interlick_interval(licks_df, key="pre_ili", categories=None, nbins=80, xmax=10):
|
|
12
|
+
"""
|
|
13
|
+
Plots a histogram of <key> split by unique values of <categories>
|
|
14
|
+
licks_df (dataframe)
|
|
15
|
+
key (string), column of licks_df
|
|
16
|
+
categories (string), column of licks_df with discrete values
|
|
17
|
+
nbins (int), number of bins for histogram
|
|
18
|
+
xmax (float), the maximum interlick interval to plot
|
|
19
|
+
|
|
20
|
+
Plot interlick interval of all licks
|
|
21
|
+
>> plot_interlick_interval(df_licks)
|
|
22
|
+
|
|
23
|
+
plot interlick interval for left and right licks separately
|
|
24
|
+
>> plot_interlick_interval(df_licks, categories='event')
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
if key not in licks_df:
|
|
28
|
+
print('key "{}" not in dataframe'.format(key))
|
|
29
|
+
return
|
|
30
|
+
if (categories is not None) and (categories not in licks_df):
|
|
31
|
+
print('categories "{}" not in dataframe'.format(categories))
|
|
32
|
+
return
|
|
33
|
+
|
|
34
|
+
# Remove NaNs (from start of session) and limit to range defined by xmax
|
|
35
|
+
licks_df = licks_df.dropna(subset=[key]).query("{} < @xmax".format(key)).copy()
|
|
36
|
+
|
|
37
|
+
if categories is not None:
|
|
38
|
+
licks_df = licks_df.dropna(subset=[categories]).copy()
|
|
39
|
+
if key == "pre_ili":
|
|
40
|
+
xlabel = "interlick interval (s)"
|
|
41
|
+
yscale = 4
|
|
42
|
+
else:
|
|
43
|
+
xlabel = key
|
|
44
|
+
yscale = 1.5
|
|
45
|
+
|
|
46
|
+
# Plot Figure
|
|
47
|
+
fig, ax = plt.subplots(figsize=(5, 4))
|
|
48
|
+
counts, edges = np.histogram(licks_df[key].values, nbins)
|
|
49
|
+
if categories is None:
|
|
50
|
+
# We have only one group of data
|
|
51
|
+
plt.hist(
|
|
52
|
+
licks_df[key].values,
|
|
53
|
+
bins=edges,
|
|
54
|
+
color=STYLE["data_color_all"],
|
|
55
|
+
alpha=STYLE["data_alpha"],
|
|
56
|
+
)
|
|
57
|
+
else:
|
|
58
|
+
# We have multiple groups of data
|
|
59
|
+
groups = licks_df[categories].unique()
|
|
60
|
+
colors = {"left_lick_time": "b", "right_lick_time": "r"}
|
|
61
|
+
for index, g in enumerate(groups):
|
|
62
|
+
df = licks_df.query(categories + " == @g")
|
|
63
|
+
if isinstance(g, bool) or isinstance(g, np.bool_):
|
|
64
|
+
if g:
|
|
65
|
+
label = categories
|
|
66
|
+
else:
|
|
67
|
+
label = "not " + categories
|
|
68
|
+
label = label
|
|
69
|
+
else:
|
|
70
|
+
label = g
|
|
71
|
+
plt.hist(df[key].values, bins=edges, alpha=0.5, color=colors[g], label=label)
|
|
72
|
+
|
|
73
|
+
# Clean up
|
|
74
|
+
plt.ylim(top=np.sort(counts)[-2] * yscale)
|
|
75
|
+
|
|
76
|
+
plt.xlim(0, xmax)
|
|
77
|
+
plt.axvline(
|
|
78
|
+
a.BOUT_THRESHOLD,
|
|
79
|
+
color=STYLE["axline_color"],
|
|
80
|
+
linestyle=STYLE["axline_linestyle"],
|
|
81
|
+
alpha=STYLE["axline_alpha"],
|
|
82
|
+
label="Licking bout threshold",
|
|
83
|
+
)
|
|
84
|
+
ax.set_ylabel("count", fontsize=STYLE["axis_fontsize"])
|
|
85
|
+
ax.set_xlabel(xlabel, fontsize=STYLE["axis_fontsize"])
|
|
86
|
+
plt.xticks(fontsize=STYLE["axis_ticks_fontsize"])
|
|
87
|
+
plt.yticks(fontsize=STYLE["axis_ticks_fontsize"])
|
|
88
|
+
plt.legend(frameon=False, fontsize=STYLE["axis_ticks_fontsize"])
|
|
89
|
+
ax.spines["top"].set_visible(False)
|
|
90
|
+
ax.spines["right"].set_visible(False)
|
|
91
|
+
|
|
92
|
+
if categories is not None:
|
|
93
|
+
plt.legend(frameon=False, fontsize=STYLE["axis_ticks_fontsize"])
|
|
94
|
+
plt.tight_layout()
|
|
@@ -52,8 +52,7 @@ def plot_session_scroller( # noqa: C901 pragma: no cover
|
|
|
52
52
|
df_licks = nwb.df_licks
|
|
53
53
|
elif plot_bouts:
|
|
54
54
|
print("computing df_licks first")
|
|
55
|
-
nwb.df_licks = a.
|
|
56
|
-
nwb.df_licks = a.annotate_rewards(nwb)
|
|
55
|
+
nwb.df_licks = a.annotate_licks(nwb)
|
|
57
56
|
df_licks = nwb.df_licks
|
|
58
57
|
else:
|
|
59
58
|
df_licks = None
|
|
@@ -214,10 +213,19 @@ def plot_session_scroller( # noqa: C901 pragma: no cover
|
|
|
214
213
|
linewidth=2,
|
|
215
214
|
color=cmap(np.mod(b, 20)),
|
|
216
215
|
)
|
|
216
|
+
|
|
217
|
+
# plot licks that trigger left rewards
|
|
217
218
|
left_rewarded_licks = df_licks.query(
|
|
218
219
|
'(event == "left_lick_time")&(rewarded)'
|
|
219
220
|
).timestamps.values
|
|
220
|
-
ax.plot(
|
|
221
|
+
ax.plot(
|
|
222
|
+
left_rewarded_licks,
|
|
223
|
+
[params["left_lick_top"]] * len(left_rewarded_licks),
|
|
224
|
+
"ro",
|
|
225
|
+
label="rewarded lick",
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
# Plot licks that trigger right rewards
|
|
221
229
|
right_rewarded_licks = df_licks.query(
|
|
222
230
|
'(event == "right_lick_time")&(rewarded)'
|
|
223
231
|
).timestamps.values
|
|
@@ -225,6 +233,33 @@ def plot_session_scroller( # noqa: C901 pragma: no cover
|
|
|
225
233
|
right_rewarded_licks, [params["right_lick_bottom"]] * len(right_rewarded_licks), "ro"
|
|
226
234
|
)
|
|
227
235
|
|
|
236
|
+
# plot cue responsive licks
|
|
237
|
+
left_cue_licks = df_licks.query(
|
|
238
|
+
'(event == "left_lick_time")&(cue_response)'
|
|
239
|
+
).timestamps.values
|
|
240
|
+
ax.plot(
|
|
241
|
+
left_cue_licks,
|
|
242
|
+
[
|
|
243
|
+
params["left_lick_bottom"]
|
|
244
|
+
+ (params["left_lick_top"] - params["left_lick_bottom"]) / 2
|
|
245
|
+
]
|
|
246
|
+
* len(left_cue_licks),
|
|
247
|
+
"bD",
|
|
248
|
+
label="cue responsive lick",
|
|
249
|
+
)
|
|
250
|
+
right_cue_licks = df_licks.query(
|
|
251
|
+
'(event == "right_lick_time")&(cue_response)'
|
|
252
|
+
).timestamps.values
|
|
253
|
+
ax.plot(
|
|
254
|
+
right_cue_licks,
|
|
255
|
+
[
|
|
256
|
+
params["right_lick_bottom"]
|
|
257
|
+
+ (params["right_lick_top"] - params["right_lick_bottom"]) / 2
|
|
258
|
+
]
|
|
259
|
+
* len(right_cue_licks),
|
|
260
|
+
"bD",
|
|
261
|
+
)
|
|
262
|
+
|
|
228
263
|
left_reward_deliverys = df_events.query('event == "left_reward_delivery_time"')
|
|
229
264
|
left_times = left_reward_deliverys.timestamps.values
|
|
230
265
|
ax.vlines(
|
|
@@ -234,6 +269,7 @@ def plot_session_scroller( # noqa: C901 pragma: no cover
|
|
|
234
269
|
alpha=1,
|
|
235
270
|
linewidth=2,
|
|
236
271
|
color="r",
|
|
272
|
+
label="reward times",
|
|
237
273
|
)
|
|
238
274
|
|
|
239
275
|
right_reward_deliverys = df_events.query('event == "right_reward_delivery_time"')
|
|
@@ -256,9 +292,11 @@ def plot_session_scroller( # noqa: C901 pragma: no cover
|
|
|
256
292
|
alpha=0.75,
|
|
257
293
|
linewidth=1,
|
|
258
294
|
color="b",
|
|
295
|
+
label="go cue",
|
|
259
296
|
)
|
|
260
297
|
|
|
261
298
|
# Clean up plot
|
|
299
|
+
ax.legend(framealpha=1, loc="lower left", reverse=True)
|
|
262
300
|
ax.set_yticks(yticks)
|
|
263
301
|
ax.set_yticklabels(ylabels, fontsize=STYLE["axis_ticks_fontsize"])
|
|
264
302
|
|
|
@@ -3,7 +3,15 @@
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
# General plotting style
|
|
6
|
-
STYLE = {
|
|
6
|
+
STYLE = {
|
|
7
|
+
"axis_ticks_fontsize": 12,
|
|
8
|
+
"axis_fontsize": 16,
|
|
9
|
+
"data_color_all": "blue",
|
|
10
|
+
"data_alpha": 1,
|
|
11
|
+
"axline_color": "k",
|
|
12
|
+
"axline_linestyle": "-",
|
|
13
|
+
"axline_alpha": 0.5,
|
|
14
|
+
}
|
|
7
15
|
|
|
8
16
|
# Colorscheme for photostim
|
|
9
17
|
PHOTOSTIM_EPOCH_MAPPING = {
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
aind_dynamic_foraging_basic_analysis/__init__.py,sha256=
|
|
1
|
+
aind_dynamic_foraging_basic_analysis/__init__.py,sha256=xItEwN8jDvfSUlrqcNzC95XewK3CUDvA4s5a1TcEVH0,194
|
|
2
2
|
aind_dynamic_foraging_basic_analysis/foraging_efficiency.py,sha256=9IhMqQo_aU_RFsDu8D2P3-Qu3J72bo7sASC3dkUQ2YE,8634
|
|
3
3
|
aind_dynamic_foraging_basic_analysis/data_model/foraging_session.py,sha256=7PFHfEIXP3QcjFS9Fk88S7PzBBYnUYw81WBjjEu_UKo,3536
|
|
4
|
-
aind_dynamic_foraging_basic_analysis/licks/annotation.py,sha256=
|
|
4
|
+
aind_dynamic_foraging_basic_analysis/licks/annotation.py,sha256=jJpP9crk4pOgij8d2FxHvOlWNkfnvO2R4hW2ANAMcjE,11997
|
|
5
5
|
aind_dynamic_foraging_basic_analysis/licks/lick_analysis.py,sha256=tgFqowzXHMRW2aCXhDi5SFE3Lfj_VMuMG1QPggkW9WE,20158
|
|
6
|
+
aind_dynamic_foraging_basic_analysis/licks/plot_interlick_interval.py,sha256=fldIAzB_Hml7S0xlfUCK1UeNpzRaWdrufXd4FaqKooY,3333
|
|
6
7
|
aind_dynamic_foraging_basic_analysis/plot/plot_fip.py,sha256=_KiEAonrsDrV-ReipDzKEPoKFTgV_E9IUCwVJTR5jac,8414
|
|
7
8
|
aind_dynamic_foraging_basic_analysis/plot/plot_foraging_session.py,sha256=yfxqEu522DkBaD20R8BBBAmII4asu3mZ3psGUdUxqEQ,11534
|
|
8
9
|
aind_dynamic_foraging_basic_analysis/plot/plot_foraging_session_plotly.py,sha256=wE-kl1W6KZjaMX08bjawWfSuse6KW6YNSxDbdph3XK0,6715
|
|
9
|
-
aind_dynamic_foraging_basic_analysis/plot/plot_session_scroller.py,sha256=
|
|
10
|
-
aind_dynamic_foraging_basic_analysis/plot/style.py,sha256=
|
|
11
|
-
aind_dynamic_foraging_basic_analysis-0.3.
|
|
12
|
-
aind_dynamic_foraging_basic_analysis-0.3.
|
|
13
|
-
aind_dynamic_foraging_basic_analysis-0.3.
|
|
14
|
-
aind_dynamic_foraging_basic_analysis-0.3.
|
|
15
|
-
aind_dynamic_foraging_basic_analysis-0.3.
|
|
10
|
+
aind_dynamic_foraging_basic_analysis/plot/plot_session_scroller.py,sha256=LopgwLGUwpXjAA6ofQfO-DBLPi0ybcDzYZTENd1CreM,11530
|
|
11
|
+
aind_dynamic_foraging_basic_analysis/plot/style.py,sha256=UQxCqxnuMJcsRd6j-QGCA_E5XudrC9H2lNltmzmTK1E,1288
|
|
12
|
+
aind_dynamic_foraging_basic_analysis-0.3.4.dist-info/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
|
|
13
|
+
aind_dynamic_foraging_basic_analysis-0.3.4.dist-info/METADATA,sha256=qL507m4jwA-6oCsEQ-qLfL3Iy1YdcukahqzU1tXN7f8,6737
|
|
14
|
+
aind_dynamic_foraging_basic_analysis-0.3.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
15
|
+
aind_dynamic_foraging_basic_analysis-0.3.4.dist-info/top_level.txt,sha256=gc5fvvd3cR7uvCHkTaSx-TcC4JmKMt9dBYMPncEO8VY,37
|
|
16
|
+
aind_dynamic_foraging_basic_analysis-0.3.4.dist-info/RECORD,,
|
|
File without changes
|