aind-dynamic-foraging-basic-analysis 0.2.4__py3-none-any.whl → 0.2.5__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.
@@ -1,6 +1,6 @@
1
1
  """Init package"""
2
2
 
3
- __version__ = "0.2.4"
3
+ __version__ = "0.2.5"
4
4
 
5
5
  from .foraging_efficiency import compute_foraging_efficiency # noqa: F401
6
6
  from .plot.plot_foraging_session import plot_foraging_session # noqa: F401
@@ -321,7 +321,9 @@ def plot_foraging_session( # noqa: C901
321
321
  return ax_choice_reward.get_figure(), [ax_choice_reward, ax_reward_schedule]
322
322
 
323
323
 
324
- def plot_session_scroller(df_events, ax=None, adjust_time=True): # pragma: no cover
324
+ def plot_session_scroller( # noqa: C901 pragma: no cover
325
+ df_events, ax=None, adjust_time=True, fip_df=None
326
+ ):
325
327
  """
326
328
  Creates an interactive plot of the session.
327
329
  Plots left/right licks/rewards, and go cues
@@ -338,16 +340,31 @@ def plot_session_scroller(df_events, ax=None, adjust_time=True): # pragma: no c
338
340
 
339
341
  adjust_time (bool). If True, resets time=0 to the first event of the session
340
342
 
341
- EXAMPLE:
343
+ fip_df is a tidy dataframe of FIP measurements generated by
344
+ aind_dynamic_foraging_data_utils.nwb_utils.create_fib_df(tidy=True)
345
+
346
+ EXAMPLES:
342
347
  df_events = nwb_utils.create_events_df(nwb_object)
343
348
  plot_foraging_session.plot_session_scroller(df_events)
349
+
350
+ df_events = nwb_utils.create_events_df(nwb_object)
351
+ fip_df = nwb_utils.create_fib_df(nwb_object, tidy=True)
352
+ plot_foraging_session.plot_session_scroller(df_events,fip_df=fip_df)
344
353
  """
345
354
  if ax is None:
346
- fig, ax = plt.subplots(figsize=(15, 3))
355
+ if fip_df is None:
356
+ fig, ax = plt.subplots(figsize=(15, 3))
357
+ else:
358
+ fig, ax = plt.subplots(figsize=(15, 8))
347
359
 
348
360
  if adjust_time:
361
+ start_time = df_events.iloc[0]["timestamps"]
349
362
  df_events = df_events.copy()
350
- df_events["timestamps"] = df_events["timestamps"] - df_events.iloc[0]["timestamps"]
363
+ df_events["timestamps"] = df_events["timestamps"] - start_time
364
+
365
+ if fip_df is not None:
366
+ fip_df = fip_df.copy()
367
+ fip_df["timestamps"] = fip_df["timestamps"] - start_time
351
368
 
352
369
  xmin = df_events.iloc[0]["timestamps"]
353
370
  xmax = xmin + 20
@@ -364,6 +381,14 @@ def plot_session_scroller(df_events, ax=None, adjust_time=True): # pragma: no c
364
381
  "right_reward_top": 0.75,
365
382
  "go_cue_bottom": 0,
366
383
  "go_cue_top": 1,
384
+ "G_1_preprocessed_bottom": 1,
385
+ "G_1_preprocessed_top": 2,
386
+ "G_2_preprocessed_bottom": 2,
387
+ "G_2_preprocessed_top": 3,
388
+ "R_1_preprocessed_bottom": 3,
389
+ "R_1_preprocessed_top": 4,
390
+ "R_2_preprocessed_bottom": 4,
391
+ "R_2_preprocessed_top": 5,
367
392
  }
368
393
  yticks = [
369
394
  (params["left_lick_top"] - params["left_lick_bottom"]) / 2 + params["left_lick_bottom"],
@@ -374,6 +399,38 @@ def plot_session_scroller(df_events, ax=None, adjust_time=True): # pragma: no c
374
399
  + params["right_reward_bottom"],
375
400
  ]
376
401
  ylabels = ["left licks", "right licks", "left reward", "right reward"]
402
+ ycolors = ["k", "k", "r", "r"]
403
+
404
+ if fip_df is not None:
405
+ fip_channels = [
406
+ "G_2_preprocessed",
407
+ "G_1_preprocessed",
408
+ "R_2_preprocessed",
409
+ "R_1_preprocessed",
410
+ ]
411
+ present_channels = fip_df["event"].unique()
412
+ for index, channel in enumerate(fip_channels):
413
+ if channel in present_channels:
414
+ yticks.append(
415
+ (params[channel + "_top"] - params[channel + "_bottom"]) / 2
416
+ + params[channel + "_bottom"]
417
+ )
418
+ ylabels.append(channel)
419
+ if "G_1" in channel:
420
+ color = "g"
421
+ elif "G_2" in channel:
422
+ color = "darkgreen"
423
+ elif "R_1" in channel:
424
+ color = "r"
425
+ elif "R_2" in channel:
426
+ color = "darkred"
427
+ ycolors.append(color)
428
+ C = fip_df.query("event == @channel").copy()
429
+ C["data"] = C["data"] - C["data"].min()
430
+ C["data"] = C["data"].values / C["data"].max()
431
+ C["data"] += params[channel + "_bottom"]
432
+ ax.plot(C.timestamps.values, C.data.values, color)
433
+ ax.axhline(params[channel + "_bottom"], color="k", linewidth=0.5, alpha=0.25)
377
434
 
378
435
  left_licks = df_events.query('event == "left_lick_time"')
379
436
  left_times = left_licks.timestamps.values
@@ -433,11 +490,14 @@ def plot_session_scroller(df_events, ax=None, adjust_time=True): # pragma: no c
433
490
  # Clean up plot
434
491
  ax.set_yticks(yticks)
435
492
  ax.set_yticklabels(ylabels, fontsize=STYLE["axis_ticks_fontsize"])
436
- colors = ["k", "k", "r", "r"]
437
- for tick, color in zip(ax.get_yticklabels(), colors):
493
+
494
+ for tick, color in zip(ax.get_yticklabels(), ycolors):
438
495
  tick.set_color(color)
439
496
  ax.set_xlabel("time (s)", fontsize=STYLE["axis_fontsize"])
440
- ax.set_ylim(0, 1)
497
+ if fip_df is None:
498
+ ax.set_ylim(0, 1)
499
+ else:
500
+ ax.set_ylim(0, 5)
441
501
  ax.spines["top"].set_visible(False)
442
502
  ax.spines["right"].set_visible(False)
443
503
  plt.tight_layout()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aind-dynamic-foraging-basic-analysis
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Generated from aind-library-template
5
5
  Author: Allen Institute for Neural Dynamics
6
6
  License: MIT
@@ -0,0 +1,10 @@
1
+ aind_dynamic_foraging_basic_analysis/__init__.py,sha256=I1u00VHqldy7ddxEBVq9TkN98RDSTHPdQVeF7N-Dgj8,194
2
+ aind_dynamic_foraging_basic_analysis/foraging_efficiency.py,sha256=9IhMqQo_aU_RFsDu8D2P3-Qu3J72bo7sASC3dkUQ2YE,8634
3
+ aind_dynamic_foraging_basic_analysis/lick_analysis.py,sha256=Du6sP-Dfr6hBdRS98gc9Gp_kOq5TV_L80pDyj2WYctQ,20120
4
+ aind_dynamic_foraging_basic_analysis/data_model/foraging_session.py,sha256=7PFHfEIXP3QcjFS9Fk88S7PzBBYnUYw81WBjjEu_UKo,3536
5
+ aind_dynamic_foraging_basic_analysis/plot/plot_foraging_session.py,sha256=e_JNb-dTlX4XfZsPlJ7eabT69_Z179-JrlqvZTwNi6Y,18666
6
+ aind_dynamic_foraging_basic_analysis-0.2.5.dist-info/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
7
+ aind_dynamic_foraging_basic_analysis-0.2.5.dist-info/METADATA,sha256=hO3k4XkH9qNz0-cM39su4TvF3oLdewHZBJ5AargtjrY,6715
8
+ aind_dynamic_foraging_basic_analysis-0.2.5.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
9
+ aind_dynamic_foraging_basic_analysis-0.2.5.dist-info/top_level.txt,sha256=gc5fvvd3cR7uvCHkTaSx-TcC4JmKMt9dBYMPncEO8VY,37
10
+ aind_dynamic_foraging_basic_analysis-0.2.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (74.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- aind_dynamic_foraging_basic_analysis/__init__.py,sha256=ti2seCRcOdLN6XHXb1oId4MB7ghsQp5ScK7kSEs889k,194
2
- aind_dynamic_foraging_basic_analysis/foraging_efficiency.py,sha256=9IhMqQo_aU_RFsDu8D2P3-Qu3J72bo7sASC3dkUQ2YE,8634
3
- aind_dynamic_foraging_basic_analysis/lick_analysis.py,sha256=Du6sP-Dfr6hBdRS98gc9Gp_kOq5TV_L80pDyj2WYctQ,20120
4
- aind_dynamic_foraging_basic_analysis/data_model/foraging_session.py,sha256=7PFHfEIXP3QcjFS9Fk88S7PzBBYnUYw81WBjjEu_UKo,3536
5
- aind_dynamic_foraging_basic_analysis/plot/plot_foraging_session.py,sha256=xvOCDutonCDmPBfzeVL49pkV_nqsTiLZPxT5Obn5s6w,16388
6
- aind_dynamic_foraging_basic_analysis-0.2.4.dist-info/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
7
- aind_dynamic_foraging_basic_analysis-0.2.4.dist-info/METADATA,sha256=4cqyS-byYZFLPvZ3GxO7JiJ6MaE3T7aixFMmvNmp-ps,6715
8
- aind_dynamic_foraging_basic_analysis-0.2.4.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
9
- aind_dynamic_foraging_basic_analysis-0.2.4.dist-info/top_level.txt,sha256=gc5fvvd3cR7uvCHkTaSx-TcC4JmKMt9dBYMPncEO8VY,37
10
- aind_dynamic_foraging_basic_analysis-0.2.4.dist-info/RECORD,,