Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding computation and plotting of trial by trial metrics #26

Merged
merged 7 commits into from
Nov 13, 2024
Merged

Conversation

alexpiet
Copy link
Collaborator

@alexpiet alexpiet commented Nov 13, 2024

Updated plot_session_scroller to plot metrics

  • users can specify which metrics to plot by passing in a list of metrics to plot
  • metrics are plotted with or without FIP data
  • metrics are randomly colored, we might want to hardcode a color mapping later
  • added a marker to plot whether the port is baited

Trial by trial metrics:

  • response_rate, fraction of trials with a response
  • gocue_reward_rate, fraction of trials with a reward
  • response_reward_rate, fraction of trials with a reward computed only on trials with a response
  • choose_right_rate, fraction of trials where mouse chose right computed only on trials with a response
  • pL, generative reward probability on the left, just added plotting
  • pR, generative reward probability on the right, just added plotting

Future work:

  • There are many more metrics to add, but I wanted to merge this in so we have a stable ecosystem for metrics.
  • parameters for computing metrics (window duration, minimum number of events, whether to "center" the window) might want to be metric specific

DEMO

nwb.df_trials = compute_all_trial_metrics(nwb)
plot_session_scroller(nwb, plot_bouts=True, metrics=['response_rate','choose_right_rate'])
Screenshot 2024-11-13 at 12 03 17 PM

Another example with baiting and generative reward probabilities

nwb.df_trials = compute_all_trial_metrics(nwb)
nwb.fip_df = create_fib_df(nwb)
plot_session_scroller(nwb, plot_bouts=True, metrics=['pR','pL'])
Screenshot 2024-11-13 at 1 38 31 PM

@hanhou
Copy link
Collaborator

hanhou commented Nov 13, 2024

@alexpiet alexpiet marked this pull request as ready for review November 13, 2024 20:00
@alexpiet
Copy link
Collaborator Author

alexpiet commented Nov 13, 2024

@hanhou @rachelstephlee @nkeesey @ZhixiaoSu This is ready for review. I'd like to merge it in quickly. It would be good to agree on names for metrics

@alexpiet alexpiet requested a review from ZhixiaoSu November 13, 2024 20:04
MIN_EVENTS = 2


def compute_all_trial_metrics(nwb):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have more trial-based metrics here that can be migrated to this function.

Most of my metrics are not binary variables, so they may not need smoothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tracking them in this issue: #27

@hanhou
Copy link
Collaborator

hanhou commented Nov 13, 2024

Now the trial metrics are plotted in time-based plot. Do you think it makes sense to also add trial metrics to the trial-based session plot as well?

Also, it would be great to have a plotly version of all these plots, esp time-based plots with FIP. Then it will be very easy to visualize in Streamlit or Jupyter notebook

@hanhou
Copy link
Collaborator

hanhou commented Nov 13, 2024

I'll go ahead and approve this for now.

@alexpiet
Copy link
Collaborator Author

Tracking them in this consolidated issue: #27

@alexpiet
Copy link
Collaborator Author

trial-based session plot

Yes, made a separate issue here: #28

@alexpiet alexpiet merged commit dff9747 into main Nov 13, 2024
3 checks passed
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