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

Problens with simba (ROIS) #221

Open anacastropsico opened 1 year ago

anacastropsico commented 1 year ago

Describe the bug I have 3 issues When I go Set video parameters this erro is show:

warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:901) warning: C:/Users/anaca/Downloads/Testes track/pYRAT\BODY\project_folder\videos\0 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:902).

When I run Outiler correction this is show Exception in Tkinter callback Traceback (most recent call last): File "c:\users\anaca\anaconda3\envs\simba\lib\tkinter__init.py", line 1705, in call__ return self.func(*args) File "c:\users\anaca\anaconda3\envs\simba\lib\site-packages\simba\SimBA.py", line 3668, in button_skipOC = Button(label_outliercorrection,text='Skip outlier correction (CAUTION)',fg='red', command=lambda:skip_outlier_c(self.projectconfigini)) File "c:\users\anaca\anaconda3\envs\simba\lib\site-packages\simba\outlier_scripts\skip_outlierCorrection.py", line 52, in skip_outlier_c csv_df.columns = newHeaders File "c:\users\anaca\anaconda3\envs\simba\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:\users\anaca\anaconda3\envs\simba\lib\site-packages\pandas\core\generic.py", line 690, in _set_axis self._data.set_axis(axis, labels) File "c:\users\anaca\anaconda3\envs\simba\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 36 elements, new values have 30 elements

When I run ROI analyses Nothing is generated

sronilsson commented 1 year ago

Hi @anacastropsico! Which version of simba are you running? Can you try to upgrade simba with pip install simba-uw-tf-dev --upgrade and let me know if you still see the same error msg?

anacastropsico commented 1 year ago

Hi @anacastropsico! Which version of simba are you running? Can you try to upgrade simba with pip install simba-uw-tf-dev --upgrade and let me know if you still see the same error msg?

I had problems with the installation and I had two versions of simba installed. simba-uw-tf-dev 1.2 simba-uw-no-tf 1.3 (I installed this one because I don't have a GPU). I only want to use simba to run ROIS analysis with my DLC files. I don't have a GPU, which version do you recommend? Can I just run the command you suggested?

anacastropsico commented 1 year ago

Now I'm with version simba: simba-uw-tf-dev-1.22.4 I have problem with outliers corretion, when I click in 'Run' show this...

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705, in call__ return self.func(*args) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 3131, in correct_outlier outlier_correcter_movement = OutlierCorrecterMovement(config_path=configini)

File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\outlier_scripts\outlier_corrector_movement.py", line 59, in init self.outlier_bp_dict[animal_name]['bp_1'] = read_config_entry(self.config, 'Outlier settings', 'movementbodypart1{}'.format(animal_name.lower()), 'str') File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\read_config_unit_tests.py", line 110, in read_config_entry raise ValueError ValueError ![image](https://user-images.githubusercontent.com/81208194/204927867-2f113fa9-bd7c-4d09-a5d2-9b86de6bbb84.png If I want skip outlier...

Processing 1 file(s) this is show in SIMBA interface load. SIMBA ERROR: SimBA expects 30 columns of data inside the files within project_folder/csv/input_csv directory. However, within file C:/Users/anaca/Downloads/Testes track/pYRAT\BODY\project_folder\csv\input_csv\R20D25T4DLC.csv file, SimBA found 36 columns.

sronilsson commented 1 year ago

Thanks @anacastropsico - use the simba-uw-tf-dev version, and make sure the simba-uw-no-tf version is uninstalled by running pip uninstall simba-uw-no-tf.

There seems to be a couple things going on. We should deal with the error at the end first: SIMBA ERROR: SimBA expects 30 columns.... This suggests that your data contains pose-estimation for 12 body-parts (36/3). However, when SimBA looks to see how many body-parts are defined in the SimBA project, it finds 10 (30/3). When you created your SimBA project, could you have missed out two body-parts? The body-parts that your projectis expecting is stored within your SimBA project in the project_folder/logs/measures/pose_configs/bp_names/project_bp_names.csv CSV so you could have a look there.

anacastropsico commented 1 year ago

I have only 10 body-parts image

anacastropsico commented 1 year ago

Obrigado@anacastropsico- use a simba-uw-tf-devversão e certifique-se de que a simba-uw-no-tfversão seja desinstalada executando pip uninstall simba-uw-no-tf.

Parece haver algumas coisas acontecendo. Devemos lidar com o erro no final primeiro: SIMBA ERROR: SimBA expects 30 columns.... Isso sugere que seus dados contêm estimativa de pose para 12 partes do corpo (36/3). No entanto, quando o SimBA verifica quantas partes do corpo estão definidas no projeto SimBA, ele encontra 10 (30/3). Quando você criou seu projeto SimBA, poderia ter perdido duas partes do corpo? As partes do corpo que seu projeto espera são armazenadas em seu projeto SimBA no project_folder/logs/measures/pose_configs/bp_names/project_bp_names.csvCSV para que você possa dar uma olhada lá.

I try ainda remake bodyparts in new project.. this erro is show

Traceback (most recent call last): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705, in call return self.func(*args) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 915, in self.saveposeConfigbutton = Button(self.scroller,text='Save Pose Config',command=lambda:self.savePoseConfig(self.scroller)) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 943, in savePoseConfig animal_id_int_list=animal_id_lst) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\user_pose_config_creator.py", line 53, in init__ self.img_height, self.img_width = int(self.img.shape[0]), int(self.img.shape[1]) AttributeError: 'NoneType' object has no attribute 'shape'

sronilsson commented 1 year ago

That error msg suggests that you selected no image, or a file that could not be read as an image, to represent your user defined body-part configuration.

anacastropsico commented 1 year ago

msg suggests that you selected no image, or a file that could not be read as an image, to represent your user defined body-part configuration.

I'm concert to number body part. Now erro is with csv file DLC imput...when I click in outlier correct show

I'm using single animal. Processing 1 file(s)... ('Unable to parse string "20.672.662.839.053.200" at position 0', 'occurred at index fucinho')

SIMBA WARNING: SimBA found more than the expected two header columns. SimBA will try to proceed by removing one additional column header level. This can happen when you import multi-animal DLC data as standard DLC data.

my file: image

sronilsson commented 1 year ago

Looking at that spreadsheet, the values does not look like pixel coordinates. SimBA expects float or integer values, but encounters, for example, 20.672.662.839.053.200 as the first value which is a string and not a number. SimBA tries to convert it to a number but fails and thats why you see this error.

Could you think of any reason why the values wouldn't be numeric?

anacastropsico commented 1 year ago

Olhando para essa planilha, os valores não se parecem com coordenadas de pixel. O SimBA espera valores flutuantes ou inteiros, mas encontra, por exemplo, 20.672.662.839.053.200como o primeiro valor que é uma string e não um número. O SimBA tenta convertê-lo em um número, mas falha e é por isso que você vê esse erro.

Você poderia pensar em algum motivo para os valores não serem numéricos?

what would be a value that simba expects? all my DLC output sheets came out like this... and I looked at copies of the simba documentation and they are similar to mine. I didn't understand what the problem was with the values in my table. I can user the H5 file?

sronilsson commented 1 year ago

I think it's not just SimBA, but most or all processing tools require values that refer to pixel locations in either float of int type., you have string type location predictions. E.g., here is a file from one of my test preojects. SI_DAY3_308_CD1_PRESENT.csv

anacastropsico commented 1 year ago

I ran my analyzes on google colab, I don't know if there is a problem with formatting the file there and when downloading it happens...visibly for me your table is the same as the one I have on the pc... image

sronilsson commented 1 year ago

Hi @anacastropsico - might be some issue when you open your file in Microsoft Excel. Difficult to see.. but your values are not comma separated ints or floats image

sronilsson commented 1 year ago

Whereas on right, we have a float image

anacastropsico commented 1 year ago

I understend now... I execulted one conversion in my table... see..

image

but one erro is show in anaconda.

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705, in call__ return self.func(*args) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 1472, in button_skipOC = Button(label_outliercorrection,text='Skip outlier correction (CAUTION)',fg='red', command=lambda: self.initiate_skip_outlier_correction()) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 2035, in initiate_skip_outlier_correction outlier_correction_skipper.skip_outlier_correction() File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\outlier_scripts\skip_outlier_correction.py", line 58, in skip_outlier_correction data_df = read_df(file_path, self.file_type) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\rw_dfs.py", line 25, in read_df df = pd.read_csv(file_path, index_col=idx, low_memory=False) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\pandas\io\parsers.py", line 685, in parser_f return _read(filepath_or_buffer, kwds) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\pandas\io\parsers.py", line 463, in _read data = parser.read(nrows) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\pandas\io\parsers.py", line 1154, in read ret = self._engine.read(nrows) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\pandas\io\parsers.py", line 2059, in read data = self._reader.read(nrows) File "pandas/_libs/parsers.pyx", line 884, in pandas._libs.parsers.TextReader.read File "pandas/_libs/parsers.pyx", line 965, in pandas._libs.parsers.TextReader._read_rows File "pandas/_libs/parsers.pyx", line 2132, in pandas._libs.parsers.raise_parser_error pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 32 in interface simba show: Processing 1 file(s)...

sronilsson commented 1 year ago

Those values you see now are VERY large integers, it is unlikely that fucino is located at those pixel values, it would be a video with resolution unlikely to fit on a harddisk. Maybe the separator in the float was removed by mistake?

anacastropsico commented 1 year ago

Esses valores que você vê agora são inteiros MUITO grandes, é improvável que fucinoesteja localizado nesses valores de pixel, seria um vídeo com resolução improvável de caber em um disco rígido. Talvez o separador no flutuador tenha sido removido por engano?

So I really need to look for another solution. I don't know why these outputs were generated as a string. I cant user the H5 file? or no?

sronilsson commented 1 year ago

Yes you can try and import the H5, I don't know how many animals you are tracking, but you can try to import the h5

anacastropsico commented 1 year ago

Yes you can try and import the H5, I don't know how many animals you are tracking, but you can try to import the h5

I'm tracking only single animal. The problem in my tables is when I open in excel... whem i open in google or notes the values are...

image

sronilsson commented 1 year ago

👍 The pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 32 error suggest there is some file inside the project_folder/csv/input_csv that cannot be opened as a CSV, that even though that file has a .csv file extension, it is not a proper csv

anacastropsico commented 1 year ago

👍O pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 32erro sugere que há algum arquivo dentro do project_folder/csv/input_csvque não pode ser aberto como CSV, embora esse arquivo tenha uma extensão de arquivo .csv, não é um csv adequado

Does that mean I won't be able to use the csv files from the colab? even the ones I didn't open in excel? to use the H5 how should I define the settings when creating the project? There I only have the h5 file option for multi_animals.

👍 The pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 32 error suggest there is some file inside the project_folder/csv/input_csv that cannot be opened as a CSV, that even though that file has a .csv file extension, it is not a proper csv

Does that mean I won't be able to use the csv files from the colab? even the ones I didn't open in excel? to use the H5 how should I define the settings when creating the project? There I only have the h5 file option for multi_animals.

sronilsson commented 1 year ago

You should be able to use the CSV just fine, it looks proper in that last screengrab. When you see thepandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 32, do you see any erro msgs in the main simba terminal window?

anacastropsico commented 1 year ago

Você deve ser capaz de usar o CSV muito bem, parece adequado na última captura de tela. Quando você vê o pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 4, saw 32, você vê alguma mensagem de erro na janela principal do terminal simba?

No... simba show : Processing 1 files(s)...

sronilsson commented 1 year ago

How many files are in the project_folder/csv/input_csv folder, and can you sen me an example?

anacastropsico commented 1 year ago

How many files are in the project_folder/csv/input_csv folder, and can you sen me an example?

Only 1. image

anacastropsico commented 1 year ago

When I go create a new project with same file csv this erro is show... Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705, in call__ return self.func(*args) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 1016, in import_singlecsv shutil.copy() TypeError: copy() missing 2 required positional arguments: 'src' and 'dst'

image

anacastropsico commented 1 year ago

Now is done!!! image

sronilsson commented 1 year ago

Hmm.. have a trouble keeping up :) But will go over and see whats going on later.

anacastropsico commented 1 year ago

When I finally defined the ROIS, conda show it... Select a ROI and then press SPACE or ENTER button! Cancel the selection process by pressing c button! Select a ROI and then press SPACE or ENTER button! Cancel the selection process by pressing c button! Select a ROI and then press SPACE or ENTER button! Cancel the selection process by pressing c button! Fatal Python error: PyEval_RestoreThread: NULL tstate

Current thread 0x000001cc (most recent call first): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_image.py", line 224 in initiate_x_y_callback File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_image.py", line 295 in interact_functions File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_define.py", line 483 in set_interact_state File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_define.py", line 308 in File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705 in call File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter\init.py", line 560 in mainloop File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_define.py", line 124 in init File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_menus.py", line 60 in draw File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter\init.py", line 1705 in call File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter\init.py", line 1283 in mainloop File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 3770 in main File "C:\Users\anaca\anaconda3\envs\SIMBA\Scripts\simba.exe\main__.py", line 7 in File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\runpy.py", line 85 in _run_code File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\runpy.py", line 193 in _run_module_as_main (SIMBA) PS C:\WINDOWS\system32>

sronilsson commented 1 year ago

Interesting, which version of python are you running python --version in your SIMBA conda environment

anacastropsico commented 1 year ago

Interesting, which version of python are you running python --version in your SIMBA conda environment python 3.6.13 image

sronilsson commented 1 year ago

Same as me so not that, if you reboot conda, do you still get the sam error?

anacastropsico commented 1 year ago

Same as me so not that, if you reboot conda, do you still get the sam error?

I restarted the pc already... and the same error continues

Fatal Python error: PyEval_RestoreThread: NULL tstate

Current thread 0x00001de4 (most recent call first): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_image.py", line 224 in initiate_x_y_callback File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_image.py", line 295 in interact_functions File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_define.py", line 483 in set_interact_state File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_define.py", line 308 in File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705 in call File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter\init.py", line 560 in mainloop File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_define.py", line 124 in init File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\roi_tools\ROI_menus.py", line 60 in draw File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter\init.py", line 1705 in call File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter\init.py", line 1283 in mainloop File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 3770 in main File "C:\Users\anaca\anaconda3\envs\SIMBA\Scripts\simba.exe\main__.py", line 7 in File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\runpy.py", line 85 in _run_code File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\runpy.py", line 193 in _run_module_as_main (SIMBA) PS C:\WINDOWS\system32> ... this happenes when I close define shapes windows...then I'm trying to save the ROI without closing the window, but the save button is inaccessible, invisible on the screen. image

sronilsson commented 1 year ago

Maybe because monitor is small, up you update simba I made the window scrollable

anacastropsico commented 1 year ago

Maybe because monitor is small, up you update simba I made the window scrollable

I updante thanks... I have new problem... the ROIS values (time) is 0. For moviment os ok... image

Also, another error is encountered when I try to use the append Roi fature. It says: Analyzing R20D25T3DLC... in acandonda: During the handling of the above exception, another exception occurred:

Traceback (last most recent call): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705, in call return self.func(*args) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\setting_menu.py", line 95, in self.run_btn = Button(self.execute_frm, text='Run', command=lambda: self.run_analysis()) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\setting_menu.py", line 162, in run_analysis roi_feature_creator.analyze_ROI_data() File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\ROI_feature_analyzer.py", line 114, in analysis_ROI_data self.distance_to_roi_centroids() File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\ROI_feature_analyzer.py", line 147, at __distance_to_roi_centroids raise KeyError KeyError without simba SIMBA ERROR: The ROI named Obj1 could not be found in video R20D25T3DLC

sronilsson commented 1 year ago

Do you have an ROI drawn called Obj1 in R20D25T3DLC?

anacastropsico commented 1 year ago

Do you have an ROI drawn called Obj1 in R20D25T3DLC?

Is ok, Done, Resolved... now I have problem when I run directionality betwenn animals. I whant see when animal direction head to obj.

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\tkinter__init.py", line 1705, in call__ return self.func(*args) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 1367, in button_analyzeDirection = Button(processmovementdupLabel,text='Analyze directionality between animals',command =lambda: self.directing_other_animals_analysis()) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\SimBA.py", line 1986, in directing_other_animals_analysis directing_animals_analyzer.create_directionality_dfs() File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\simba\Directing_animals_analyzer.py", line 125, in create_directionality_dfs self.directionality_df_dict[video_name] = pd.concat(out_df_lst, axis=0).drop('Directing_BOOL', axis=1) File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\pandas\core\reshape\concat.py", line 255, in concat sort=sort, File "C:\Users\anaca\anaconda3\envs\SIMBA\lib\site-packages\pandas\core\reshape\concat.py", line 304, in init raise ValueError("No objects to concatenate") ValueError: No objects to concatenate

sronilsson commented 1 year ago

Yes that method is for analyzing animal-animal directionality. Try the ROI features methods. It won't work as you only have one animal, I should insert s better error msg