deeplabcut.refine_training_dataset.outlier_frames
Functions:
| Name | Description |
|---|---|
PlottingSingleFrame |
Label frame and save under imagename / this is already cropped (for clip) |
PlottingSingleFramecv2 |
Label frame and save under imagename / cap is not already cropped. |
attempt_to_add_video |
Add new videos to the config file at any stage of the project. |
compute_deviations |
Fits Seasonal AutoRegressive Integrated Moving Average with eXogenous regressors |
convertparms2start |
Creating a start value for sarimax in case of an value error |
extract_outlier_frames |
Extracts the outlier frames. |
find_outliers_in_raw_data |
Extract outlier frames from either raw detections or assemblies of multiple |
find_outliers_in_raw_detections |
Find outlier frames from the raw detections of multiple animals. |
merge_datasets |
Merge the original training dataset with the newly refined data. |
PlottingSingleFrame
PlottingSingleFrame(
clip,
Dataframe,
bodyparts2plot,
tmpfolder,
index,
dotsize,
pcutoff,
alphavalue,
colors,
strwidth=4,
savelabeled=True,
)
Label frame and save under imagename / this is already cropped (for clip)
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
PlottingSingleFramecv2
PlottingSingleFramecv2(
cap, Dataframe, bodyparts2plot, tmpfolder, index, dotsize, pcutoff, alphavalue, colors, strwidth=4, savelabeled=True
)
Label frame and save under imagename / cap is not already cropped.
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
attempt_to_add_video
Add new videos to the config file at any stage of the project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
string
|
Full path of the config file in the project. |
required |
|
string
|
Full path of the video to add to the project. |
required |
|
bool
|
If this is set to True, the videos will be copied
to the project/videos directory. If False, the symlink of the videos will
be copied instead. The default is |
required |
|
list
|
A list containing the list of cropping coordinates of the video. Defaults to None. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True iff the video was successfully added to the project. |
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
compute_deviations
Fits Seasonal AutoRegressive Integrated Moving Average with eXogenous regressors model to data and computes confidence interval as well as mean fit.
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
convertparms2start
Creating a start value for sarimax in case of an value error See: https://groups.google.com/forum/#!topic/pystatsmodels/S_Fo53F25Rk
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
extract_outlier_frames
extract_outlier_frames(
config: str | Path,
videos: list[str | Path],
video_extensions: str | Sequence[str] | None = None,
shuffle=1,
trainingsetindex=0,
outlieralgorithm="jump",
frames2use=None,
comparisonbodyparts="all",
epsilon=20,
p_bound=0.01,
ARdegree=3,
MAdegree=1,
alpha=0.01,
extractionalgorithm="kmeans",
automatic=False,
cluster_resizewidth=30,
cluster_color=False,
opencv=True,
savelabeled=False,
copy_videos=False,
destfolder=None,
modelprefix="",
track_method="",
**kwargs
)
Extracts the outlier frames.
Extracts the outlier frames if the predictions are not correct for a certain video from the cropped video running from start to stop as defined in config.yaml.
Another crucial parameter in config.yaml is how many frames to extract
numframes2extract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
Full path of the config.yaml file. |
required |
|
list[str | Path]
|
The full paths to videos for analysis or a path to the directory, where all the videos with same extension are stored. |
required |
|
str | Sequence[str] | None
|
Controls how |
None
|
|
int
|
The shuffle index of training dataset. The extracted frames will be stored in the labeled-dataset for the corresponding shuffle of training dataset. Defaults to 1. |
1
|
|
int
|
Integer specifying which TrainingsetFraction to use. Note that TrainingFraction is a list in config.yaml. Defaults to 0. |
0
|
|
str
|
String specifying the algorithm used to detect the outliers.
Defaults to "jump". |
'jump'
|
|
list[str]
|
If |
None
|
|
list[str] or str
|
This selects the body parts for
which the comparisons with the outliers are carried out. If |
'all'
|
|
float
|
For outlieralgorithm |
0.01
|
|
float
|
If |
20
|
|
int
|
For outlieralgorithm |
3
|
|
int
|
For outlieralgorithm |
1
|
|
float
|
Significance level for detecting outliers based on confidence interval of fitted ARIMA model. Only the distance is used however. Defaults to 0.01. |
0.01
|
|
str
|
String specifying the algorithm to use for
selecting the frames from the identified putatative outlier frames.
Currently, deeplabcut supports either |
'kmeans'
|
|
bool
|
If |
False
|
|
number
|
If |
30
|
|
bool
|
If |
False
|
|
bool
|
Uses openCV for loading & extractiong (otherwise moviepy (legacy)). Defaults to True. |
True
|
|
bool
|
If |
False
|
|
bool
|
If True, newly-added videos (from which outlier frames are extracted) are copied to the project folder. By default, symbolic links are created instead. Defaults to False. |
False
|
|
str or None
|
Specifies the destination folder that was
used for storing analysis data. If |
None
|
|
str
|
Directory containing the deeplabcut models to use when evaluating the network. By default, the models are assumed to exist in the project folder. Defaults to "". |
''
|
|
str
|
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. Defaults to "". |
''
|
|
Additional arguments. For torch-based shuffles, can be used to specify: - snapshot_index - detector_snapshot_index |
{}
|
Returns:
| Type | Description |
|---|---|
|
None |
Examples:
Extract the frames with default settings on Windows.
deeplabcut.extract_outlier_frames(
'C:\myproject\reaching-task\config.yaml',
['C:\yourusername\rig-95\Videos\reachingvideo1.avi'],
)
Extract the frames with default settings on Linux/MacOS.
deeplabcut.extract_outlier_frames(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/video/reachinvideo1.avi'],
)
Extract the frames using the "kmeans" algorithm.
deeplabcut.extract_outlier_frames(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/video/reachinvideo1.avi'],
extractionalgorithm='kmeans',
)
Extract the frames using the "kmeans" algorithm and "epsilon=5" pixels.
deeplabcut.extract_outlier_frames(
'/analysis/project/reaching-task/config.yaml',
['/analysis/project/video/reachinvideo1.avi'],
epsilon=5,
extractionalgorithm='kmeans',
)
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
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 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
find_outliers_in_raw_data
find_outliers_in_raw_data(
config: str | Path,
pickle_file: str | Path,
video_file: str | Path,
pcutoff=0.1,
percentiles=(5, 95),
with_annotations=True,
extraction_algo="kmeans",
copy_videos=False,
)
Extract outlier frames from either raw detections or assemblies of multiple animals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
Absolute path to the project config.yaml. |
required |
|
str | Path
|
Path to a _full.pickle or _assemblies.pickle. |
required |
|
str | Path
|
Path to the corresponding video file for frame extraction. |
required |
|
float
|
Detection confidence threshold below which frames are flagged as containing outliers. Only considered if raw detections are passed in. Defaults to 0.1. |
0.1
|
|
tuple
|
Assemblies are considered outliers if their areas are beyond the 5th and 95th percentiles. Must contain a lower and upper bound. Defaults to (5, 95). |
(5, 95)
|
|
bool
|
If true, extract frames and the corresponding network predictions. Otherwise, only the frames are extracted. Defaults to True. |
True
|
|
string
|
Outlier detection algorithm. Must be either
|
'kmeans'
|
|
bool
|
If True, newly-added videos (from which outlier frames are extracted) are copied to the project folder. By default, symbolic links are created instead. Defaults to False. |
False
|
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
find_outliers_in_raw_detections
Find outlier frames from the raw detections of multiple animals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
Data in the *_full.pickle file obtained after
|
required |
|
string
|
Outlier detection algorithm. Currently, only 'uncertain' is supported for multi-animal raw detections. Defaults to "uncertain". |
'uncertain'
|
|
float
|
Detection confidence threshold below which frames
are flagged as containing outliers. Only considered if |
0.1
|
|
list
|
Indices in the list of labeled body parts to be kept of the analysis. By default, all keypoints are used for outlier search. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Indices of video frames containing potential outliers, and the processed data dictionary. |
Source code in deeplabcut/refine_training_dataset/outlier_frames.py
merge_datasets
Merge the original training dataset with the newly refined data.
Checks if the original training dataset can be merged with the newly refined training dataset. To do so it will check if the frames in all extracted video sets were relabeled.
If this is the case then the "iteration" variable is advanced by 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
Full path of the config.yaml file. |
required |
|
int or None
|
If an integer is given the iteration variable is set to this value. This is only done if all datasets were labeled or refined. Defaults to None. |
None
|
Examples:
deeplabcut.merge_datasets("/analysis/project/reaching-task/config.yaml")