minian.preprocessing module¶
-
minian.preprocessing.denoise(varr, method, **kwargs)[source]¶ Denoise the movie frame by frame.
This function wraps around several image processing functions to denoise the data frame by frame. All additional keyword arguments will be passed directly to the underlying functions.
- Parameters
varr (xr.DataArray) – The input movie data, should have dimensions “height”, “width” and “frame”.
method (str) – The method to use to denoise each frame. If “gaussian”, then a gaussian filter will be applied using
cv2.GaussianBlur(). If “anisotropic”, then anisotropic filtering will be applied usingmedpy.filter.smoothing.anisotropic_diffusion(). If “median”, then a median filter will be applied usingcv2.medianBlur(). If “bilateral”, then a bilateral filter will be applied usingcv2.bilateralFilter().
- Returns
res (xr.DataArray) – The resulting denoised movie. Same shape as input varr but will have “_denoised” appended to its name.
- Raises
NotImplementedError – if the supplied method is not recognized
-
minian.preprocessing.remove_background(varr, method, wnd)[source]¶ Remove background from a video.
This function remove background frame by frame. Two methods are available for use: if method == “uniform”, then the background is estimated by convolving the frame with a uniform/mean kernel and then subtract it from the frame. If method == “tophat”, then a morphological tophat operation is applied to each frame.
- Parameters
varr (xr.DataArray) – The input movie data, should have dimensions “height”, “width” and “frame”.
method (str) – The method used to remove the background. Should be either “uniform” or “tophat”.
wnd (int) – Window size of kernels used for background removal, specified in pixels. If method == “uniform”, this will be the size of a box kernel convolved with each frame. If method == “tophat”, this will be the radius of a disk kernel used for morphological operations.
- Returns
res (xr.DataArray) – The resulting movie with background removed. Same shape as input varr but will have “_subtracted” appended to its name.
See also
- Morphology :
for details about morphological operations
-
minian.preprocessing.remove_background_perframe(fm, method, wnd, selem)[source]¶ Remove background from a single frame.
- Parameters
fm (np.ndarray) – The input frame.
method (str) – Method to use to remove background. Should be either “uniform” or “tophat”.
wnd (int) – Size of the uniform filter. Only used if method == “uniform”.
selem (np.ndarray) – Kernel used for morphological operations. Only used if method == “tophat”.
- Returns
fm (np.ndarray) – The frame with background removed.
See also
remove_backgroundfor detailed explanations