spectral_unmixing.apply_filters

spectral_unmixing.apply_filters(stack, filters, *, filters_channel2=None, median_size=3, gaussian_sigma=1.0, median_size_channel2=None, gaussian_sigma_channel2=None, apply_3d=False)[source]

Apply one or more filters to a microscopy stack.

Parameters:
  • stack (array-like) – Input stack in canonical TZCYX order, or a simpler ZYX / YX array.

  • filters (str or sequence of str) – Either a single filter name or a sequence such as ["median", "gaussian"]. Filters are applied in the order provided.

  • filters_channel2 (str or sequence of str or None, optional) – Optional filter sequence applied only to the second channel (index 1). If None, the same filters sequence is used for all channels.

  • median_size (int or sequence of int, optional) – Median kernel size. If a sequence with length T is provided, the value is applied per time point. If the sequence length does not match T, only the first entry is used for all time points.

  • gaussian_sigma (float or sequence of float, optional) – Gaussian sigma. If a sequence with length T is provided, the value is applied per time point. If the sequence length does not match T, only the first entry is used for all time points.

  • median_size_channel2 (int or sequence of int or None, optional) – Optional median kernel size override for the second channel (index 1). If None, the values from median_size are reused.

  • gaussian_sigma_channel2 (float or sequence of float or None, optional) – Optional Gaussian sigma override for the second channel (index 1). If None, the values from gaussian_sigma are reused.

  • apply_3d (bool, optional) – If True, apply filters in 3D over ZYX for each T and C volume. If False, apply them plane-wise in YX for each available T and Z.

Return type:

ndarray

Returns:

np.ndarray – Filtered stack with the same shape as the input.

Notes

Channel-specific overrides currently target the second channel, i.e. channel index 1. This matches the common two-channel use case in the unmixing workflow where the second channel may need different smoothing strength.