deeplabcut.utils.auxiliaryfunctions
DeepLabCut2.0 Toolbox (deeplabcut.org) © A. & M. Mathis Labs https://github.com/DeepLabCut/DeepLabCut Please see AUTHORS for contributors.
https://github.com/DeepLabCut/DeepLabCut/blob/master/AUTHORS Licensed under GNU Lesser General Public License v3.0
Functions:
| Name | Description |
|---|---|
attempt_to_make_folder |
Attempts to create a folder with specified name. |
check_if_post_processing |
Checks if filtered/bone lengths were already calculated. |
filter_files_by_patterns |
Filters files in a folder based on start, contain, and end patterns. |
find_analyzed_data |
Find potential data files from the hints given to the function. |
find_video_metadata |
For backward compatibility, let us search the substring 'meta'. |
get_bodyparts |
Get the bodyparts. |
get_data_and_metadata_filenames |
Paths to data and metadata files relative to the project root. |
get_deeplabcut_path |
Get path of where deeplabcut is currently running. |
get_evaluation_folder |
Get the evaluation folder. |
get_model_folder |
Get the model folder. |
get_scorer_name |
Extract the scorer/network name for a particular shuffle, training fraction, etc. |
get_snapshots_from_folder |
Returns an ordered list of existing snapshot names in the train folder, sorted by |
get_training_set_folder |
Training Set folder for config file based on parameters. |
get_unique_bodyparts |
Get the unique bodyparts. |
get_video_list |
Get list of videos in a path (if filetype == all), otherwise just a specific |
grab_files_in_folder |
Return the paths of files with extension ext present in folder. |
intersection_of_body_parts_and_ones_given_by_user |
Returns all body parts when comparisonbodyparts=='all', otherwise all bpts that |
read_pickle |
Read the pickle file. |
read_plainconfig |
Load a YAML config (alias for read_config_as_dict). See deeplabcut.core.config. |
safe_resolve |
Return a resolved Path that is safe to use with str-based I/O. |
save_data |
Save predicted data as h5 file and metadata as pickle file; created by |
write_pickle |
Write the pickle file. |
write_plainconfig |
Write a config dict to YAML (alias for write_config). See deeplabcut.core.config. |
attempt_to_make_folder
Attempts to create a folder with specified name.
Does nothing if it already exists.
Source code in deeplabcut/utils/auxiliaryfunctions.py
check_if_post_processing
Checks if filtered/bone lengths were already calculated.
If not, figures out if data was already analyzed (either with legacy scorer name or new one!)
Source code in deeplabcut/utils/auxiliaryfunctions.py
filter_files_by_patterns
filter_files_by_patterns(
folder: str | Path,
start_patterns: set[str] | None = None,
contain_patterns: set[str] | None = None,
end_patterns: set[str] | None = None,
) -> list[Path]
Filters files in a folder based on start, contain, and end patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
The folder to search for files. |
required |
|
Set[str] | None
|
Patterns the filenames should start with. If None or empty, this pattern is not taken into account. |
None
|
|
set[str]
|
Patterns the filenames should contain. If None or empty, this pattern is not taken into account. |
None
|
|
set[str]
|
Patterns the filenames should end with. If None or empty, this pattern is not taken into account. |
None
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
List[Path]: List of files that match the criteria. |
Source code in deeplabcut/utils/auxiliaryfunctions.py
find_analyzed_data
Find potential data files from the hints given to the function.
Source code in deeplabcut/utils/auxiliaryfunctions.py
find_video_metadata
For backward compatibility, let us search the substring 'meta'.
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_bodyparts
Get the bodyparts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
a project configuration file |
required |
Returns: bodyparts listed in the project (does not include the unique_bodyparts entry)
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_data_and_metadata_filenames
get_data_and_metadata_filenames(
trainingsetfolder: str | Path, trainFraction: float, shuffle: int, cfg: dict
) -> tuple[Path, Path]
Paths to data and metadata files relative to the project root.
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_deeplabcut_path
Get path of where deeplabcut is currently running.
get_evaluation_folder
get_evaluation_folder(
trainFraction: float, shuffle: int, cfg: dict, engine: Engine | None = None, modelprefix: str = ""
) -> Path
Get the evaluation folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
the training fraction (as defined in the project configuration) for which to get the evaluation folder |
required |
|
int
|
the index of the shuffle for which to get the evaluation folder |
required |
|
dict
|
the project configuration |
required |
|
Engine | None
|
The engine for which we want the model folder. Defaults to None, which automatically gets the engine for the shuffle from the training dataset metadata file. |
None
|
|
str
|
The name of the folder |
''
|
Returns:
| Type | Description |
|---|---|
Path
|
the relative path from the project root to the folder containing the model files for a shuffle (configuration files, snapshots, training logs, ...) |
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_model_folder
get_model_folder(
trainFraction: float, shuffle: int, cfg: dict, modelprefix: str = "", engine: Engine = Engine.TF
) -> Path
Get the model folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
the training fraction (as defined in the project configuration) for which to get the model folder |
required |
|
int
|
the index of the shuffle for which to get the model folder |
required |
|
dict
|
the project configuration |
required |
|
str
|
The name of the folder |
''
|
|
Engine
|
The engine for which we want the model folder. Defaults to |
TF
|
Returns:
| Type | Description |
|---|---|
Path
|
the relative path from the project root to the folder containing the model files for a shuffle (configuration files, snapshots, training logs, ...) |
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_scorer_name
get_scorer_name(
cfg: dict,
shuffle: int,
trainFraction: float,
trainingsiterations: str | int = "unknown",
modelprefix: str = "",
engine: Engine | None = None,
**kwargs
)
Extract the scorer/network name for a particular shuffle, training fraction, etc.
If the engine is not specified, determines which to use from the project configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Additional arguments. For torch-based shuffles, can be used to specify: - snapshot_index - detector_snapshot_index |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
DLCscorer and DLCscorerlegacy (old naming convention). |
Source code in deeplabcut/utils/auxiliaryfunctions.py
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 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
get_snapshots_from_folder
Returns an ordered list of existing snapshot names in the train folder, sorted by increasing training iterations.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no snapshot_names are found in the train_folder. |
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_training_set_folder
Training Set folder for config file based on parameters.
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_unique_bodyparts
Get the unique bodyparts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
a project configuration file |
required |
Returns: all unique bodyparts listed in the project
Source code in deeplabcut/utils/auxiliaryfunctions.py
get_video_list
Get list of videos in a path (if filetype == all), otherwise just a specific file.
Source code in deeplabcut/utils/auxiliaryfunctions.py
grab_files_in_folder
Return the paths of files with extension ext present in folder.
Source code in deeplabcut/utils/auxiliaryfunctions.py
intersection_of_body_parts_and_ones_given_by_user
Returns all body parts when comparisonbodyparts=='all', otherwise all bpts that are in the intersection of comparisonbodyparts and the actual bodyparts.
Source code in deeplabcut/utils/auxiliaryfunctions.py
read_pickle
read_plainconfig
Load a YAML config (alias for read_config_as_dict). See deeplabcut.core.config.
safe_resolve
Return a resolved Path that is safe to use with str-based I/O.
Prefers Path.resolve() so that symlinks are followed (useful on Linux). Falls back to Path.absolute() when resolve() fails or the resolved path cannot be stat'd via its plain string form — e.g. on Windows 11 + SMB network drives where resolve() may return an unusable \?\Volume{GUID}... form.
See https://github.com/DeepLabCut/DeepLabCut/issues/3348
Source code in deeplabcut/utils/auxiliaryfunctions.py
save_data
Save predicted data as h5 file and metadata as pickle file; created by predict_videos.py.
Source code in deeplabcut/utils/auxiliaryfunctions.py
write_pickle
write_plainconfig
Write a config dict to YAML (alias for write_config). See deeplabcut.core.config.