mri.operators.proximity.weighted#

class WeightedSparseThreshold(weights, coeffs_shape, weight_type='scale_based', zero_weight_coarse=True, linear=<modopt.opt.linear.base.Identity object>, **kwargs)[source]#

Bases: modopt.opt.proximity.SparseThreshold

This is a weighted version of SparseThreshold in ModOpt. When chosen scale_based, it allows the users to specify an array of weights W[i] and each weight is assigen to respective scale i. Also, custom weights can be defined. Note that the weights on coarse scale is always set to 0

Parameters
  • weights (numpy.ndarray) – Input array of weights or a tuple holding base weight W and power P

  • coeffs_shape (tuple) – The shape of linear coefficients

  • weight_type (string 'custom' | 'scale_based' | 'custom_scale',) – default ‘scale_based’ Mode of operation of proximity: custom -> custom array of weights scale_based -> custom weights applied per scale

  • zero_weight_coarse (bool, default True) –

  • linear (object, default Identity()) – Linear operator, to be used in cost function evaluation

See also

SparseThreshold

parent class

property mu#

mu is the weights used for thresholding

_sigma_mad(data, centered=True)[source]#

Return a robust estimation of the standard deviation.

The standard deviation is computed using the following estimator, based on the Median Absolute deviation of the data 1 .. math:

\hat{\sigma} =

rac{MAD}{sqrt{2} extrm{erf}^{-1}(1/2)}

Parameters
data: numpy.ndarray

the data on which the standard deviation will be estimated.

centered: bool, default True.

If true the median of the is assummed to be 0.

float:

The estimation of the standard deviation.

_sure_est(data)[source]#

Return an estimation of the threshold computed using the SURE method.

The computation of the estimator is based on the formulation of cite:donoho1994 and the efficient implementation of [#]_

Parameters

data (numpy.array) – Noisy Data with unit standard deviation.

Returns

Value of the threshold minimizing the SURE estimator.

Return type

float

References

1

https://pyyawt.readthedocs.io/_modules/pyyawt/denoising.html#ValSUREThresh

_thresh_select(data, thresh_est)[source]#

Threshold selection for denoising, implementing the methods proposed in cite:donoho1994

Parameters
  • data (numpy.ndarray) – Noisy data on which a threshold will be estimated. It should only be corrupted by a standard gaussian white noise N(0,1).

  • thresh_est (str) – threshold estimation method. Available are “sure”, “universal”, “hybrid-sure”.

Returns

the threshold for the data provided.

Return type

float

wavelet_noise_estimate(wavelet_coeffs, coeffs_shape, sigma_est)[source]#

Return an estimate of the noise standard deviation in each subband.

Parameters
  • wavelet_coeffs (numpy.ndarray) – flatten array of wavelet coefficients, typically returned by WaveletN.op

  • coeffs_shape – list of tuple representing the shape of each subband. Typically accessible by WaveletN.coeffs_shape

  • sigma_est (str) – Estimation method, available are “band”, “scale”, and “global”

Returns

Estimation of the variance for each wavelet subband.

Return type

numpy.ndarray

Notes

This methods makes several assumptions:

  • The wavelet coefficients are ordered by scale, and the scales are ordered by size.

  • At each scale, the subbands should have the same shape.

The variance estimation is either performed:

  • On each subband (sigma_est = "band")

  • On each scale, using the detailled HH subband. (sigma_est = "scale")

  • Only with the largest, most detailled HH band (sigma_est = "global")

See also

_sigma_mad

function estimating the standard deviation.

wavelet_threshold_estimate(wavelet_coeffs, coeffs_shape, thresh_range='global', sigma_range='global', thresh_estimation='hybrid-sure')[source]#

Estimate wavelet coefficient thresholds.

Notes that no threshold will be estimate for the coarse scale. :param wavelet_coeffs: flatten array of wavelet coefficient, typically returned by WaveletN.op :type wavelet_coeffs: numpy.ndarray :param coeffs_shape: List of tuple representing the shape of each subbands.

Typically accessible by WaveletN.coeffs_shape

Parameters
  • thresh_range (str. default "global") – Defines on which data range to estimate thresholds. Either “band”, “scale”, or “global”

  • sigma_range (str, default "global") – Defines on which data range to estimate thresholds. Either “band”, “scale”, or “global”

  • thresh_estimation (str, default "hybrid-sure") – Name of the threshold estimation method. Available are “sure”, “hybrid-sure”, “universal”

Returns

array of threshold for each wavelet coefficient.

Return type

numpy.ndarray

class AutoWeightedSparseThreshold(coeffs_shape, linear=<modopt.opt.linear.base.Identity object>, update_period=0, sigma_range='global', thresh_range='global', threshold_estimation='sure', threshold_scaler=1.0, **kwargs)[source]#

Bases: modopt.opt.proximity.SparseThreshold

Automatic Weighting of sparse coefficients.

This proximty automatically determines the threshold for Sparse (e.g. Wavelet based) coefficients.

The weight are computed on first call, and updated on every update_period call. Note that the coarse/approximation scale will not be thresholded.

Parameters
  • coeffs_shape (list of tuple) – list of shape for the subbands.

  • linear (LinearOperator) – Required for cost estimation.

  • update_period (int) – Estimation of the weight update period.

  • threshold_estimation (str) – threshold estimation method. Available are “sure”, “hybrid-sure” and “universal”

  • thresh_range (str) – threshold range of estimation. Available are “global”, “scale” and “band”

  • sigma_range (str) – noise std range of estimation. Available are “global”, “scale” and “band”

  • thresh_type (str) – “hard” or “soft” thresholding.

_auto_thresh(input_data)[source]#

Compute the best weights for the input_data.

Parameters

input_data (numpy.ndarray) – Array of sparse coefficient.

_op_method(input_data, extra_factor=1.0)[source]#

Operator.

This method returns the input data thresholded by the weights. The weights are computed using the universal threshold rule.

Parameters
  • input_data (numpy.ndarray) – Input data array

  • extra_factor (float) – Additional multiplication factor (default is 1.0)

Returns

Thresholded data

Return type

numpy.ndarray