identify

kgpy.img.spikes.identify(data, axis=None, kernel_size=11, pencil_size=3, percentile_threshold=99, num_hist_bins=128, filter_type='median')

Identify spikes in an image using a local median-dependent threshold. To start, this function calculates a histogram of local median vs value for every specified axis. From this histogram we can compute a cumulative distribution along the vertical (constant local median) axis. From the cumulative distribution, we can compute the location of the upper/lower threshold for a particular local median. The local median-dependent upper and lower thresholds are fit to a polynomial for interpolation/extrapolation. :type data: numpy.ndarray :param data: The input array :type axis: typing.Union[int, typing.Tuple[int, ...], None] :param axis: The axis or axes which are considered for computing the local median. If None, the median is computed along all the axes in data :type kernel_size: typing.Union[int, typing.Tuple[int, ...]] :param kernel_size: Int or list of ints the same length as axis specifying the size of the local median kernel. :type percentile_threshold: typing.Union[float, typing.Tuple[float, float]] :param percentile_threshold: Threshold at which to declare a spike for a particular value of the local median. This function can detect both positive and negative spikes, so we specify both an upper and lower threshold. If specified as a scalar, percentile_threshold is the upper threshold and the lower threshold is ` 100 - percentile_threshold`. If specified as a 2-element tuple, the first element is the lower threshold and the second element is the upper threshold. :param poly_deg: :type num_hist_bins: int :param num_hist_bins: :param plot_histograms: :rtype: typing.Tuple[numpy.ndarray, typing.List[kgpy.img.spikes.Stats]] :return:

Parameters:
Return type:

Tuple[ndarray, List[Stats]]