deeplabcut.post_processing.filtering
Functions:
| Name | Description |
|---|---|
columnwise_spline_interp |
Perform cubic spline interpolation over the columns of data. All gaps of size |
filterpredictions |
Fits frame-by-frame pose predictions. |
columnwise_spline_interp
Perform cubic spline interpolation over the columns of data. All gaps of size lower than or equal to max_gap are filled, and data slightly smoothed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
array_like
|
2D matrix of data. |
required |
|
int
|
Maximum gap size to fill. By default, all gaps are interpolated. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
Interpolated data with the same shape as data. |
Source code in deeplabcut/post_processing/filtering.py
filterpredictions
filterpredictions(
config: str | Path,
video: str | Path,
video_extensions: str | Sequence[str] | None = None,
shuffle=1,
trainingsetindex=0,
filtertype="median",
windowlength=5,
p_bound=0.001,
ARdegree=3,
MAdegree=1,
alpha=0.01,
save_as_csv=True,
destfolder=None,
modelprefix="",
track_method="",
return_data=False,
**kwargs
)
Fits frame-by-frame pose predictions.
The pose predictions are fitted with ARIMA model (filtertype='arima') or median filter (default).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | Path
|
Full path of the config.yaml file. |
required |
|
str | Path
|
Full path of the video to filter. Make sure that this video is already analyzed. |
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
|
|
string
|
The filter type - 'arima', 'median' or 'spline'. Defaults to "median". |
'median'
|
|
int
|
For filtertype='median' filters the input array using a local window-size given by windowlength. The array will automatically be zero-padded. https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.medfilt.html. The windowlenght should be an odd number. If filtertype='spline', windowlength is the maximal gap size to fill. Defaults to 5. |
5
|
|
float
|
For filtertype 'arima' this parameter defines the likelihood below, below which a body part will be consided as missing data for filtering purposes. Defaults to 0.001. |
0.001
|
|
int
|
For filtertype 'arima' Autoregressive degree of Sarimax model degree. see https://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAX.html. Defaults to 3. |
3
|
|
int
|
For filtertype 'arima' Moving Average degree of Sarimax model degree. See https://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAX.html. Defaults to 1. |
1
|
|
float
|
Significance level for detecting outliers based on the confidence interval of the fitted SARIMAX model. Defaults to 0.01. |
0.01
|
|
bool
|
Saves the predictions in a .csv file. Defaults to True. |
True
|
|
string
|
Specifies the destination folder for 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 "". |
''
|
|
string
|
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 "". |
''
|
|
bool
|
If True, returns a dictionary of the filtered data keyed by video names. Defaults to False. |
False
|
|
dict
|
Additional arguments. For torch-based shuffles, can be used to specify: - snapshot_index - detector_snapshot_index |
{}
|
Returns:
| Type | Description |
|---|---|
|
dict | None: If |
Examples:
Arima model:
deeplabcut.filterpredictions(
'C:\myproject\reaching-task\config.yaml',
['C:\myproject\trailtracking-task\test.mp4'],
shuffle=3,
filtertype='arima',
ARdegree=5,
MAdegree=2,
)
Use median filter over 10 bins:
deeplabcut.filterpredictions(
'C:\myproject\reaching-task\config.yaml',
['C:\myproject\trailtracking-task\test.mp4'],
shuffle=3,
windowlength=10,
)
One can then use the filtered rather than the frame-by-frame predictions by calling:
deeplabcut.plot_trajectories(
'C:\myproject\reaching-task\config.yaml',
['C:\myproject\trailtracking-task\test.mp4'],
shuffle=3,
filtered=True,
)
deeplabcut.create_labeled_video(
'C:\myproject\reaching-task\config.yaml',
['C:\myproject\trailtracking-task\test.mp4'],
shuffle=3,
filtered=True,
)
Source code in deeplabcut/post_processing/filtering.py
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 | |