spatial Gaussian filter

spatialGaussFilt - Spatial gaussian filter


Applies a spatial gaussian filter to image time series.

Description


This function applies a smoothing to the image using a Gaussian filter in order to blur the images and reduce high-frequency noise. This function uses Matlab's imgaussfilt function to perform the smoothing of the frames from the image time series data.

Input


This function accepts image time series with dimensions Y, X and T, or image time series split by events with dimensions Y, X, T and E, either as a numeric array or as a .dat file. UMT structs and .umt files are not supported.

A .dat input is read, filtered and written in blocks of whole frames (Low-RAM mode), so the recording is never loaded whole. Progress is printed to the command window.

The algorithm


This function uses a 2D Gaussian smoothing kernel with a user-defined standard deviation (i.e. sigma). In brief, the larger the value of the standard deviation of the filter, more blurred the image will be. Here is an example of five standard deviations values applied to an image measuring 256 by 256 pixels :

spatialGaussFilt_sigma_example
Example of five different standard deviation (sigma) on a image from the cortical activity of a mouse

As stated above, this function applies Matlab's function imgaussfilt to all frames of an image time series. The filter convolutes a square Gaussian kernel to the image. The filter is forced to be applied in the spatial domain to avoid unwanted results if the data contains infinite values or NaNs. The Kernel size is dependent on the sigma value (function's default) and is defined as:

kernel_size = 2*ceil(2*sigma)+1;

Output


The output has the same axes and sizes as the input and the same representation: a numeric array for an array input (single or double as the input; integer and logical arrays are converted to single), or the spatialGaussFilt.dat file (saved in the save folder) for a .dat input.

Note
Every Y by X frame is filtered on its own; frames are never mixed along T or E. NaN values are replaced by zero before filtering and restored afterwards. NaN masks are tracked per frame, so a pixel that is NaN in one frame does not discard valid data in other frames.

Parameters


The parameter of this function is the following:

Standard deviation of the Gaussian filter.


Back to top

Copyright © LabeoTech 2023. This work is licensed under the GNU General Public License, Version 3.0.