Ordinator¶
Combinatorial optimization to find permutation maximizing sparsity.
-
mr_utils.cs.ordinator.
get_xhat
(locs, N, k, inverse, pdf_ref, pdf, pdf_metric)[source]¶ Compute xhat for given coefficient locs using basinhopping.
Parameters: - locs (array_like) – Coefficient location indices.
- N (int) – Length of the desired signal (also number of coefficients in total).
- k (int) – Desired sparsity level.
- inverse (callable) – Inverse sparsifying transform.
- pdf_ref (array_like) – Reference pdf of the prior to compare against.
- pdf (callable) – Function that estimates pixel intensity distribution.
- pdf_metric (callable) – Function that returns the distance between pdfs.
Returns: - xhat (array_like) – Inverse transform of coeffs.
- locs (array_like) – Indices of non-zero coefficients.
- coeffs (array_like) – Coefficients of xhat.
-
mr_utils.cs.ordinator.
obj
(ck, N, locs, inverse, pdf_ref, pdf, pdf_metric)[source]¶ Objective function for basinhopping.
-
mr_utils.cs.ordinator.
ordinator1d
(prior, k, forward, inverse, chunksize=10, pdf=None, pdf_metric=None, sparse_metric=None, disp=False)[source]¶ Find permutation that maximizes sparsity of 1d signal.
Parameters: - prior (array_like) – Prior signal estimate to base ordering.
- k (int) – Desired sparsity level.
- forward (callable) – Sparsifying transform.
- inverse (callable) – Inverse sparsifying transform.
- chunksize (int, optional) – Chunk size for parallel processing pool.
- pdf (callable, optional) – Function that estimates pixel intensity distribution.
- pdf_metric (callable, optional) – Function that returns the distance between pdfs.
- sparse_metric (callable, optional) – Metric to use to measure sparsity. Uses l1 norm by default.
- disp (bool, optional) – Whether or not to display coefficient plots at the end.
Returns: Reordering indices.
Return type: array_like
Raises: ValueError
– If disp=True and forward function is not provided.Notes
pdf_method=None uses histogram. pdf_metric=None uses l2 norm. If disp=True then forward transform function must be provided. Otherwise, forward is not required, only inverse.
pdf_method should assume the signal will be bounded between (-1, 1). We do this by always normalizing a signal before computing pdf or comparing.
-
class
mr_utils.cs.ordinator.
pdf_default
(prior)[source]¶ Picklable object for computing pdfs.
Uses histogram to estimate pdf.
-
N
¶ Size of signal.
Type: int
-
lims
¶ Upper and lower bounds for range of histogram.
Type: array_like or tuple
-
pdf_ref
¶ pdf estimate of prior. Used to compare to pdf(xhat).
Type: array_like
-
bins
¶ bin locations used for construction of pdf_ref.
Type: array_like
-
-
mr_utils.cs.ordinator.
pdf_metric_default
(x, y)[source]¶ Default pdf metric, l2 norm.
Parameters: - x (array_like) – First pdf.
- y (array_like) – Second pdf.
Returns: l2 norm between x and y.
Return type: float
-
mr_utils.cs.ordinator.
search_fun
(locs, N, k, inverse, pdf_ref, pdf, pdf_metric)[source]¶ Return function for parallel loop.
Parameters: - locs (array_like) – Coefficient location indices.
- N (int) – Length of the desired signal (also number of coefficients in total).
- k (int) – Desired sparsity level.
- inverse (callable) – Inverse sparsifying transform.
- pdf_ref (array_like) – Reference pdf of the prior to compare against.
- pdf (callable) – Function that estimates pixel intensity distribution.
- pdf_metric (callable) – Function that returns the distance between pdfs.
Returns: - locs (array_like) – Indices of non-zero coefficients.
- vals (array_like) – Values of coefficients at locations given by locs.
- float – Measure of difference between pdf_ref and pdf(xhat).