Skip to content

Commit

Permalink
#56 fixation dur over days
Browse files Browse the repository at this point in the history
  • Loading branch information
jess-breda committed Aug 31, 2024
1 parent fc82880 commit b9398ed
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/behav_viz/visualize/FixationGrower/exp_compare_alpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,49 @@
from behav_viz.visualize.df_preperation import compute_days_relative_to_stage


###################### FIXATION DUR #####################

#### OVER DAYS ####


def plot_fixation_dur_compare_experiment(
df,
ax=None,
title="",
min_stage=5,
max_stage=7,
relative_to_stage=5,
):

if ax is None:
fig, ax = pu.make_fig()

viz.FixationGrower.plots.plot_fixation_dur_over_days(
df,
ax=ax,
min_stage=min_stage,
max_stage=max_stage,
relative_to_stage=relative_to_stage,
title=title,
hue="fix_experiment",
hue_order=["V1", "V2"],
palette=pu.ALPHA_PALLETTE,
style="animal_id",
marker=".",
)

# handles, labels = ax.get_legend_handles_labels()
# from matplotlib.legend import Legend

# legend = Legend(
# ax, handles[0:2], labels[0:2], loc="best"
# ) # Adjust the index based on how many items you want
# ax.add_artist(legend)
# ax.legend(bbox_to_anchor=(1, 1))

return None


###################### FAILED FIXATION & VIOLATIONS ######################

#### OVER DAYS ####
Expand Down Expand Up @@ -423,6 +466,8 @@ def plot_days_to_reach_target_fix_boxplot_compare_experiment(
if ax.get_legend():
ax.legend_.remove()

sns.despine()

return None


Expand Down
41 changes: 41 additions & 0 deletions src/behav_viz/visualize/FixationGrower/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,44 @@ def plot_trial_structure(
ax.legend(loc="upper left")

return None


############################ FIXATION DUR ######################################


def plot_fixation_dur_over_days(
df,
min_stage=None,
max_stage=None,
relative_to_stage=5,
ax=None,
title="",
rotate_x_labels=False,
**kwargs,
):

df = compute_days_relative_to_stage(df, relative_to_stage)
x_var = f"days_relative_to_stage_{relative_to_stage}"
xlabel = f"Days rel to stage {relative_to_stage}"

if ax is None:
fig, ax = pu.make_fig()

sns.lineplot(
data=df.query("stage >= @min_stage and stage <= @max_stage"),
x=x_var,
y="fixation_dur",
estimator="max",
ax=ax,
**kwargs,
)

ax.grid()
ax.axhline(2, color="k", lw=2)

_ = ax.set(ylabel="Fix Dur [s]", xlabel=xlabel, title=title)

if rotate_x_labels:
ax.tick_params(rotation=0)

return None

0 comments on commit b9398ed

Please sign in to comment.