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

Multi-Animal DLC Import Error #148

Closed yana-yuhai closed 2 years ago

yana-yuhai commented 2 years ago

Hi @sgoldenlab, I am having an issue where when I try and import the h5 files using H5 (multianimalDLC):

"Importing 0 multi-animal DLC h5 files to the current project All multi-animal DLC .h5 tracking files ordered and imported into SimBA project in the chosen workflow file format"

It works when I select CSV (DLC/DeepPoseKit) but using that option leads to issues with Extracting Features.

I currently have simba-uw-tf-dev and I uninstalled it and tried both versions simba-uw-tf-dev==0.57 and simba-uw-tf-dev==0.58 and did not have any luck.

Thank you for the help!

sronilsson commented 2 years ago

Hello @yana-yuhai !

Could you update to the latest version of simba-uw-tf-dev, we are up to 0.88.0 now - pip install simba-uw-tf-dev==0.88.0 or simba-uw-tf-dev --upgrade and let us know how it goes?

yana-yuhai commented 2 years ago

Hi,

I tried updating to the latest version but am still experiencing the same error message with 0 files being imported.

Also, the files end in el.h5, so I've been selecting the "ellipse" option.

sronilsson commented 2 years ago

hello @yana-yuhai - I see. What SimBA does is to look in the selected data folder for filenames ending with el.h5 or el_filtered.h5, the code is in read_DLCmulti_h5_function.py line 32-37 and pasted below.

The reason that I can think this is happening:

    if filetype == 'skeleton':
        filesFound = glob.glob(dataFolder + '/*sk.h5') + glob.glob(dataFolder + '/*sk_filtered.h5')
    if filetype == 'box':
        filesFound = glob.glob(dataFolder + '/*bx.h5') + glob.glob(dataFolder + '/*bx_filtered.h5')
    if filetype == 'ellipse':
        filesFound = glob.glob(dataFolder + '/*el.h5') + glob.glob(dataFolder + '/*el_filtered.h5')
yana-yuhai commented 2 years ago

Hi,

I haven't changed the file names - perhaps it's the folder issue.

This is the folder pathway I've specified: D:\Yana\yana_training_social-Yana-2021-10-29\videos\h5

This is an example of a file name: Trial1_2021-07-17-095318-0000DLC0dlcmetms5_yana_training_socialOct29shuffle1_50000_el.h5

Is there a way I should rename the folder or files to resolve this issue? I'm not entirely sure where the issue is coming from. Thank you for the help.

sronilsson commented 2 years ago

Thanks @yana-yuhai - I tried to replicate this myself using the same folder-path as you and I didn't get any errors..

Is D:\ some external storage device? If so, could you try moving the files from the D:\ drive to C:\ or whatever the drive python is running on, and let me know if that works?

Also, I separate question (which is unrelated to your error), your filename is Trial1_2021-07-17-095318-0000DLC0dlcmetms5_yana_training_socialOct29shuffle1_50000_el.h5 and contains the substring DLC0dlcmetms5. I have not seen this before, they typically have the substring DLC_dlcrnetms5. Just wanted to check, is this a typo, or is your file named Trial1_2021-07-17-095318-0000DLC0dlcmetms5_yana_training_socialOct29shuffle1_50000_el.h5 and not Trial1_2021-07-17-095318-0000DLC_dlcrnetms5_yana_training_socialOct29shuffle1_50000_el.h5?

yana-yuhai commented 2 years ago

Yes, D:\ is a USB. I copied all the files to C:\ such that the path is now: C:\Yana\yana_training_social-Yana-2021-10-29\videos\h5

Also, yes that was a typo. The file has the substring DLC_dlcrnetms5.

Although I changed the location of the files, I'm still getting the same error message "importing 0 multi-animal DLC .h5 files..." Do you think there may be an issue with the h5 files themselves such that I'd have to re-analyze the videos on DLC and generate new h5 files? Could have copying the files to C:\ rather than moving them be causing this issue to persist (i.e. should I delete the files from D:)?

yana-yuhai commented 2 years ago

To walk you through what I've done prior to this error message:

Generated project Yana_SimBA in C:\Yana Created custom pose configuration Imported 5 videos from C:\Yana\yana_training_social-Yana-2021-10-29\videos\dlc-videos Then I get the error trying to import the h5 files

sronilsson commented 2 years ago

@yana-yuhai - alright. No, it won't be a pose-estimation issue. The message "importing 0 multi-animal DLC .h5 files..." suggests that SimBA just can't find any files with a el.h5 ending inside of the C:\Yana\yana_training_social-Yana-2021-10-29\videos\h5\ directory.

Try one more thing - just stick the h5 files inside of a folder on the desktop, e.g., C:\Yana\Desktop\MyVideos\ - I just want to confirm there is nothing strange on your end going on with the hyphens and numbers you have in the path. And let me know if you still get the same error?

yana-yuhai commented 2 years ago

I tried it but am still getting the error. One thing I noticed was that the pathway was C:\Yana\OneDrive\Desktop\MyVideos\

Do you think this could be due to saving files onto OneDrive?

sronilsson commented 2 years ago

I don't think that could be it, although I haven't tried to import data into SimBA from OneDrive. It might be worth trying just on your local machine, not OneDrive.

Could you do pip show simba-uw-tf-dev and post a screenshot of the output?

Could you also type pip show simba-uw-tf and pip show simba-uw-no-tf and make sure nothing is found for these two packages.

yana-yuhai commented 2 years ago

Here is the screenshot. I checked the other packages and they are not there

Screen Shot 2021-11-22 at 4 55 46 PM

.

sronilsson commented 2 years ago

Thanks @yana-yuhai, a little bit of a mystery at the moment.. I've tried to replicate again with exactly the same file formats and paths as you and I am not seeing the error..

What I have done now is to insert some better errors and print outs in SimBA when it tries to import the files, printing out which directories are being searched and for which file-endings, and if zero files are found, print out if any other files are found in the directory that is not matching the search criteria.

Can you update SimBA to version 0.88.1 by pip install simba-uw-tf-dev==0.88.1 and show me a screenshot of the SimBA terminal now after trying to import your files?

yana-yuhai commented 2 years ago
Screen Shot 2021-11-23 at 10 51 34 AM Screen Shot 2021-11-23 at 10 56 34 AM
yana-yuhai commented 2 years ago

Updated SimBA and the results are interesting. It's telling me that the files are non-ellipse. I tried switching the selection to box and skeleton and got the same output.

sronilsson commented 2 years ago

Oh your files seems to have the file-ending el.h5.h5, rather than el.h5, which is why this error is happening. If you look at the files in the file-explorer, are the files named el.h5.h5?

yana-yuhai commented 2 years ago

The files are named el.h5 in file explorer. Should I change them to just "el"? Maybe the .h5 is being added on somehow?

sronilsson commented 2 years ago

Hmm, no this is a little peculiar. Are you hiding the file-extensions in the file-explorer and have added them by hand, resulting in a duplication?

https://vtcri.kayako.com/article/296-view-file-extensions-windows-10

yana-yuhai commented 2 years ago

Yes, that's it! When I clicked extensions the file names appeared as el.h5.h5. How should I fix this?

sronilsson commented 2 years ago

Strange but good! I advice to always show file-endings. Just remove the duplicate file-extensions, so the files are named Trial1_2021-07-17-095318-0000DLC_dlcrnetms5_yana_training_socialOct29shuffle1_50000_el.h5 and not Trial1_2021-07-17-095318-0000DLC_dlcrnetms5_yana_training_socialOct29shuffle1_50000_el.h5.h5 and let me know if you can import them.

yana-yuhai commented 2 years ago

I think we've almost figured it out. It now says "importing 5 multi-animal DLC h5 files..." but is also giving me an error messages for one of the files that I've posted below

Screen Shot 2021-11-23 at 11 54 56 AM

.

yana-yuhai commented 2 years ago

Thank you so much for all the help, by the way.

sronilsson commented 2 years ago

Alright, progress! Next, SimBA searches for the video file associated with you multi-animal H5 file. It searches the project_folder/videos for a video associated with the Trial1_2021-07-17-095318-0000DLC_dlcrnetms5_yana_training_socialOct29shuffle1_50000_el.h5 file, but can't find anything. The screenshot you see is a range of file-names SimBA guessed that your video might have, inside the project_folder/videos folder. However, none of these files where located.

Have you imported your videos?

You can read more about this error and potential solutions here:

https://github.com/sgoldenlab/simba/blob/master/docs/FAQ.md#17-i-get-an-error-when-i-try-to-import-multi-animal-data-h5-files-from-deeplabcut-into-simba---the-error-says-that-simba-cannot-locate-my-video-files

Also, I can still see some el.h5.h5 in there. Make sure all of the files you are importing only has the el.h5 file-ending.

sronilsson commented 2 years ago

The first guess should be Trial1_2021-07-17-095318-0000.mp4 and Trial1_2021-07-17-095318-0000.avi

yana-yuhai commented 2 years ago

Yes, everything is working! I apologize for the delayed response. Thank you so much for the help.