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
279 stars 138 forks source link

Error in validating model on single video #165

Open frankiechang123 opened 2 years ago

frankiechang123 commented 2 years ago

Describe the bug

I'm trying to validate my model on a single video. After selecting one csv file from features_extracted and the sav model file, an error message shows up when I clicked 'Run model':

Running model...
Error: make sure all the videos that are going to be analyzed are represented in the project_folder/logs/video_info.csv file
Predictions generated.

To Reproduce Steps to reproduce the behavior:

  1. In GUI, finish previous steps and go to 'Run machine model' tab
  2. Select a features file and a sav model file.
  3. Click on 'Run Model'
  4. See error

Expected behavior

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context The video_info.csv:

6,60,756,730,1000,0.6220072346846136
7,60,756,730,1000,0.6220072346846136
4,60,756,730,1000,0.6220072346846136
5,60,756,730,1000,0.6220072346846136
13,60,756,730,1000,0.6220072346846136
2,60,756,730,1000,0.6220072346846136
10,60,756,730,1000,0.6220072346846136
3,60,756,730,1000,0.6220072346846136
12,60,756,730,1000,0.6220072346846136
9,60,756,730,1000,0.6220072346846136
14,60,756,730,1000,0.6220072346846136
8,60,756,730,1000,0.6220072346846136
11,60,756,730,1000,0.6220072346846136
frankiechang123 commented 2 years ago

Also, when I clicked 'Generate Plot', an error message shows up:

image

It looks like it's looking for an mp4 file while all my videos are in .avi? Could this be the problem?

sronilsson commented 2 years ago

Hello @frankiechang123 ! Thanks for reporting.

What might be happening is that your videos are named as integers and there version of SimBA you are running gets confused. I will make sure this doesn't happen, but in meantime, could you rename your files in the video_info.csv, and the files in the features_extracted folder, Video1 etc. instead of 1 and see if that fixes it?

frankiechang123 commented 2 years ago

Hi! I changed the filenames as you suggested and now there's no error message.

However, when I clicked 'Generate Plot', it was still looking for mp4 files. Is there a way around this?

Thank you so much!

sronilsson commented 2 years ago

@frankiechang123 - which version of SimBA are you running?

sronilsson commented 2 years ago

@frankiechang123 - I've inserted a couple of checks around the functions you are using, could you update SimBA to version 0.89.6 - pip install simba-uw-tf-dev==0.89.6 or pip install simba-uw-tf-dev --upgrade and see if it behaves correctly on your end?

frankiechang123 commented 2 years ago

Hi! I uninstalled my previous version simba-uw-no-tf-1.3.0 and installed simba-uw-tf-dev==0.89.

It then says simba cannot be found. What am I doing wrong?

sronilsson commented 2 years ago

Hello @frankiechang123 - if you type in your environment: 1) pip uninstall simba-uw-no-tf - this removes the simba-uw-no-tf version (which is not maintained) 2) pip install simba-uw-tf-dev - this installs the latest version of simba (the one being updated and maintained) 3) simba - this should launch simba-uw-tf-dev

let me know if that works

Urimons commented 2 years ago

Hey, I encountered the same problem when trying to "Run RF Model" under the "Run machine model" tab, and also when trying to "Analyze machine predictions".

The error when trying to "Run RF Model":

_Running 1 model(s) on 4 video file(s). Analyzing video 1/4... Error: make sure all the videos that are going to be analyzed are represented in the project_folder/logs/videoinfo.csv file

The error when trying to "Analyze machine predictions":

_Analyzing video 1/6... File # processed for machine predictions: 1/6 Error: make sure all the videos that are going to be analyzed are represented in the project_folder/logs/video_info.csv file Analyzing video 2/6... File # processed for machine predictions: 2/6 Error: make sure all the videos that are going to be analyzed are represented in the project_folder/logs/video_info.csv file Analyzing video 3/6... File # processed for machine predictions: 3/6 Error: make sure all the videos that are going to be analyzed are represented in the project_folder/logs/video_info.csv file Analyzing video 4/6... Model paths saved in projectconfig.ini Applying settings for classical tracking...

I tried to apply the suggestions mentioned here with no success... any advice what I should do?

sronilsson commented 2 years ago

Hi @Urimons! Which version of SimBA are you running? Can you type pip show simba-uw-tf-dev and paste the output here

Urimons commented 2 years ago

(simba) C:\Users\YizharAnalysis>pip show simba-uw-tf-dev Name: Simba-UW-tf-dev Version: 0.90.9 Summary: Toolkit for computer classification of complex social behaviors in experimental animals Home-page: https://github.com/sgoldenlab/simba Author: Simon Nilsson, Jia Jie Choong, Nastacia Goodwin, Sophia Hwang, Sam Golden Author-email: goldenneurolab@gmail.com License: GNU Lesser General Public License v3 (LGPLv3)

sronilsson commented 2 years ago

Thanks @Urimons - I can see that the function being called hasn't been update for a while. Hang on, I will push a fix.

sronilsson commented 2 years ago

@Urimons - can you upgrade SimBA - pip install simba-uw-tf-dev --upgrade - it should be version 0.91.0, and check if it works now? If not, let me know what errors you see, thanks for reporting

Urimons commented 2 years ago

Now when I try to "Run RF model" I get: _(simba) C:\Users\YizharAnalysis>simba Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\configparser.py", line 789, in get value = d[option] File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\collections__init.py", line 883, in getitem return self.missing(key) # support subclasses that define missing File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\collections__init.py", line 875, in missing__ raise KeyError(key) _KeyError: 'no_of_animals' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\tkinter\init.py", line 1705, in call__ return self.func(*args) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 5892, in runrfmodel rfmodel(self.projectconfigini) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\run_RF_model.py", line 36, in rfmodel noAnimals = config.getint('ROI settings', 'no_of_animals') File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\configparser.py", line 819, in getint fallback=fallback, kwargs) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\configparser.py", line 809, in _get_conv kwargs)_ File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\configparser.py", line 803, in _get return conv(self.get(section, option, **kwargs)) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\configparser.py", line 792, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'no_ofanimals' in section: 'ROI settings'

and when I try "Analyze machine predictions" I get: Traceback (most recent call last): File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\tkinter\init.py", line 1705, in call return self.func(*args) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 5878, in button1 = Button(dlmlabel,text='Analyze',command=lambda:self.findDatalogList(titlebox,var)) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 5888, in findDatalogList analyze_process_data_log(self.projectconfigini,finallist) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\process_data_log.py", line 83, in analyze_process_data_log firstOccurList.append(round(currDf['Start Time'].min(), 3)) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\pandas\core\generic.py", line 11618, in stat_func f, name, axis=axis, skipna=skipna, numeric_only=numeric_only File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\pandas\core\series.py", line 4090, in _reduce return op(delegate, skipna=skipna, **kwds) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\pandas\core\nanops.py", line 131, in f raise TypeError(e) TypeError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

sronilsson commented 2 years ago

Thanks, let me take another look

sronilsson commented 2 years ago

@Urimons - there was a typo of mine in Run RF model - but not sure what is going on in Analyze machine predictions, it could likely be that the Run RF model fails, and therefore no values to analyze in Analyze machine predictions. Can we try again, with version 0.91.1?

Urimons commented 2 years ago

Tried again. The "Run RF model" works now, but the "Analyze..." still doesn't, this is the error: _Traceback (most recent call last): File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\tkinter__init.py", line 1705, in call__ return self.func(*args) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 5878, in button1 = Button(dlmlabel,text='Analyze',command=lambda:self.findDatalogList(titlebox,var)) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 5888, in findDatalogList analyze_process_data_log(self.projectconfigini,finallist) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\simba\process_data_log.py", line 83, in analyze_process_data_log firstOccurList.append(round(currDf['Start Time'].min(), 3)) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\pandas\core\generic.py", line 11618, in stat_func f, name, axis=axis, skipna=skipna, numeric_only=numeric_only File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\pandas\core\series.py", line 4090, in reduce return op(delegate, skipna=skipna, **kwds) File "C:\Users\YizharAnalysis\anaconda3\envs\simba\lib\site-packages\pandas\core\nanops.py", line 131, in f raise TypeError(e) TypeError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

image image

sronilsson commented 2 years ago

Got it, almost there :) Hang on..

sronilsson commented 2 years ago

Can you try again with 0.91.2 and let me know?

Urimons commented 2 years ago

it works! Thanks a lot :)