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. |
create_config_template |
Creates a template for config.yaml file. |
create_config_template_3d |
Creates a template for config.yaml file for 3d project. |
edit_config |
Convenience function to edit and save a config file from a dictionary. |
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 |
Args: |
get_deeplabcut_path |
Get path of where deeplabcut is currently running. |
get_evaluation_folder |
Args: |
get_immediate_subdirectories |
Get list of immediate subdirectories. |
get_model_folder |
Args: |
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 |
Args: |
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_config |
Reads structured config file defining a project. |
read_pickle |
Read the pickle file. |
save_data |
Save predicted data as h5 file and metadata as pickle file; created by |
write_config |
Write structured config file. |
write_config_3d |
Write structured 3D config file. |
write_pickle |
Write the pickle file. |
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
create_config_template
Creates a template for config.yaml file.
This specific order is preserved while saving as yaml file.
Source code in deeplabcut/utils/auxiliaryfunctions.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
create_config_template_3d
Creates a template for config.yaml file for 3d project.
This specific order is preserved while saving as yaml file.
Source code in deeplabcut/utils/auxiliaryfunctions.py
edit_config
Convenience function to edit and save a config file from a dictionary.
Parameters
configname : string String containing the full path of the config file in the project. edits : dict Key–value pairs to edit in config output_name : string, optional (default='') Overwrite the original config.yaml by default. If passed in though, new filename of the edited config.
Examples
config_path = 'my_stellar_lab/dlc/config.yaml'
edits = {'numframes2pick': 5, 'trainingFraction': [0.5, 0.8], 'skeleton': [['a', 'b'], ['b', 'c']]}
deeplabcut.auxiliaryfunctions.edit_config(config_path, edits)
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
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_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
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_immediate_subdirectories
get_model_folder
get_model_folder(
trainFraction: float, shuffle: int, cfg: dict, modelprefix: str = "", engine: Engine = Engine.TF
) -> Path
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 kwargs: additional arguments. For torch-based shuffles, can be used to specify: - snapshot_index - detector_snapshot_index
Returns tuple of DLCscorer, DLCscorerlegacy (old naming convention)
Source code in deeplabcut/utils/auxiliaryfunctions.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
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
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_config
Reads structured config file defining a project.
Source code in deeplabcut/utils/auxiliaryfunctions.py
read_pickle
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_config
Write structured config file.
Source code in deeplabcut/utils/auxiliaryfunctions.py
write_config_3d
Write structured 3D config file.