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 during outlier correction step #193

Closed fon215 closed 2 years ago

fon215 commented 2 years ago

Describe the bug I am working through the SimBA pipeline and I am working on the Outlier correction step following the tutorial steps on the documentation page. I am getting this error when I set the settings. The distance between ears is about 31.75mm for the location criterion and the distance between nose and tail base is about 63.5mm for the movement criterion. I put these values in the Outlier settings. I am a little confused of how this step works, did I do this properly and did I put the right numbers? When I go to run the outlier correction this is what I see in the command window. Could anyone be helpful in understanding what is happening?

Exception in Tkinter callback Traceback (most recent call last): File "c:\tools\anaconda3\envs\simbaenv\lib\tkinter\__init__.py", line 1705, in __call__ return self.func(*args) File "c:\tools\anaconda3\envs\simbaenv\lib\site-packages\simba\SimBA.py", line 6279, in correct_outlier dev_move_user_defined(configini) File "c:\tools\anaconda3\envs\simbaenv\lib\site-packages\simba\outlier_scripts\movement\correct_devs_mov_user_defined.py", line 120, in dev_move_user_defined csv_df.columns = colHeads File "c:\tools\anaconda3\envs\simbaenv\lib\site-packages\pandas\core\generic.py", line 5192, in __setattr__ return object.__setattr__(self, name, value) File "pandas/_libs/properties.pyx", line 67, in pandas._libs.properties.AxisProperty.__set__ File "c:\tools\anaconda3\envs\simbaenv\lib\site-packages\pandas\core\generic.py", line 690, in _set_axis self._data.set_axis(axis, labels) File "c:\tools\anaconda3\envs\simbaenv\lib\site-packages\pandas\core\internals\managers.py", line 183, in set_axis "values have {new} elements".format(old=old_len, new=new_len) ValueError: Length mismatch: Expected axis has 18 elements, new values have 27 elements

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Outlier correction' step
  2. Click on 'Settings"
  3. Enter values, click 'Confirm"
  4. Press 'Run Outlier Correction'
  5. See error

Expected behavior Outlier correction should properly remove outliers.

Desktop (Lenovo P340 Workstation (ThinkStation) - Type 30DH (Tower Form Factor)):

Additional context I am working through a remote desktop while using this software.

sronilsson commented 2 years ago

Hi @fon215! Thanks for reporting. First, the menus circled below, they want a multiplier, not a distance value. SimBA will calculate the mean (or median value) between the two body-parts (in this example, the right ear and the tail). SimBA will then use the entered multiplier to get a threshold value. For example, for the movement criterion, if the median distance between the right ear and the tail is 100mm, and the multiplier is set to 2, then any body-part movement larger than 100mm*2 is treated as an outlier movement, and the movement is removed, and the body-part is placed back in the most recent reliably coordinate before the movement. There is more info on this here

The error you are seeing however is unrelated to this. After correcting the outliers, SimBA will modify the heading of the file so it is standardized regardless from whi Untitled 2 ch pose-estimation package the data comes from. SimBA wants to insert 27 new headings, and believes that you are tracking 9 bodyparts (27 / 3). However, the file only contains 6 body-parts (18 /3). How many body-parts does your data contain, and what did you specify in the drop-down menues for body-part configuration when creating your project? If you open the project_config.ini and scroll down to pose_estimation_body_parts = what do you see it equal?

fon215 commented 2 years ago

Thank you so much! Now I understand the settings for outlier correction better!

Whenever I look in the project_config.ini I see pose_estimation_body_parts = 9, which I am understanding now that I selected that wrong in the drop down menu when creating the project because I am using 6 body parts for my data, which I marked the nose, the left forepaw, the right forepaw, the left hind paw, the right hind paw, and the tail base in my DLC tracking data. Do I just change the number next to pose_estimation_body_parts = to 6? Let me know the best way to fix this.

sronilsson commented 2 years ago

Hi @fon215!

Correct! There are a few “built-in” pose-estimation body-part configurations in SimBA, that you can choose from the drop-downs. You can see what kind of data they anticipate in the images that are showed below the dropdowns where you create your project. You can also read about them here: https://github.com/sgoldenlab/simba/blob/master/docs/Tutorial_DLC.md

Your body-parts, e.g., hand paws, is not available in these built-in configurations. That means we have to create and choose to use a user-defined body-part configuration in the SimBA dropdown menu when we create our project. There is a tutorial for how to do that here: https://github.com/sgoldenlab/simba/blob/master/docs/Pose_config.md Let me know if that makes sense!

fon215 commented 2 years ago

Yes, that makes sense! So, do I just change that number to 6 or do I have to create another project to properly include the body parts I want to?

sronilsson commented 2 years ago

If you change it to 6, the SimBA will think its one of the default "in-built" settings with 6 body-parts, rather than a user-defined body-part configuration. I recommend creating a new project with user-defined body-part configuration!

fon215 commented 2 years ago

Okay, thank you!

fon215 commented 2 years ago

Actually, I have another question about this. Do I have to generate an image like the default ones in the settings for creating a new project where the body parts are marked on a mouse? Or is there another way this is generated?

sronilsson commented 2 years ago

SimBA will ask you to create an image, however, it is just a place holder, and not used for anything important in SimBA. You can grab any image and select the locations of your body-parts.

fon215 commented 2 years ago

Okay, thanks so much, again!