bartorch.optim.data_scaling

Contents

bartorch.optim.data_scaling#

bartorch.optim.data_scaling(y, *, A=None, percentile=None, compat=False)#

The number pics divides its data by before solving.

Dividing by it makes a regularization weight independent of the data’s overall scale.

Parameters:
  • y (torch.Tensor) – Data as the solve will see it: for a Cartesian encoding, after the sampling pattern and fftmod(..., inverse=True). Coils on their own axis, in the layout bartorch.tools.pics() takes rather than the squeezed one an operator takes: the estimate is read off the k-space centre, which a misplaced coil axis moves.

  • A (LinearOperator, optional) – The encoding. With one, the estimate pics makes for a trajectory: the spread of |A^H y| from its order statistics. Without one, the k-space-centre estimate of bart estscaling, which pics uses for a Cartesian encoding.

  • percentile (float, optional) – Take this percentile of the sorted magnitudes instead of BART’s rule (estscaling -p; pics has no flag for it).

  • compat (bool) – Take the median, as BART’s older estimate did. Only with A.

Returns:

The scaling. Zero means the estimate failed; pics then warns and uses one.

Return type:

float

Notes

The solution of a solve on scaled data is scaled too; pics leaves it so. pics -w 1 disables the scaling, which makes a solve assembled without this function comparable to the tool.

Examples

>>> y = bartorch.fftmod(kspace * pattern, axes=(-1, -2, -3), inverse=True)
>>> scale = optim.data_scaling(y)
>>> x = optim.FISTA(prox.Wavelet((-1, -2), 0.01))((y / scale).squeeze(1), A)