Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ dependencies = [
'pathlib',
'numpy',
'pydantic',
'hdmf_zarr'
'hdmf_zarr',
'aind-dynamic-foraging-data-utils >= 0.1.25'
]

[project.optional-dependencies]
Expand Down
16 changes: 8 additions & 8 deletions src/aind_dynamic_foraging_basic_analysis/licks/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def annotate_licks(nwb):
nwb is an object that has df_events as an attribute
"""
if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return
nwb.df_licks = annotate_lick_bouts(nwb)
nwb.df_licks = annotate_artifacts(nwb)
Expand All @@ -57,7 +57,7 @@ def annotate_lick_bouts(nwb):
"""

if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return
df_licks = nwb.df_events.query('event in ["right_lick_time","left_lick_time"]').copy()
df_licks.reset_index(drop=True, inplace=True)
Expand Down Expand Up @@ -90,7 +90,7 @@ def annotate_artifacts(nwb):
nwb, an object with attributes: df_licks, df_events
"""
if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return

if not hasattr(nwb, "df_licks"):
Expand Down Expand Up @@ -122,7 +122,7 @@ def annotate_rewards(nwb):
"""

if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return

# ensure we have df_licks
Expand Down Expand Up @@ -183,7 +183,7 @@ def annotate_cue_response(nwb):
"""

if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return

# ensure we have df_licks
Expand Down Expand Up @@ -232,7 +232,7 @@ def annotate_intertrial_choices(nwb):
"""
# Add lick_bout annotation, and cue_response if not already added
if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return
if not hasattr(nwb, "df_licks"):
nwb.df_licks = annotate_lick_bouts(nwb)
Expand Down Expand Up @@ -267,7 +267,7 @@ def annotate_switches(nwb):
"""
# Add lick_bout annotation, and cue_response if not already added
if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return
if not hasattr(nwb, "df_licks"):
nwb.df_licks = annotate_lick_bouts(nwb)
Expand Down Expand Up @@ -337,7 +337,7 @@ def annotate_within_session(nwb):
"""

if not hasattr(nwb, "df_events"):
print("You need to compute df_events: nwb_utils.create_events_df(nwb)")
print("You need to compute df_events: nwb_utils.create_df_events(nwb)")
return

# ensure we have df_licks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def compute_trial_metrics(nwb):
"""
if not hasattr(nwb, "df_events"):
print("computing df_events first")
nwb.df_events = nu.create_events_df(nwb)
nwb.df_events = nu.create_df_events(nwb)

if not hasattr(nwb, "df_trials"):
print("computing df_trials")
Expand Down Expand Up @@ -340,7 +340,7 @@ def get_average_signal_window(
raise ValueError("You need to compute df_trials: nwb_utils.create_trials_df(nwb)")

if not hasattr(nwb, "df_fip"):
raise ValueError("You need to compute df_fip: nwb_utils.create_fib_df(nwb)")
raise ValueError("You need to compute df_fip: nwb_utils.create_df_fip(nwb)")

# Check alignment_event is in df_trials columns
if alignment_event not in nwb.df_trials.columns:
Expand Down
20 changes: 10 additions & 10 deletions src/aind_dynamic_foraging_basic_analysis/plot/plot_fip.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def plot_fip_psth_compare_alignments( # NOQA C901
for nwb_i in nwb_list:
if not hasattr(nwb_i, "df_fip"):
print("You need to compute the df_fip first")
print("running `nwb.df_fip = create_fib_df(nwb,tidy=True)`")
nwb_i.df_fip = nu.create_fib_df(nwb_i, tidy=True)
print("running `nwb.df_fip = create_df_fip(nwb,tidy=True)`")
nwb_i.df_fip = nu.create_df_fip(nwb_i, tidy=True)
if not hasattr(nwb_i, "df_events"):
print("You need to compute the df_events first")
print("run `nwb.df_events = create_events_df(nwb)`")
nwb_i.df_events = nu.create_events_df(nwb_i)
print("run `nwb.df_events = create_df_events(nwb)`")
nwb_i.df_events = nu.create_df_events(nwb_i)
if channel not in nwb_i.df_fip["event"].values:
print("channel {} not in df_fip".format(channel))

Expand Down Expand Up @@ -216,12 +216,12 @@ def plot_fip_psth_compare_channels( # NOQA C901
for nwb_i in nwb_list:
if not hasattr(nwb_i, "df_fip"):
print("You need to compute the df_fip first")
print("running `nwb.df_fip = create_fib_df(nwb,tidy=True)`")
nwb_i.df_fip = nu.create_fib_df(nwb_i, tidy=True)
print("running `nwb.df_fip = create_df_fip(nwb,tidy=True)`")
nwb_i.df_fip = nu.create_df_fip(nwb_i, tidy=True)
if not hasattr(nwb_i, "df_events"):
print("You need to compute the df_events first")
print("run `nwb.df_events = create_events_df(nwb)`")
nwb_i.df_events = nu.create_events_df(nwb_i)
print("run `nwb.df_events = create_df_events(nwb)`")
nwb_i.df_events = nu.create_df_events(nwb_i)

# Add warning if channels are missing
missing_channels = [c for c in channels if c not in nwb_i.df_fip["event"].values]
Expand Down Expand Up @@ -422,8 +422,8 @@ def plot_histogram(nwb, preprocessed=True, edge_percentile=2, data_column="data"
"""
if not hasattr(nwb, "df_fip"):
print("You need to compute the df_fip first")
print("running `nwb.df_fip = create_fib_df(nwb,tidy=True)`")
nwb.df_fip = nu.create_fib_df(nwb, tidy=True)
print("running `nwb.df_fip = create_df_fip(nwb,tidy=True)`")
nwb.df_fip = nu.create_df_fip(nwb, tidy=True)
return

fig, ax = plt.subplots(3, 2, sharex=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def plot_session_in_time_plotly( # noqa: C901 pragma: no cover
df_events: A tidy dataframe of session events.

fip_df is a tidy dataframe of FIP measurements generated by
aind_dynamic_foraging_data_utils.nwb_utils.create_fib_df(tidy=True)
aind_dynamic_foraging_data_utils.nwb_utils.create_df_fip(tidy=True)

adjust_time (bool): If True, resets time=0 to the first event of the session.

EXAMPLE:
df_events = nwb_utils.create_events_df(nwb_object)
fip_df = nwb_utils.create_fib_df(nwb_object, tidy=True)
df_events = nwb_utils.create_df_events(nwb_object)
fip_df = nwb_utils.create_df_fip(nwb_object, tidy=True)
plot_foraging_session_plotly.plot_session_events_plotly(df_events)
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def plot_session_scroller( # noqa: C901 pragma: no cover

if not hasattr(nwb, "df_events"):
print("computing df_events first")
nwb.df_events = nu.create_events_df(nwb)
nwb.df_events = nu.create_df_events(nwb)
df_events = nwb.df_events
else:
df_events = nwb.df_events
Expand Down