deeplabcut.post_processing.analyze_skeleton
Contributed by Federico Claudi - https://github.com/FedeClaudi
Functions:
| Name | Description |
|---|---|
analyzebone |
[Computes length and orientation of the bone at each frame] |
analyzeskeleton |
Extracts length and orientation of each "bone" of the skeleton. |
angle_between_points_2d_anticlockwise |
angle_between_points_2d_clockwise [Determines the angle of a straight line drawn |
calc_angle_between_vectors_of_points_2d |
calc_angle_between_vectors_of_points_2d [calculates the clockwise angle between |
calc_distance_between_points_two_vectors_2d |
calc_distance_between_points_two_vectors_2d [pairwise distance between vectors |
analyzebone
[Computes length and orientation of the bone at each frame]
Source code in deeplabcut/post_processing/analyze_skeleton.py
analyzeskeleton
analyzeskeleton(
config,
videos,
video_extensions: str | Sequence[str] | None = None,
shuffle=1,
trainingsetindex=0,
filtered=False,
save_as_csv=False,
destfolder=None,
modelprefix="",
track_method="",
return_data=False,
**kwargs
)
Extracts length and orientation of each "bone" of the skeleton.
The bone and skeleton information is defined in the config file.
Parameters
config: str Full path of the config.yaml file.
list[str]
The full paths to videos for analysis or a path to the directory, where all the videos with same extension are stored.
str | Sequence[str] | None, optional, default=None
Controls how videos are filtered, based on file extension.
File paths and directory contents are treated differently:
- None (default): file paths are accepted as-is; directories are
scanned for files with a recognized video extension.
- str or Sequence[str] (e.g. "mp4" or ["mp4", "avi"]):
both file paths and directory contents are filtered by the given
extension(s).
int, optional, default=1
The shuffle index of training dataset. The extracted frames will be stored in the labeled-dataset for the corresponding shuffle of training dataset.
int, optional, default=0
Integer specifying which TrainingsetFraction to use. Note that TrainingFraction is a list in config.yaml.
bool, optional, default=False
Boolean variable indicating if filtered output should be plotted rather than
frame-by-frame predictions. Filtered version can be calculated with
deeplabcut.filterpredictions.
bool, optional, default=False
Saves the predictions in a .csv file.
string or None, optional, default=None
Specifies the destination folder for analysis data. If None, the path of
the video is used. Note that for subsequent analysis this folder also needs to
be passed.
str, optional, default=""
Directory containing the deeplabcut models to use when evaluating the network. By default, the models are assumed to exist in the project folder.
string, optional, default=""
Specifies the tracker used to generate the data. Empty by default (corresponding to a single animal project). For multiple animals, must be either 'box', 'skeleton', or 'ellipse' and will be taken from the config.yaml file if none is given.
bool, optional, default=False
If True, returns a dictionary of the filtered data keyed by video names.
additional arguments.
For torch-based shuffles, can be used to specify: - snapshot_index - detector_snapshot_index
Returns
video_to_skeleton_df Dictionary mapping video filepaths to skeleton dataframes.
* If no videos exist, the dictionary will be empty.
* If a video is not analyzed, the corresponding value in the dictionary will be
None.
Source code in deeplabcut/post_processing/analyze_skeleton.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
angle_between_points_2d_anticlockwise
angle_between_points_2d_clockwise [Determines the angle of a straight line drawn between point one and two. The number returned, which is a double in degrees, tells us how much we have to rotate a horizontal line anti-clockwise for it to match the line between the two points.]
Returns:
| Type | Description |
|---|---|
|
[int] -- [clockwise angle between p1, p2 using the inner product and the deterinant of the two vectors] |
- to check: print(zero, ninety, oneeighty, twoseventy)
zero = angle_between_points_2d_clockwise([0, 1], [0, 1]) ninety = angle_between_points_2d_clockwise([1, 0], [0, 1]) oneeighty = angle_between_points_2d_clockwise([0, -1], [0, 1]) twoseventy = angle_between_points_2d_clockwise([-1, 0], [0, 1]) ninety2 = angle_between_points_2d_clockwise([10, 0], [10, 1]) print(ninety2)
Source code in deeplabcut/post_processing/analyze_skeleton.py
calc_angle_between_vectors_of_points_2d
calc_angle_between_vectors_of_points_2d [calculates the clockwise angle between each set of point for two 2d arrays of points]
Returns:
| Type | Description |
|---|---|
|
[np.ndarray] -- [1d array with clockwise angle between pairwise points in v1,v2] |
Testing:
v1 = np.zeros((2, 4)) v1[1, :] = [1, 1, 1, 1, ] v2 = np.zeros((2, 4)) v2[0, :] = [0, 1, 0, -1] v2[1, :] = [1, 0, -1, 0] a = calc_angle_between_vectors_of_points_2d(v2, v1)
Source code in deeplabcut/post_processing/analyze_skeleton.py
calc_distance_between_points_two_vectors_2d
calc_distance_between_points_two_vectors_2d [pairwise distance between vectors points]
Returns:
| Type | Description |
|---|---|
|
[type] -- [description] |
testing:
v1 = np.zeros((2, 5)) v2 = np.zeros((2, 5)) v2[1, :] = [0, 10, 25, 50, 100] d = calc_distance_between_points_two_vectors_2d(v1.T, v2.T)