dattalab / keypoint-moseq

https://keypoint-moseq.readthedocs.io
Other
64 stars 26 forks source link

KeyError when generating dataframes for newly added data #98

Closed ryanschwark closed 10 months ago

ryanschwark commented 10 months ago

Hi all, After successfully applying a previously-trained model to new data, I've been trying to obtain the moseq_df and stats_df csv files incorporating this newly added data, using the analysis notebook. I've made sure that the newly added data is now part of the results.h5 file, and that the folder structure is correct. After importing the updated data into the analysis notebook, I used the cell in '1.3. Generate dataframes' as follows, and got the resulting error:

moseq_df = kpms.compute_moseq_df(project_dir, model_name, smooth_heading=True) moseq_df


KeyError Traceback (most recent call last) Cell In[26], line 1 ----> 1 moseq_df = kpms.compute_moseq_df(project_dir, model_name, smooth_heading=True) 2 moseq_df

File ~\anaconda3\envs\keypoint_moseq\lib\site-packages\keypoint_moseq\analysis.py:163, in compute_moseq_df(project_dir, model_name, fps, smooth_heading) 149 velocity.append( 150 np.concatenate( 151 ( (...) 158 ) 159 ) 161 if file_info is not None: 162 # find the group for each recording from index data --> 163 s_group.append([file_info[k]["group"]] n_frame) 164 else: 165 # no index data 166 s_group.append(["default"] n_frame)

KeyError: 'Five mole-rats open field-841-006-592+600-575-076+035-609-606+075-045-624+033-347-603 - 10min trim_track0'

What might be causing this error? Thanks!

calebweinreb commented 10 months ago

Probably the new sessions are missing from the index.yaml file in the project directory. Can you confirm if that is the case? If so, you can add them manually using a text editor or with the widget (index_file=kpms.interactive_group_setting(project_dir, model_name)) if you have it working.

Also @versey-sherry we should catch this error in the future.

ryanschwark commented 10 months ago

Yep you were right, I just checked the index.yaml file and the newly added videos were nowhere to be found. The file only contains the videos that the model was originally trained on.

After manually adding each file name to the index.yaml file, it worked! I was able to export both the moseq_df file and the moseq_stats file!

Thanks so much!