Skip to content

Running Quantile

Source

Running quantile estimation for normalization stats.

QuantileEstimator

Streaming quantile estimator using adaptive histogram binning.

Parameters:

  • lower_quantiles (list[float]) –

    Lower quantile values to compute, one per channel.

  • upper_quantiles (list[float]) –

    Upper quantile values to compute, one per channel.

  • n_bins (int, default: 65536 ) –

    Number of histogram bins. Default is 65536 (suitable for 16-bit data).

  • margin (float, default: 0.1 ) –

    Fractional margin to add to histogram range. Default is 0.1 (10%).

__init__(lower_quantiles, upper_quantiles, n_bins=65536, margin=0.1)

Initialize histograms and bounds for streaming quantile estimation.

Parameters:

  • lower_quantiles (list of float) –

    Lower quantile per channel.

  • upper_quantiles (list of float) –

    Upper quantile per channel.

  • n_bins (int, default: 65536 ) –

    Number of histogram bins.

  • margin (float, default: 0.1 ) –

    Fractional margin for histogram range.

finalize()

Return (lower_quantiles, upper_quantiles) arrays per channel.

Returns:

  • tuple of numpy.ndarray

    (lower_quantiles, upper_quantiles) per channel.

update(patch)

Update histograms and bounds with a single patch.

Parameters:

  • patch (ndarray) –

    Patch with shape C(Z)YX.