Closed klgrove closed 7 months ago
Hi @klgrove, did you analyze the videos before running the analyze_skeleton
code? The skeleton analysis code uses the output from deeplabcut.analyze_videos
, so you would need to run it first, such as:
videos = r"C:\Users\klgrove\OneDrive - Inside MD Anderson\Documents\Shepherd Lab\Baseline Testing\Toe Spread Vids"
deeplabcut.analyze_videos(
config_path, videos, videotype='mp4', shuffle=1, trainingsetindex=0, filtered=True, save_as_csv=True, destfolder=None
)
deeplabcut.analyzeskeleton(
config_path, videos, videotype='mp4', shuffle=1, trainingsetindex=0, filtered=True, save_as_csv=True, destfolder=None
)
Yes, I did analyze the videos first.
Does the Analyze Skeleton output a different CSV file than what I would get with just converting the h5 files to CSV? I was able to convert the H5 files to CSV, but I wasn't sure if Analyze Skeleton gives a different output.
@klgrove yes, deeplabcut.analyzeskeleton
computes the length and orientation of each bone in the skeleton (the skeleton as it's defined in your project config.yaml
), and it computes these values by using the output of deeplabcut.analyze_videos
.
Can you check if you have output files in your video folder (C:\Users\klgrove\OneDrive - Inside MD Anderson\Documents\Shepherd Lab\Baseline Testing\Toe Spread Vids
)?
The filenames should have names in the format {video_name}DLC_resnet50_LatToeSpreadNov17shuffle1_45000_el.pickle
The output files are there, but some of them look like they used an old snapshot (20000 versus 45000). Would that make a difference? Do I need to re-analyze the videos using the old snapshot before running analyze skeleton?
I ran deeplabcut.analyze_videos on the entire folder again, and then tried analyze skeleton, and I am still getting the same error: No filtered data file found.
I tried analyze skeleton again this morning, and this is what it spit out:
Processing Q:\Behavioral Care and Enrichment\Research Projects & Data\Kristi Grove\Shepherd Lab\Baseline Testing\Toe Spread Vids\22Dec2023 (1)-converted.mp4
No filtered data file found in Q:\Behavioral Care and Enrichment\Research Projects & Data\Kristi Grove\Shepherd Lab\Baseline Testing\Toe Spread Vids for video 22Dec2023 (1)-converted and scorer DLC_resnet50_LatToeSpreadNov17shuffle1_45000 and ellipse tracker.
Processing Q:\Behavioral Care and Enrichment\Research Projects & Data\Kristi Grove\Shepherd Lab\Baseline Testing\Toe Spread Vids\22Dec2023 (2)-converted.mp4
C:\Users\klgrove\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\deeplabcut\post_processing\analyze_skeleton.py:286: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.
for animal_name, df_ in df.groupby(level="individuals", axis=1):
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[31], line 1
----> 1 deeplabcut.analyzeskeleton(config, r"Q:\Behavioral Care and Enrichment\Research Projects & Data\Kristi Grove\Shepherd Lab\Baseline Testing\Toe Spread Vids", videotype='mp4', shuffle=1, trainingsetindex=0, filtered=True, save_as_csv=True, destfolder=None)
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\deeplabcut\post_processing\analyze_skeleton.py:291, in analyzeskeleton(config, videos, videotype, shuffle, trainingsetindex, filtered, save_as_csv, destfolder, modelprefix, track_method, return_data)
289 for bp1, bp2 in cfg["skeleton"]:
290 name = "{}_{}_{}".format(animal_name, bp1, bp2)
--> 291 bones[name] = analyzebone(temp[bp1], temp[bp2])
292 else:
293 for bp1, bp2 in cfg["skeleton"]:
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\deeplabcut\post_processing\analyze_skeleton.py:155, in analyzebone(bp1, bp2)
152 bp2_pos = np.vstack([bp2.x.values, bp2.y.values]).T
154 # get bone length and orientation
--> 155 bone_length = calc_distance_between_points_two_vectors_2d(bp1_pos, bp2_pos)
156 bone_orientation = calc_angle_between_vectors_of_points_2d(bp1_pos.T, bp2_pos.T)
158 # keep the smallest of the two likelihoods
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\deeplabcut\post_processing\analyze_skeleton.py:59, in calc_distance_between_points_two_vectors_2d(v1, v2)
56 raise ValueError("Error: input arrays should have the same length")
58 # Calculate distance
---> 59 dist = [distance.euclidean(p1, p2) for p1, p2 in zip(v1, v2)]
60 return dist
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\deeplabcut\post_processing\analyze_skeleton.py:59, in <listcomp>(.0)
56 raise ValueError("Error: input arrays should have the same length")
58 # Calculate distance
---> 59 dist = [distance.euclidean(p1, p2) for p1, p2 in zip(v1, v2)]
60 return dist
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\scipy\spatial\distance.py:536, in euclidean(u, v, w)
500 def euclidean(u, v, w=None):
501 """
502 Computes the Euclidean distance between two 1-D arrays.
503
(...)
534
535 """
--> 536 return minkowski(u, v, p=2, w=w)
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\scipy\spatial\distance.py:496, in minkowski(u, v, p, w)
494 root_w = np.power(w, 1/p)
495 u_v = root_w * u_v
--> 496 dist = norm(u_v, ord=p)
497 return dist
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\scipy\linalg\_misc.py:146, in norm(a, ord, axis, keepdims, check_finite)
144 # Differs from numpy only in non-finite handling and the use of blas.
145 if check_finite:
--> 146 a = np.asarray_chkfinite(a)
147 else:
148 a = np.asarray(a)
File ~\AppData\Local\anaconda3\envs\tfdml_plugin\lib\site-packages\numpy\lib\function_base.py:630, in asarray_chkfinite(a, dtype, order)
628 a = asarray(a, dtype=dtype, order=order)
629 if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
--> 630 raise ValueError(
631 "array must not contain infs or NaNs")
632 return a
ValueError: array must not contain infs or NaNs
Is there an existing issue for this?
Bug description
I am trying to generate CSV files of the skeletons for analysis. I followed the steps outlined here: https://github.com/DeepLabCut/DeepLabCut/blob/main/deeplabcut/post_processing/analyze_skeleton.py
Everything seems to go fine using the code above, but when I try to analyze the skeleton, I get the following error:
Operating System
Windows 10 Enterprise
DeepLabCut version
dlc version 2.3.8
DeepLabCut mode
multi animal
Device type
GPU 0-Intel (R) UHD Graphics GPU 1-AMD Radeon RX 6500
Steps To Reproduce
Relevant log output
Anything else?
No response
Code of Conduct