Noise Filtration

This module carries out noise filtration over multiple tiff blocks.

One way to reduce the effect of photobleaching on SOFI analysis is to divide a long video into multiple blocks with fewer frames. In each block, the decrease in fluorescence intensity is small enough so that users canomit the effect of photobleaching. Each block can be considered as an individual PysofiData object. After the reconstruction step, all reconstructed images are saved in separate object, and can be put together for the filtration.

functions

pysofi.filtering.filter1d_same(time_series, noise_filter)

Filter original time_series with noise_filter, and return the filtered_series with the same length as the original sereis. Compared to MATLAB results, when the length of the filter and frame number are both even, the filtered result would shift to left by one number. In other cases, results are the same.

pysofi.filtering.med_smooth(ori_signal, kernel_size=251)

Perform a one-dimensional median filter with ‘reflect’ padding. For more information, please check scipy.signal.medfilt.

pysofi.filtering.noise_filter1d(dset, im_set, noise_filter=[], filtername='noise filter after M6', filenames=None, return_option=False, return_type='dict')

Perform noise filtering on a image stack along the time axis for each pixel independently.

Parameters
  • dset (dict) – filename (str) -> Data (object). A dictionary mapping tiff stack filenames to Data object.

  • im_set (dict) – filename (str) -> pre-filtering image (ndarray). A dictionary mapping tiff filenames to images need to be filtered.

  • noise_filter (ndarray) – Noise filtering kernel, e.g. 1D-Gaussian.

  • filtername (str) – Name of the filter for Data.add_filtered.

  • filenames (list (str)) – Sequence of filenames for the filtering.

  • return_option (bool) – Whether to return the results after noise filtering or not.

  • return_type (str) – Choose the format of the returned value. Can use either ‘ndarray’ or ‘dict’

Returns

  • m_filtered (ndarray) – Filtered image stack in the format of a numpy.ndarray.

  • m_filtered (dict) – Filtered image stack in the format of a dictionary.

Example

A one-dimensional Gaussian mask (kernel) is first generated, and passed to the filtration along with an array of images in sequence that needs to be filtered (m_set):

nf = masks.gauss1D_mask(shape=(1,21), sigma=2)
m_filtered = filtering.noise_filter1d(dset, m_set, nf, filenames=filenames, return_option=True)