Processes
behavysis_pipeline.processes.CalculateParams
¶
summary
Source code in behavysis_pipeline/processes/calculate_params.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 167 168 169 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 |
|
exp_dur(dlc_fp, configs_fp)
staticmethod
¶
Calculates the duration in seconds, from the time the specified bodyparts appeared to the time they disappeared. Appear/disappear is calculated from likelihood.
Source code in behavysis_pipeline/processes/calculate_params.py
px_per_mm(dlc_fp, configs_fp)
staticmethod
¶
Calculates the pixels per mm conversion for the video.
This is done by averaging the (x, y) coordinates of each corner, finding the average x difference for the widths in pixels and y distance for the heights in pixels, dividing these pixel distances by their respective mm distances (from the *config.json file), and taking the average of these width and height conversions to estimate the px to mm conversion.
Notes
The config file must contain the following parameters:
Source code in behavysis_pipeline/processes/calculate_params.py
start_frame(dlc_fp, configs_fp)
staticmethod
¶
Determine the starting frame of the experiment based on when the subject "likely" entered the footage.
This is done by looking at a sliding window of time. If the median likelihood of the subject existing in each frame across the sliding window is greater than the defined pcutoff, then the determine this as the start time.
Notes
The config file must contain the following parameters:
Source code in behavysis_pipeline/processes/calculate_params.py
stop_frame(dlc_fp, configs_fp)
staticmethod
¶
Calculates the end time according to the following equation:
Source code in behavysis_pipeline/processes/calculate_params.py
behavysis_pipeline.processes.ClassifyBehaviours
¶
summary
Source code in behavysis_pipeline/processes/classify_behaviours.py
classify_behaviours(features_fp, out_fp, configs_fp, overwrite)
staticmethod
¶
Given model config files in the BehavClassifier format, generates beahviour predidctions on the given extracted features dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features_fp |
str
|
description |
required |
out_fp |
str
|
description |
required |
configs_fp |
str
|
description |
required |
overwrite |
bool
|
Whether to overwrite the output file (if it exists). |
required |
Returns:
Type | Description |
---|---|
str
|
Description of the function's outcome. |
Notes
The config file must contain the following parameters:
Where themodels
list is a list of model_config.json
filepaths.
Source code in behavysis_pipeline/processes/classify_behaviours.py
behavysis_pipeline.processes.Evaluate
¶
summary
Source code in behavysis_pipeline/processes/evaluate.py
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 167 168 169 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 |
|
behav_plot(vid_fp, dlc_fp, behavs_fp, out_dir, configs_fp, overwrite)
staticmethod
¶
Make behaviour evaluation plot of the predicted and actual behaviours through time.
Source code in behavysis_pipeline/processes/evaluate.py
eval_vid(vid_fp, dlc_fp, behavs_fp, out_dir, configs_fp, overwrite)
staticmethod
¶
Run the DLC model on the formatted video to generate a DLC annotated video and DLC file for
all experiments. The DLC model's config.yaml filepath must be specified in the config_path
parameter in the user
section of the config file.
Source code in behavysis_pipeline/processes/evaluate.py
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 |
|
keypoints_plot(vid_fp, dlc_fp, behavs_fp, out_dir, configs_fp, overwrite)
staticmethod
¶
Make keypoints evaluation plot of likelihood of each bodypart through time.
Source code in behavysis_pipeline/processes/evaluate.py
behavysis_pipeline.processes.ExtractFeatures
¶
summary
Source code in behavysis_pipeline/processes/extract_features.py
extract_features(dlc_fp, out_fp, configs_fp, temp_dir, overwrite)
staticmethod
¶
Extracting features from preprocessed DLC dataframe using SimBA processes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dlc_fp |
str
|
Preprocessed DLC filepath. |
required |
out_fp |
str
|
Filepath to save extracted_features dataframe. |
required |
configs_fp |
str
|
Configs JSON filepath. |
required |
temp_dir |
str
|
Temporary directory path. Used during intermediate SimBA processes. |
required |
overwrite |
bool
|
Whether to overwrite the out_fp file (if it exists). |
required |
Returns:
Type | Description |
---|---|
str
|
The outcome of the process. |
Source code in behavysis_pipeline/processes/extract_features.py
behavysis_pipeline.processes.FormatVid
¶
Class for formatting videos based on given parameters.
Source code in behavysis_pipeline/processes/format_vid.py
format_vid(in_fp, out_fp, configs_fp, overwrite)
staticmethod
¶
Formats the input video with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_fp |
str
|
The input video filepath. |
required |
out_fp |
str
|
The output video filepath. |
required |
configs_fp |
str
|
The JSON configs filepath. |
required |
overwrite |
bool
|
Whether to overwrite the output file (if it exists). |
required |
Returns:
Type | Description |
---|---|
str
|
Description of the function's outcome. |
Source code in behavysis_pipeline/processes/format_vid.py
get_vid_metadata(in_fp, out_fp, configs_fp, overwrite)
staticmethod
¶
Finds the video metadata/parameters for either the raw or formatted video, and stores this data in the experiment's config file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_fp |
str
|
The input video filepath. |
required |
out_fp |
str
|
The output video filepath. |
required |
configs_fp |
str
|
The JSON configs filepath. |
required |
overwrite |
bool
|
Whether to overwrite the output file (if it exists). IGNORED |
required |
Returns:
Type | Description |
---|---|
str
|
Description of the function's outcome. |
Source code in behavysis_pipeline/processes/format_vid.py
behavysis_pipeline.processes.Preprocess
¶
summary
Source code in behavysis_pipeline/processes/preprocess.py
34 35 36 37 38 39 40 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 167 168 169 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 |
|
interpolate(in_fp, out_fp, configs_fp, overwrite)
staticmethod
¶
"Smooths" out noticeable jitter of points, where the likelihood (and accuracy) of a point's coordinates are low (e.g., when the subject's head goes out of view). It does this by linearly interpolating the frames of a body part that are below a given likelihood pcutoff.
Notes
The config file must contain the following parameters:
Source code in behavysis_pipeline/processes/preprocess.py
refine_ids(in_fp, out_fp, configs_fp, overwrite)
staticmethod
¶
Ensures that the identity is correctly tracked for maDLC. Assumes interpolatePoints and calcBodyCentre has already been run.
Notes
The config file must contain the following parameters:
Source code in behavysis_pipeline/processes/preprocess.py
start_stop_trim(in_fp, out_fp, configs_fp, overwrite)
staticmethod
¶
Filters the rows of a DLC formatted dataframe to include only rows within the start and end time of the experiment, given a corresponding configs dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
in_fp |
str
|
The file path of the input DLC formatted dataframe. |
required |
out_fp |
str
|
The file path of the output trimmed dataframe. |
required |
configs_fp |
str
|
The file path of the configs dict. |
required |
overwrite |
bool
|
If True, overwrite the output file if it already exists. If False, skip processing if the output file already exists. |
required |
Returns:
Type | Description |
---|---|
str
|
An outcome message indicating the result of the trimming process. |
Notes
The config file must contain the following parameters:
Source code in behavysis_pipeline/processes/preprocess.py
behavysis_pipeline.processes.RunDLC
¶
summary
Source code in behavysis_pipeline/processes/run_dlc.py
37 38 39 40 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 |
|
ma_dlc_analyse_batch(in_fp_ls, out_dir, configs_dir, temp_dir, gputouse, overwrite)
staticmethod
¶
Running custom DLC script to generate a DLC keypoints dataframe from a single video.
Source code in behavysis_pipeline/processes/run_dlc.py
ma_dlc_analyse_single(in_fp, out_fp, configs_fp, temp_dir, gputouse, overwrite)
staticmethod
¶
Running custom DLC script to generate a DLC keypoints dataframe from a single video.
Source code in behavysis_pipeline/processes/run_dlc.py
behavysis_pipeline.processes.UpdateConfigs
¶
summary
Source code in behavysis_pipeline/processes/update_configs.py
update_configs(configs_fp, default_configs_fp, overwrite)
staticmethod
¶
Initialises the config files with the given default_configs
.
The different types of overwriting are:
- "user": Only the user parameters are updated.
- "all": All parameters are updated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
configs_fp |
str
|
The filepath of the existing config file. |
required |
default_configs_fp |
str
|
The filepath of the default config file to use. |
required |
overwrite |
Literal['user', 'all']
|
Specifies how to update the config files. |
required |
Returns:
Type | Description |
---|---|
str
|
Description of the function's outcome. |