Skip to content

adding auroc to session_metrics#103

Open
rachelstephlee wants to merge 4 commits into
mainfrom
auroc
Open

adding auroc to session_metrics#103
rachelstephlee wants to merge 4 commits into
mainfrom
auroc

Conversation

@rachelstephlee

Copy link
Copy Markdown
Collaborator

adding auroc calculation to each session and across multiple sessions.

@rachelstephlee rachelstephlee requested a review from alexpiet June 5, 2026 10:23
@alexpiet

alexpiet commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

looks good, let me test it before approving. Do you have an example code snippet of how to use?

@rachelstephlee

Copy link
Copy Markdown
Collaborator Author

Yes of course.

This is how I tested it:

alignment_times = nwb.df_trials.choice_time_in_session.values
labels = nwb.df_trials.earned_reward.values
channel = 'G_1_dff-bright_mc-iso-IRLS'
tw = [-1, 5.5]
bin_size = 0.25
data_col = 'data_z'
auc_df = compute_auroc(nwb, alignment_times, labels, channel, tw, bin_size, data_col)

plt.figure()
(fig, ax, align) = pf.plot_fip_psth_compare_alignments(
            nwb,
            [{"no rew": nwb.df_trials.query("earned_reward == 0").choice_time_in_session.values,
            "rew": nwb.df_trials.query("earned_reward == 1").choice_time_in_session.values}
            ],
            channel,
            tw=[-1, 5.5],
            extra_colors={"no rew": 'grey', "rew": 'magenta'},
            data_column="data_z"
            )
plt.plot(auc_df['bin_center'],auc_df['auc'], color='blue', label='auROC')

Let me know if I should add the former snippet into a README or ipynb for other users.

@alexpiet

Copy link
Copy Markdown
Collaborator

When I test it, I get this warning:

[/root/aind-dynamic-foraging-basic-analysis/src/aind_dynamic_foraging_basic_analysis/metrics/session_metrics.py:87](https://codeocean.allenneuraldynamics.org/root/aind-dynamic-foraging-basic-analysis/src/aind_dynamic_foraging_basic_analysis/metrics/session_metrics.py#line=86): FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  aligns.groupby(["bin_center", "event_number"])[data_col].mean().unstack(["event_number"])

@alexpiet alexpiet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

address the future warning, otherwise looks good

@rachelstephlee

Copy link
Copy Markdown
Collaborator Author

added observed=True explicitly to avoid the FutureWarning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants