eddymotion.data.filtering module

Filtering data.

eddymotion.data.filtering.DEFAULT_DTYPE = 'int16'

The default image’s data type.

eddymotion.data.filtering.advanced_clip(data: ndarray, p_min: float = 35, p_max: float = 99.98, nonnegative: bool = True, dtype: str | dtype = 'int16', invert: bool = False) ndarray[source]

Clips outliers from a n-dimensional array and scales/casts to a specified data type.

This function removes outliers from both ends of the intensity distribution in a n-dimensional array using percentiles. It optionally enforces non-negative values and scales the data to fit within a specified data type (e.g., uint8 for image registration). To remove outliers more robustly, the function first applies a median filter to the data before calculating clipping thresholds.

Parameters:
  • data (ndarray) – The input n-dimensional data array.

  • p_min (float, optional) – The lower percentile threshold for clipping. Values below this percentile are set to the threshold value.

  • p_max (float, optional) – The upper percentile threshold for clipping. Values above this percentile are set to the threshold value.

  • nonnegative (bool, optional) – If True, only consider non-negative values when calculating thresholds.

  • dtype (str or dtype, optional) – The desired data type for the output array. Supported types are “uint8” and “int16”.

  • invert (bool, optional) – If True, inverts the intensity values after scaling (1.0 - data).

Returns:

The clipped and scaled data array with the specified data type.

Return type:

ndarray