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
273 stars 137 forks source link

Unable to Create Project with Updated Version of SimBA #242

Open mrnels19 opened 1 year ago

mrnels19 commented 1 year ago

Describe the bug When I updated to the most recent version of SimBA (1.54.1), I am unable to create a new project. I was previously using SimBA 1.31.0 To Reproduce

  1. Update SimBA in Anaconda using the command pip install simba-uw-tf-dev --upgrade
  2. In the GUI, go to File -> Create a New Project
  3. See screenshots for error in terminal and in GUI

Expected behavior There should not be any errors in the terminal and I should be able to create a new project in the GUI

Screenshots Updated Simba Error Updated Simba Code Error

Desktop (please complete the following information):

Additional context I noticed that the GUI for SimBA 1.54.1 looks a little different, as there are icons next to each tab in the GUI. What are some of the updates that this new version provides?

sronilsson commented 1 year ago

Hi @mrnels19 - If you do pip uninstall simba-uw-tf-dev followed by pip install simba-uw-tf-dev, how does it look?

PS. The updates are large but all back-end. SimBA has been made easier to develop, there was a lot of repeated junk code, missing classes, missing tests and lack of clear error msg and logging for users. There are some small new functions here and there, you may see some new buttons. They are all documented but if you cant find specific docs let me know and I will point you to them.

mrnels19 commented 1 year ago

I used both of those commands, and I am still getting the same error.

sronilsson commented 1 year ago

when you type pip uninstall simba-uw-tf-dev, before you press Y to confirm uninstallation, what do you see printed out?

mrnels19 commented 1 year ago

This is what I see: pip uninstall simba notes

sronilsson commented 1 year ago

Try and delete that folder (directory simba) within the site-packages manually before installing simba and let me know how goes

mrnels19 commented 1 year ago

Thank you for your input! I am able to successfully load a new project now. However, after I import my SLEAP tracking data (for the multi-animal tracking with the 8 body-part configuration SimBA provides), only one animal is tracked when I am asked to match the tracks to the appropriate animal. This is true, even as I press "x" to advance to another frame. If I label the two animals in the frame, I have to press "c" twice in order to exit this part of the GUI (pressing "c" once does not cause anything to occur) and I get an error in the terminal that is seen in the screenshot below.

I initially ran into this error when I was working with SimBA 1.31.0 today, which prompted me to update SimBA. I had previously worked with SimBA 1.31.0 and did not experience this error. However, I am still encountering this issue after I have successfully updated to the latest version of SimBA. one animal marked one animal marked terminal error

sronilsson commented 1 year ago

If you close python terminal, open it again, and run simba, do you still have the issue?

Also make sure all python processes are killed in activity manager before rebooting the teminal and simba.

sronilsson commented 1 year ago

PS

I initially ran into this error when I was working with SimBA 1.31.0 today, which prompted me to update SimBA. I had previously worked with SimBA 1.31.0 and did not experience this error. 

This makes me think there is something specific to the video data file. Do you se ethis error on all .slp files, or just one?

mrnels19 commented 1 year ago

Thank you! I was able to resolve the problem by working with a different file. I am still using the multi-animal tracking model with 8 body parts on each animal provided by SimBA. I was able to load in my videos and tracking data just fine. When I opened the Load Project GUI, I was able to successfully set the video parameters, skip outlier extraction, extract features, and label behavior. I then went over to the Train Machine Model tab, where I used the parameters in the BtWGaNP_meta file to save settings for a specific model (one for each behavior I labeled). I then pressed the button that said Train Multiple Models (one for each saved setting) and got the errors shown in the screenshots below. What do you think could be causing these errors, as I did not have any issues with my data until now? train machine model terminal error train machine model error

sronilsson commented 1 year ago

Hi @mrnels19 - if you open a CSV inside the project_folder/csv/targets_inserted directory, what can you see your body-parts beeing named in the header?

mrnels19 commented 1 year ago

Hello, @sronilsson! When I open the CSV file, I first see what is included in my screenshot, which includes all the body parts. targets inserted csv

sronilsson commented 1 year ago

When you created your project, did you do user defined pose configuration? Those headers in that file, is what you would see if you picked a default body-part configuration. Which one exactly I don't know as I think notepad has more data hidden to the right outside the screengrab

mrnels19 commented 1 year ago

I used the default body-part configuration that involved multi-tracking and eight body parts on each animal. I also have provided a link to the complete CSV file, as there is more data hidden to the right. https://drive.google.com/file/d/1pdguHPW9kFPG0ErrrBiPsV39HwpQtUAl/view?usp=sharing

I had to send the CSV file as a link, since it was so large - let me know if you cannot access it. pose configuration

sronilsson commented 1 year ago

In the screengrab earlier I see Social_partner and test and Knee etc. Does those ring a bell? Is that a pose config you have defined before?

mrnels19 commented 1 year ago

Yes, the animals were named SocialPartner and Test, when I was asked to label the animals in SimBA. I also defined each of the 8 body parts in SLEAP when predicting on the frames. The body parts titled Knee would refer to body parts 5 and 6 in this pose configuration. Should the animals and body parts have different names in order for the default pose configuration to work?

sronilsson commented 1 year ago

No if you define your own body-part configuration, you should select that from the dropdown, what options do you see when you click the body-part config dropdown?

mrnels19 commented 1 year ago

When I click the body-part config dropdown, I see options for 4, 7, and 8 body parts on each animal, as well as an option to create my own configuration. I selected the 8 body part configuration, as that extracts the most features in SimBA. My frames have two animals in them, each with 8 body parts in the positions listed in the configuration. If the animals and the body parts are supposed to have specific names in order for the configuration to work, could you please share them with me?

sronilsson commented 1 year ago

No if you have those body-parts it should work fine, I don't know where the knee etc comes from though. If you selected the 8 body part configuration and never defined your own body-part configuration right?

mrnels19 commented 1 year ago

Yes, I never defined my own body-part configuration in SimBA for this specific project

sronilsson commented 1 year ago

Thank you @mrnels19, very helpful, then I might have introduced a bug: I will look tomorrow and let you know - has been a long day

mrnels19 commented 1 year ago

Thank you so much! I also wanted to let you know that my body parts are not in the same order as those listed in the configuration. For example, my left ear body part is listed as the second body part in my skeleton, but it is listed as the first body part in the image for the SimBA configuration. If this is something that could be noted as well, that would be great!

mrnels19 commented 1 year ago

Hi, I just wanted to follow up to my previous response with another question. Ever since I began working with SimBA, there have been times when not all of the tracking data for a given video has been imported, as seen in the screenshot I have included below. The entire video has been predicted on, so I am not sure why all the tracking data has not been imported. What do you think is causing this to happen? not all frames imported

sronilsson commented 1 year ago

Hi, I just wanted to follow up to my previous response with another question. Ever since I began working with SimBA, there have been times when not all of the tracking data for a given video has been imported, as seen in the screenshot I have included below. The entire video has been predicted on, so I am not sure why all the tracking data has not been imported. What do you think is causing this to happen? not all frames imported

I think the SLP file has a frames key. The 74133 comes from the number of unique entries in this key. Has your videos got 74k frames?

Restructing the SLP files is slow. There is an option to import sleap H5 files now though, which is a newer format sleap outputs, and its significantly quicker. Have you tried that?

sronilsson commented 1 year ago

Yes, I never defined my own body-part configuration in SimBA for this specific project

I Have tried to recreate your error and I can't. The body-part names in your project is stored in the project_folder/logs/measures/pose_configs/bp_names/project_bp_names.csv file. Have you got a screengrab of the entries in that file?

It makes me think that when you deleted your anaconda simba files, there were still some files that where not properly deleted. Specifically, all the different body-part configs within a SimBA installation are stored in the are stored in the simba/pose_configurations/ in your anaconda environment. Do you think any of those files could have survived your manual delete?

gemajpg commented 1 year ago

Hi! I have the same issue but I wasn't able to fix it with the commands recommended before. I uninstalled and installed simba and also tried by deleting it manually in site-packages. Does someone know how to fix it, please?

florianduclot commented 1 year ago

@gemajpg , I too have the same error. @sronilsson , to reproduce:

  1. create a new conda env: conda create --name simbadev python=3.6
  2. pip install simba-uw-tf-dev
  3. pip uninstall shapely
  4. conda install -c conda-forge shapely
  5. simba, and then click File > Create a new project. The pop up window opens, but the main content isn't displayed. Logs shows:
    (simbadev) C:\Windows\system32>simba
    Exception in Tkinter callback
    Traceback (most recent call last):
    File "C:\Users\MBF\miniconda3\envs\simbadev\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
    File "C:\Users\MBF\miniconda3\envs\simbadev\lib\site-packages\simba\SimBA.py", line 746, in <lambda>
    file_menu.add_command(label='Create a new project', compound='left', image=self.menu_icons['create']['img'], command=lambda: ProjectCreatorPopUp())
    File "C:\Users\MBF\miniconda3\envs\simbadev\lib\site-packages\simba\create_project_pop_up.py", line 78, in __init__
    self.bp_lu[k]['img'] = PhotoImage(file=os.path.join(os.path.dirname(__file__), self.bp_lu[k]['img_path']))
    File "C:\Users\MBF\miniconda3\envs\simbadev\lib\tkinter\__init__.py", line 3545, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
    File "C:\Users\MBF\miniconda3\envs\simbadev\lib\tkinter\__init__.py", line 3501, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
    _tkinter.TclError: encountered an unsupported criticial chunk type "eXIf"

I could fix it by specifying ImageTk in line 78: before: https://github.com/sgoldenlab/simba/blob/2fbff2f6fcc7cd3c6ef14ea1e42a2913e61091f0/simba/create_project_pop_up.py#L78

after:

            self.bp_lu[k]['img'] = ImageTk.PhotoImage(file=os.path.join(os.path.dirname(__file__), self.bp_lu[k]['img_path']))

I'm not sure whether there are more occurrences like this throughout the project, however.

PS: @sronilsson, sorry for piling up in this issue; I realize it isn't the same problem as the original post of this issue. Let me know if you'd rather me open a new one instead.

EDIT note: I have corrected a typo in ImageTk.

gemajpg commented 1 year ago

@florianduclot Thank you!! It does seem like we get exactly the same problem when we try to create a new project. I tried to do what you recommended but sadly now I get the following issue:

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\gemap\Anaconda3\envs\simba\lib\tkinter__init.py", line 1705, in call return self.func(*args) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 746, in file_menu.add_command(label='Create a new project', compound='left', image=self.menu_icons['create']['img'], command=lambda: ProjectCreatorPopUp()) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\create_project_pop_up.py", line 78, in init__ self.bp_lu[k]['img'] = ImageTK.PhotoImage(file=os.path.join(os.path.dirname(file), self.bp_lu[k]['img_path'])) NameError: name 'ImageTK' is not defined

florianduclot commented 1 year ago

@gemajpg , that is my bad... I have a typo in my previous post. It should be a lower case k: ImageTk.

I'll edit my previous post accordingly; sorry for that.

gemajpg commented 1 year ago

@florianduclot It works now! Thank you so much!

sronilsson commented 1 year ago

Thanks a lot @florianduclot @mrnels19, very helpful, I can see it and will insert the fix. For whatever reason no errors are raised on my mac so would be difficult to find it without your help 👍🏻

mrnels19 commented 1 year ago

Yes, I never defined my own body-part configuration in SimBA for this specific project

I Have tried to recreate your error and I can't. The body-part names in your project is stored in the project_folder/logs/measures/pose_configs/bp_names/project_bp_names.csv file. Have you got a screengrab of the entries in that file?

It makes me think that when you deleted your anaconda simba files, there were still some files that where not properly deleted. Specifically, all the different body-part configs within a SimBA installation are stored in the are stored in the simba/pose_configurations/ in your anaconda environment. Do you think any of those files could have survived your manual delete?

Hello, has a fix been inserted for the error that occurred when people trained with the eight body-part configuration? Or, did the issue in the final comments involve installing and loading a new project in SimBA? I am still using SimBA 1.31.0, so I do not know if this fix is in a newer version.

sronilsson commented 1 year ago

This should be fixed, but if you see it after running pip install simba-uw-tf-dev --upgrade, let me know! It should be version 1.58.8 now.

mrnels19 commented 1 year ago

Thank you! I have updated to version 1.58.8. However, I cannot seem to load in the .h5 SLEAP file for my video, as the button is covered up, as seen in the screenshot. This issue still occurs when I put the project window in fullscreen on a Windows computer. ImportTrackingData

sronilsson commented 1 year ago

Thanks @mrnels19, my bad, see how it looks like and how it runs in in version 1.59.1. Please let me know if other issues pop up.

mrnels19 commented 1 year ago

When I entered pip install simba-uw-tf-dev --upgrade to upgrade to SimBA 1.59.1, I got the following error message in the screenshot below. I am installing with Anaconda on Windows 10.

1 59 1 installation error

sronilsson commented 1 year ago

It should be there, do you still see that msg?

mrnels19 commented 1 year ago

I was able to install SimBA 1.59.1 and see the settings for importing a SLEAP .h5 file. However, there is an error when I press "Import SLEAP h5" after setting a h5 SLEAP directory. I have attached a screenshot with this error, and I noticed that the path listed in the error is different than the path I selected. Additionally, the path in the error uses both forward and back slashes. I also experience this issue when importing data from a .slp file. importtrackingdatadirectory

mrnels19 commented 1 year ago

I was able to import a SLEAP .h5 file by switching to SimBA 1.55.8, in order to continue working with my data. I stayed in SimBA 1.55.8 until it was time to train my machine model, and I upgraded back to SimBA 1.59.1.

I appear to still be receiving error messages, when I use the pose configuration for multi-animal tracking with eight body parts on each animal (I have two animals in each frame). After I label behavior in a video and set model parameters according to BtWGaNP_meta, I go to train my model and get the errors shown in the screenshots below.

It appears that my body part names differ from the assigned body part names in this pose configuration. For example, I named the body part on the tip of each mouse's tail "Tail_End" when training SLEAP to label my frames, but this body part may have been assigned a different name when this pose configuration was designed in SimBA. I did not create any pose configurations in SimBA, but selected "Multi tracking" and "Multi-animals; 8 body-parts" when creating a project.
Additionally, each mouse is named "Animal_1" or "Animal_2" and this is listed in front of the name of each body part in the error. I assigned these names to the mice when I imported my tracking data into SimBA (the names of my body parts in SLEAP do not have "Animal_1" or "Animal_2" in front of them). It appears that SimBA places the identity of each animal in front of a specific body part when training a model.

I am using Python 3.6.13 on Windows 10 and Anaconda.

Is there any way I can use this SimBA pose configuration, even though my body parts do not appear to have the same names as the body parts that were used to develop this pose configuration in SimBA? If not, can you share what the name of each body part is in this pose configuration, so that I can change the names of my body parts in SLEAP to make it work? Thank you! 1 59 1 8 marker error

sronilsson commented 1 year ago

Thanks @mrnels19 - very helpful. I know this bug too and will insert fix later today..

FYI I have a few very small testing projects I run the code on before updating: unfortunately I don't have any testing projects with SLEAP H5 and any of the default pose-estimation configs (e.g., 2 animals and 8 body-parts each). If you a little bit of data you could share, e.g. 1 or 2 h5 files with associated videos, let me know and I can add those to the tests.

mrnels19 commented 1 year ago

Hi @sronilsson - thank you! I have attached a video, the .slp file, and the .h5 file here. https://drive.google.com/drive/folders/15Ey4U3FpseAXIEZl8CdA7q0pxZWeTTP6?usp=share_link Let me know if you have any questions!

sronilsson commented 1 year ago

Thanks @mrnels19 - can you give it a go in version 1.59.2 and let me know how it runs?

mrnels19 commented 1 year ago

Yes, I am able to successfully load a SLEAP .h5 file in version 1.59.2!