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 import h5 file from DLC #243

Closed gemajpg closed 1 year ago

gemajpg commented 1 year ago

Hi! I cannot import the h5 file from DLC when trying to import tracking data. I get the following message:

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\mixins\pop_up_mixin.py", line 430, in tracking_data_type=self.dlc_data_type_option_dropdown.getChoices())) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\mixins\pop_up_mixin.py", line 290, in run_call dlc_multi_animal_importer.import_data() File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\pose_importers\dlc_multi_animal_importer.py", line 372, in import_data self.find_video_file() File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\pose_importers\dlc_multi_animal_importer.py", line 142, in __find_video_file raise NoFilesFoundError(msg=f'SimBA searched your project_folder/videos directory for a video file representing {self.file_name}, and could not find a match. Above is a list of possible video filenames that SimBA searched for within your projects video directory without success.') simba.utils.errors.NoFilesFoundError: SimBA searched your project_folder/videos directory for a video file representing Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el, and could not find a match. Above is a list of possible video filenames that SimBA searched for within your projects video directory without success.

But I have also recieved other errors, it doesn't seem to be stable.

I tried to look up for answers in others issues or the FAQ but none of them seem to solve it for me.

For example, I did not change the name of any file after they were created by DLC. And I've been following the steps provided by the generic simBA tutorial.

I do have to mention, I had the following issue with Tkinter (the create project window was blank) but was fixed yesterday in this issue:

https://github.com/sgoldenlab/simba/issues/242

It changed the script to create a project.

I am using simBA on Anaconda.

Does someone know how to fix it?

Sorry if I didn't explain myself very clearly, I have nearly no knowledge of this topic.

Thank you in advance.

sronilsson commented 1 year ago

Hi @gemajpg!

SimBA is looking for a video file inside your project, in the project_folder/videos/ directory, called Vídeo ratones blancos.mp4 or Vídeo ratones blancos.avi, but can't find it. Does e.g., project_folder/videos/Vídeo ratones blancos.avi exist?

gemajpg commented 1 year ago

@sronilsson Hi! It has the video imported before with its original name: Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_full

Should I change it to only "Vídeo ratones blancos.mp4"?

sronilsson commented 1 year ago

Hi @gemajpg! Yes but Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_full does not sound like an original video you named, it sounds lik a video visualization example created by deeplabcut. SimBA wants the original video.

gemajpg commented 1 year ago

@sronilsson Okay! Thank you! I tried with the original video, now I get this:

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 627, in open self._handle = tables.open_file(self._path, self._mode, kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\tables\file.py", line 315, in open_file return File(filename, mode, title, root_uep, filters, kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\tables\file.py", line 778, in init self._g_new(filename, mode, **params) File "tables\hdf5extension.pyx", line 492, in tables.hdf5extension.File._g_new tables.exceptions.HDF5ExtError: HDF5 error back trace

File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5F.c", line 509, in H5Fopen unable to open file File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5Fint.c", line 1498, in H5F_open unable to open file: time = Mon Apr 3 21:26:25 2023 , name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', tent_flags = 0 File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FD.c", line 734, in H5FD_open open failed File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FDsec2.c", line 346, in H5FD_sec2_open unable to open file: name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0

End of HDF5 error back trace

Unable to open/create file 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5'

During handling of the above exception, another exception occurred:

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\mixins\pop_up_mixin.py", line 430, in tracking_data_type=self.dlc_data_type_option_dropdown.getChoices())) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\mixins\pop_up_mixin.py", line 290, in run_call dlc_multi_animal_importer.import_data() File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\pose_importers\dlc_multi_animal_importer.py", line 373, in import_data self.data_df = pd.read_hdf(file_path).replace([np.inf, -np.inf], np.nan).fillna(0) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 384, in read_hdf store = HDFStore(path_or_buf, mode=mode, **kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 505, in init__ self.open(mode=mode, **kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 661, in open raise IOError(str(e)) OSError: HDF5 error back trace

File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5F.c", line 509, in H5Fopen unable to open file File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5Fint.c", line 1498, in H5F_open unable to open file: time = Mon Apr 3 21:26:25 2023 , name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', tent_flags = 0 File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FD.c", line 734, in H5FD_open open failed File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FDsec2.c", line 346, in H5FD_sec2_open unable to open file: name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0

End of HDF5 error back trace

Unable to open/create file 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5'

sronilsson commented 1 year ago

Hi @gemajpg! This suggest you have a data file inside your videos folder. It seems like SimBA is trying to open the file, assuming it is a data file, but it is not a data file. Just to check, is `'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5' a data file, or is it a video file?

gemajpg commented 1 year ago

@sronilsson Yes, it's a h5 data file I believe. I tried also to put it outside the folder where DLC creates it (the one for the videos) but it still can't seem to open it either.

It was taken from this folder, I think it is the file needed. image

In the information of Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5 it says it is a h5 file: image

sronilsson commented 1 year ago

Got it, - in your SImBA project, first import the video for Vídeo ratones blancos, next, import the data: which is the Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5 file.

gemajpg commented 1 year ago

@sronilsson Hi! I have been doing that all the time and it still gives me the same error. image

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 627, in open self._handle = tables.open_file(self._path, self._mode, kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\tables\file.py", line 315, in open_file return File(filename, mode, title, root_uep, filters, kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\tables\file.py", line 778, in init self._g_new(filename, mode, **params) File "tables\hdf5extension.pyx", line 492, in tables.hdf5extension.File._g_new tables.exceptions.HDF5ExtError: HDF5 error back trace

File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5F.c", line 509, in H5Fopen unable to open file File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5Fint.c", line 1498, in H5F_open unable to open file: time = Thu Apr 6 14:26:26 2023 , name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', tent_flags = 0 File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FD.c", line 734, in H5FD_open open failed File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FDsec2.c", line 346, in H5FD_sec2_open unable to open file: name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0

End of HDF5 error back trace

Unable to open/create file 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5'

During handling of the above exception, another exception occurred:

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\mixins\pop_up_mixin.py", line 430, in tracking_data_type=self.dlc_data_type_option_dropdown.getChoices())) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\mixins\pop_up_mixin.py", line 290, in run_call dlc_multi_animal_importer.import_data() File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\simba\pose_importers\dlc_multi_animal_importer.py", line 373, in import_data self.data_df = pd.read_hdf(file_path).replace([np.inf, -np.inf], np.nan).fillna(0) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 384, in read_hdf store = HDFStore(path_or_buf, mode=mode, **kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 505, in init__ self.open(mode=mode, **kwargs) File "C:\Users\gemap\Anaconda3\envs\simba\lib\site-packages\pandas\io\pytables.py", line 661, in open raise IOError(str(e)) OSError: HDF5 error back trace

File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5F.c", line 509, in H5Fopen unable to open file File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5Fint.c", line 1498, in H5F_open unable to open file: time = Thu Apr 6 14:26:26 2023 , name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', tent_flags = 0 File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FD.c", line 734, in H5FD_open open failed File "D:\pytables_hdf5\CMake-hdf5-1.10.5\hdf5-1.10.5\src\H5FDsec2.c", line 346, in H5FD_sec2_open unable to open file: name = 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0

End of HDF5 error back trace

Unable to open/create file 'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5'

sronilsson commented 1 year ago

Hi @gemajpg - is there anything odd going on with `'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5' - how large is the file?

gemajpg commented 1 year ago

@sronilsson It is 1,83 MB (1.920.300 bytes). Is it too big?

sronilsson commented 1 year ago

Oh no it's very small - something could have gone wrong when created. Do you have the same issue with every .h5 files?

gemajpg commented 1 year ago

@sronilsson Yes, I tried with another one I had and it still shows the same error. I believe it might have something to do with Tkinter or the script since, as I said, it didn't used to let me open the "create file" window, it was blank but was fixed in this other issue: https://github.com/sgoldenlab/simba/issues/242

Could it have something to do?

sronilsson commented 1 year ago

I don't think so, this error comes from pandas, trying to open the h5 file. However, we hit an error `'C:/Users/gemap/Desktop/pruebasparasimba-GJP-2023-04-02/videos\Vídeo ratones blancosDLC_resnet50_pruebasparasimbaApr2shuffle1_50000_el.h5' meaning either the file is corrupted or it doesn't exist. If you paste the file here I can give it a go

gemajpg commented 1 year ago

@sronilsson It did not let me upload the file since it doesn't support this file type. I uploaded it to google drive so I can share it. Here's the link: https://drive.google.com/file/d/1ZNZi5-rZO8Lo0ZB21kSGIucMSFOgJ6IZ/view?usp=sharing

Thank you for all the help so far!

sronilsson commented 1 year ago

No worries. It's strange because I have no problem reading this file..

But some report similar issues with non-english characters in the file names HERE. Could you see if changing Vídeo to Video fixes it?

gemajpg commented 1 year ago

@sronilsson it worked! thank you!