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

Planning: standardized dynamic foraging analysis #16

Open
4 of 18 tasks
hanhou opened this issue Mar 6, 2024 · 11 comments
Open
4 of 18 tasks

Planning: standardized dynamic foraging analysis #16

hanhou opened this issue Mar 6, 2024 · 11 comments
Assignees
Labels

Comments

@hanhou
Copy link
Collaborator

hanhou commented Mar 6, 2024

Session-wise analysis

Here let's brainstorm what standardized analyses and plots we want to have for each behavioral session. They will be plugged into the pipeline and appear in the Streamlit app within 24 hrs after the session.

  1. Basic analysis (will go to Repo 2 below)

  2. Model fittings on animal choice (will go to Repo 3 below)

  3. Video analysis

    • Basic analysis such as motion energy etc. (will go to Repo 4 below)
    • Supervised methods: DLC/LP (this capsule?)
    • Unsupervised methods: auto-encoder such as BehavNet (Faeze; not ready for standardization)
    • HMM analysis on extracted (latent) video trajectories (not ready for standardization)

How should we organize the repos?

We should divide things across multiple repos. Originally posted by @jsiegle in #8:

My inclination to divide things across multiple repos also stems from my experience with the AllenSDK. If all analysis code lives in one package, it starts to develop idiosyncrasies that make it difficult for others to reuse/contribute to. The biggest problem with the AllenSDK was probably the fact that numerous pinned dependencies made it impossible to install in an existing environment, but a tangential problem was that its monolithic nature meant that very few people inside the Institute actually used it as a starting point for exploratory analysis. Obviously we are not trying to create something on the same scale, but I think it's important to plan for the type of code ecosystem we want to end up with before investing significant time building shared packages.

See section PROPOSED REPOSITORY STRUCTURE of this doc. And here is an excerpt from the part relevant to foraging behavior.

Repo 1: aind-dynamic-forgaing-data-utils

  • Purpose: Ingests NWB and spits out dataframes with the relevant information. Focused on dynamic foraging. Other tasks can branch and build task-specific utils.
  • Inputs are nwbs, outputs are dataframes (tidy and not)
  • Dependencies: xarray (includes numpy and pandas), scikit-learn (includes scipy), matplotlib
  • Example functions:
    • nwb_to_dataframe()
    • align_to_behavior()

Repo 2: aind-dynamic-foraging-basic-analysis

  • Purpose: extract basic session-wise (e.g. foraging efficiency) and trial-wise statistics (e.g. reaction time); generate basic plots that will be put in the data visualization app. include functions that understand task structure; encourage code reuse across everyone working on the same project
  • Inputs are dataframes, NOT nwbs
  • Dependencies: aind-nwb-utils, aind-ephys-utils, aind-ophys-utils, aind-behavior-utils
  • Other desired functions:
    • plot_licks() - plot lick times relative to key events
    • plot_reward/choice_history()
    • regress_behavior()
  • Other potential repositories: patch-foraging-analysis, dynamic-routing-analysis

Repo 3: aind-dynamic-foraging-models

  • Purpose: a place to put dynamic-foraging related descriptive models (e.g,. logistic regression), generative models (e.g., Q-learning and Bayesian inference model), and their associated model fitting modules. The generative model should have separately coded agents that can be readily plugged into any simulation. The fitting function should return all fitted parameters and metrics such as AIC and BIC.
  • Dependencies:
  • Example functions: Logistic regression models (Han), RL models (Han), and a CO capsule refactored by Stefano (with pipeline too)

Repo 4: aind-dynamic-foraging-video-analysis

  • Purpose:
    • basic analysis of behavioral video (motion energy etc.)
    • not sure if the DLC/LP stuff will be in this repo. Maybe not, since we already have them in CO pipeline.
  • Dependencies:
  • Example functions
@hanhou hanhou added the planning label Mar 6, 2024
@hanhou hanhou changed the title Discussion on how we organize functions, packages, CO capsules, and CO pipelines Discussion on how we organize repos for dynamic foraging analysis Mar 19, 2024
@hanhou hanhou changed the title Discussion on how we organize repos for dynamic foraging analysis Standardized dynamic foraging analysis Mar 19, 2024
@hanhou hanhou self-assigned this Mar 19, 2024
@hanhou hanhou changed the title Standardized dynamic foraging analysis Planning: standardized dynamic foraging analysis Mar 19, 2024
@hanhou hanhou added this to the Add standardized dynamic foraging analysis to the pipeline milestone Mar 19, 2024
@hanhou
Copy link
Collaborator Author

hanhou commented Mar 19, 2024

@JeremiahYCohen @ZhixiaoSu please add your inputs.

@JeremiahYCohen
Copy link
Collaborator

I like the list of basic analyses and repo structure.

Another model that could go into Repo 3 is a volatile Kalman filter (or another ideal observer model).

Would it make sense to have "Repo 4: video-analysis"?

@hanhou
Copy link
Collaborator Author

hanhou commented Mar 20, 2024

I like the list of basic analyses and repo structure.

Another model that could go into Repo 3 is a volatile Kalman filter (or another ideal observer model).

Would it make sense to have "Repo 4: video-analysis"?

Added them to the plan.

@ZhixiaoSu do you have code for the volatile Kalman filter? I don't see here.

@ZhixiaoSu
Copy link
Collaborator

@JeremiahYCohen Can you provide a bit more detail of how we would want to utilize the volatilKalmenFilter model? We have different versions of that model that have different purposes. (Fitting behavior, simulation etc. The version in this link is written by Hanqing in his rotation, so not sure if it has the function we want.)

@JeremiahYCohen
Copy link
Collaborator

Probably not a priority. The idea would be to compare mouse behavior to an ideal observer model to answer: (1) how far are mice from ideal ("foraging efficiency" may answer this); (2) does mouse strategy look like an ideal observer in some epochs?

Maybe this is the right repo:
https://github.com/JeremiahYCohenLab/cooperAnalysis/tree/cd508383c859a4ccae9c2a59c0f9620f429aeff7/matlabCode/operantMatching/learningModels/idealObserverModels

@ZhixiaoSu
Copy link
Collaborator

Oh got it! Then the one you just sent perfectly meets the need. It maximizes reward rate over parameter space when simulating behavior. We may need one additional part of code that does the behavior simulation in different task settings (coupled/not, baited/not).

@hanhou
Copy link
Collaborator Author

hanhou commented Mar 21, 2024

Thank you, Jeremiah and Sue!

However the link doesn't work for me. Is the repo cooperAnalysis a private repo?

@ZhixiaoSu
Copy link
Collaborator

Just sent you an invitation.

@hanhou hanhou removed this from the Add standardized dynamic foraging analysis to the pipelinea milestone Mar 21, 2024
@rachelstephlee rachelstephlee self-assigned this Jul 12, 2024
@alexpiet
Copy link
Collaborator

I'm making a wiki page here: https://github.com/AllenNeuralDynamics/aind-dynamic-foraging-data-utils/wiki

Lets document how we access data, and where different analysis tools are located.

@alexpiet
Copy link
Collaborator

alexpiet commented Aug 8, 2024

@rachelstephlee @hanhou How does this look for a basic organization of the repos?

Image

digraph G {
  compound=True;

  subgraph cluster_0 {

      style=filled;
      color=lightgrey;
      node [style=filled, color=white];
      trials_df;
      session_df;
      events_df;
      fib_df;
      label="aind-dynamic-foraging-data-utils";
  }
  
  subgraph cluster_1 {
      compound=True
      style=filled;
      color=lightgrey;
      node [style=filled, color=white];
      PSTHs;
      visualizations;
      stats;
      label="aind-dynamic-foraging-basic-analysis";
  }
  
  subgraph cluster_2 {
      compound=True
      style=filled;
      color=lightgrey;
      node [style=filled, color=white];
      behavior_models;
      label="aind-dynamic-foraging-models";
  }
  
  

 NWB -> trials_df [lhead=cluster_0];
 NWB -> session_df [lhead=cluster_0];
 NWB -> events_df [lhead=cluster_0];
 NWB -> fib_df [lhead=cluster_0];
 fib_df -> PSTHs [lhead=cluster_1];
 events_df -> PSTHs [lhead=cluster_1];
 trials_df -> visualizations [lhead=cluster_1];
 trials_df -> behavior_models [lhead=cluster_2];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants