sgoldenlab / simba

SimBA (Simple Behavioral Analysis), a pipeline and GUI for developing supervised behavioral classifiers
https://simba-uw-tf-dev.readthedocs.io/
GNU General Public License v3.0
289 stars 141 forks source link

Plotly Visualization Questions #232

Open mrnels19 opened 1 year ago

mrnels19 commented 1 year ago

Describe the bug I am working to plot results using the Plotly feature in SimBA. I am following the instructions on the page titled "Interactive Data Visualization and Export in SimBA," but I am only able to view results on the graph that is titled "Probability [Behavior] - Group Means." I checked the boxes to load information from the Sklearn results, Time Bin analyses, and probabilities in the Plotly/Dash section of the Visualizations tab in the GUI.

To Reproduce Steps to reproduce the behavior:

  1. Create a new project in SimBA with three behaviors. Define a skeleton for multi-animal tracking, where each animal has 13 body parts.
  2. Import 2 videos, the corresponding SLEAP tracking data (do not perform any interpolation or smoothing), and then extract the frames.
  3. Load the project, and then set video parameters.
  4. Go to the Outlier Correction tab and select Skip Outlier Correctoin (I think my SLEAP tracking was accurate so I skipped this part).
  5. Extract features.
  6. Label behavior. When labeling behavior, I labeled 1 in every 100 frames for the first 20,000 frames in a 70,000 frame video. I was just testing out my videos here, so I did not label an entire video.
  7. Train Machine Model. Use the hyperparameters in the BtWGaNP_meta.csv file, and press Save settings to specific model. Make a model with the hyperparameters in the BtWGaNP_meta.csv file for each behavior. Then, press Train multiple models, one for each saved setting.
  8. Under the Run Machine Model tab, click Model Settings, and load in the appropriate .sav file for each behavior. Set a threshold and minimum bout length. Press Set Model(s). Then, press Run RF Model.
  9. Analyze the machine results by generating files for the following options: Analyze machine predictions, Analyze distances/velocity, Time bins: Machine predictions, and Time bins: Distance/velocity.
  10. Under the Visualizations tab, go under Sklearn Visualizations and the Apply to all videos subheading. Check the generate videos box and press Visualize classification results. Then, I generated a gnatt plot by going under the gnatt plot subheading and checking the create videos box before pressing Generate gnatt plot.
  11. Go under Plotly/Dash in the Visualizations tab and check Sklearn results, Time bin analyses, and probabilities. Then press Save SimBA/Plotly dataset. Load the H5 file and press Open SimBA/Plotly dataset.
  12. See error

Expected behavior I should see results for the probabilities, sklearn results, and time bin analyses when I open Plotly. The option for selecting sklearn data is not available. When I select the time bins analyses option, nothing appears on either graph. When I select the VideoData category in Plotly, which displays the probabilities data, I only see data on the top graph and not on the bottom graph with the Mean Time (seconds) on the y-axis and Video/Group on the x-axis. Screenshots The first screenshot shows what I see when I select the VideoData category for probabilities. The second screenshot shows what I see when I click on the time bins category.

Plotly Probabiilities Issue Plotly TimeBins Issue

Desktop (please complete the following information):

If you could show how to display all of the sklearn, time bins, and probability data in Plotly, I would really appreciate it!

mrnels19 commented 1 year ago

I have also included a screenshot of the files that I have in project_folder/logs. I noticed that an image on the "Interactive Data Visualization and Export in SimBA" page had a file called sklearn_20200810173021.csv in the same location. How can I generate this sklearn csv file, and would this sklearn csv file enable me to display the sklearn data in Plotly?

project_folder logs

Also, parts of my Time_bins_ML_results csv file are missing data. Perhaps this could be contributing to the absence of data in the time bin analyses in Plotly. If so, how could this issue be resolved? I have also included a screenshot of the missing data portion of these file below. time bins ml empty part

mrnels19 commented 1 year ago

Hello! I just wanted to follow up to my previous comments about the Plotly visualizations. Do you think the missing sklearn information could be due to using SLEAP or a user-defined pose configuration? I was able to create a video of the sklearn plots, but I could not find a way to generate a .csv file with the sklearn information. Also, would the missing data in the Time Bins .csv file, and the issue with displaying Time Bins data in Plotly, be due to not labeling enough frames when training the model? I would be willing to clarify anything, or share pictures, files or videos to help.

sronilsson commented 1 year ago

Hi @mrnels19! I just want to let you know I've seen this, and it's likely a bug I need to look at and not related to what you are doing. The reason I didn't respond sooner is that I didn't build the dashboard and the the people that did, are not around to maintain, so not an immediate fix available for me, need to look at their code. The time bins data output was recently transposed in Simba, and the dashboard probably expects one row per video instead of one row per time bin.

I'm overwhelmed at the moment, so can't get to it. I hope I get some time at the end of the week and will keep you updated.

mrnels19 commented 1 year ago

Thank you for letting me know!