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
286 stars 139 forks source link

SimBA stalls while processing a file for movement outliers #159

Closed AnnabelPerry closed 2 years ago

AnnabelPerry commented 2 years ago

Describe the bug I am new to SimBA and am trying to use it to classify behaviors in a fish species. Before running on my full dataset, I am troubleshooting SimBA on a single video. I have been following the ReadTheDocs instructions (https://simba-docs.readthedocs.io/en/latest/docs/getting_started/simba_tutorial.html#part-1-create-a-new-project) and am on Part 2, Step 4. I am trying to correct for outliers. However, it has been 6 hours since I started the outlier correction process and the main SimBA window is still displaying the following message:

Pose-estimation body part setting for outlier correction: 9
Applying settings for classical tracking...
Processing 1 files for movement outliers...

Pressing "Run outlier correction" generated the following error in the terminal:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/home/blackmonlab/anaconda3/envs/simbaenv/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/home/blackmonlab/anaconda3/envs/simbaenv/lib/python3.6/site-packages/simba/SimBA.py", line 6092, in correct_outlier
    dev_move_user_defined(configini)
  File "/home/blackmonlab/anaconda3/envs/simbaenv/lib/python3.6/site-packages/simba/outlier_scripts/movement/correct_devs_mov_user_defined.py", line 120, in dev_move_user_defined
    csv_df.columns = colHeads
  File "/home/blackmonlab/anaconda3/envs/simbaenv/lib/python3.6/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 "/home/blackmonlab/anaconda3/envs/simbaenv/lib/python3.6/site-packages/pandas/core/generic.py", line 690, in _set_axis
    self._data.set_axis(axis, labels)
  File "/home/blackmonlab/anaconda3/envs/simbaenv/lib/python3.6/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 25 elements, new values have 27 elements

To Reproduce The video and DeepLabCut data are attached as Google Drive files at the bottom of this post. To prep the video, I just cropped it a bit. To get this error, I followed the steps from the SimBA ReadTheDocs, SimBA Pipeline section. Below are the specific parameters I used for each step which required user input:

In Part 1, Steps 1.4-1.5, I specified 9 behaviors:

  1. Suspension
  2. Bottom Skimming
  3. Drifting
  4. Fast Turning
  5. Flit Swimming
  6. Pushing Against Tank Wall
  7. Slow Turning
  8. Sustained Swimming
  9. Other

In Part 1, Step 1.6, I specified classic tracking

For Part 1, Step 1.7, I specified 1 animal, 9 body parts

In Part 2, Step 3.1, I set Distance_in_mm to 225 mm (the length of the top of my fish's tank)

In Part 2, Step 3.6, I drew a line across top of tank

In Part 2, Step 4.2, I used nose and tail as reference body parts

In Part 2, Step 4.3, I listed 120mm for both Movement criterion and Location criterion. I know these are both probably bad parameters. I used them because the maximum size of the fish is 120mm (though mine are probably closer to 50mm). I will probably adjust them once I can see the results of outlier correction.

Expected behavior ReadTheDocs indicates I should expect to find 2 log files in the /project_folder/logs/ directory upon successful completion, and presumably a message stating that the program is looking for location outliers, followed by some sort of "done" message

Desktop Ubuntu 18.04 Python 3.6.10 I am using Anaconda

Additional context Here is a Google Drive Folder with the video and DeepLabCut tracking data I am using in this process. Please don't hesitate to message me if there are sharing issues: https://drive.google.com/drive/folders/1JB3nE14e3-8AcZE0DsZ0F1wXpwmMqM_J?usp=sharing

sronilsson commented 2 years ago

Hi @AnnabelPerry - thanks for sharing the files on the gdrive. I will take a look what might be going on but can't get to it straighaway. It seems the error is caused by the outlier correction functions of SimBA thinking you have fewer body-parts than the 9 that you actually have. I would suggest skipping the outlier correction and proceed without it to see if the rest of the pipeline works OK.

AnnabelPerry commented 2 years ago

Hi, I'm still having a problem with this. I skipped outlier correction and moved straight to extracting features. When extracting, I get the following message:

Pose-estimation body part setting for feature extraction: 9
0
Extracting features from 0 files...
Extracting features from 0 file(s)...
All feature extraction complete.

I'm not entirely clear on what feature extraction is supposed to do, but it doesn't seem right that SimBA is registering 0 files. When I proceed to behavior labeling and click Select video (create new video annotation), I get the following error:

Number of Frames: 38981
/home/blackmonlab/Documents/Annabel/NeuralNetworkProject/SimBATestProject/project_folder/csv/features_extracted/Surface 1 41486_cropped.csv @@@@@@@@@@@@@
The CSV file could not be located at the following path: /home/blackmonlab/Documents/Annabel/NeuralNetworkProject/SimBATestProject/project_folder/csv/features_extracted/Surface 1 41486_cropped.csv . It may be that you missed a step in the analysis. Please generate the file before proceeding.
None
Applying settings for classical tracking...

There seems to be an issue with extracting features - could this be related to the issue with outlier correction, or should I open a second issue?

sgoldenlab commented 2 years ago

Hi @AnnabelPerry - yes you are right it is related to the outlier extraction, let's try to get passed it.

(i) SimBA takes the files inside of the the project_folder/csv/outlier_corrected_movement_location folder and extracts features from these files. A feature in your case, could be the angular rotation of the fish, the velocity of the fish body-parts etc. The message Extracting features from 0 files.. suggests that there are 0 files inside of this folder in your project, so we need to get this folder populated so we have files to extract features from.

(ii) The Pose-estimation body part setting for feature extraction: 9 message suggests that you are sing one of SimBAs built in pose-estimation configurations. I don't think this is accurate, as you are classifying behaviors of fish, and there is no built in configuration for fish as the moment. That message should be reading user-defined rather than 9.

(iii) The core issue probably comes from point ii, where SimBA thinks you have 9 in-built body-parts but you don't. When you click skip outlier correction SimBA tries to apply the in-built body-part names to your CSV files but fails as your pose-estimation files contains more/less body-parts. Could you try to use a user-defined body-part configuration and see if that fixes it?

AnnabelPerry commented 2 years ago

Hi, thanks for your rapid response! I generated a new project and manually-defined body parts using a screenshot from one of the videos. I went through the steps I described in the original post and ended up with this message after clicking "extract features". It still says Extracting features from 0 files...

Pose-estimation body part setting for feature extraction: user_defined
0
Applying settings for classical tracking...
Extracting features from 0 files...
All feature extraction complete.

When I attempt to label behaviors, I still get this message:

The CSV file could not be located at the following path: /home/blackmonlab/Documents/Annabel/NeuralNetworkProject/SimBATestProject/SurfaceProject/project_folder/csv/features_extracted/Surface 1 41486_cropped.csv . It may be that you missed a step in the analysis. Please generate the file before proceeding.
sgoldenlab commented 2 years ago

Hi @AnnabelPerry - just to confirm: when yo skipped outlier correctio, this you indicate this by pressing this button? Capture

AnnabelPerry commented 2 years ago

Yes, I did skip outlier correction

AnnabelPerry commented 2 years ago

My bad, I had not pressed the button on this most recent outlier correction. I did this and the issue appears to have been fixed. Thank you!