Closed niksirbi closed 5 months ago
In xarray
, this could be as simple as doing:
da.rolling(time=5).median()
See rolling-window-operations.
If we want to be fancy, we can set the timepoints below a specified confidence threshold to NaN, before applying the median filter.
DeepLabCut has some support for smoothing/filtering pose tracks, in the form of the
filterpredictions()
function in thefiltering.py
module.They offer three options:
scipy.signal.medfilt()
.We should also offer several filtering options eventually, but the median filter is probably the easiest to start with.
Maybe a first step would be to create a
filtering.py
/smoothing.py
module and add a single median filter function. That function should:xarray.Dataset
as inputscipy.signal.medfilt()
orscipy.ndimage.median_filter()
)xarray.Dataset
as outputxarray
-aware (usexarray
's built-in functionalities as much as possible)Dask
(though this may be also left for a future version)