optim.data_scaling#
- bartorch.optim.data_scaling()#
Estimate the factor by which BART’s reconstructions divide the data.
Dividing the data by it makes a regularization weight independent of the data’s overall scale.
- Parameters:
y (torch.Tensor) – Data as the solve takes it: for a Cartesian encoding, after the sampling pattern and
fftmod(..., inverse=True). WithoutAthe coils are on their own axis in BART’s layout, not squeezed as an operator takes them, since the estimate is read from the k-space centre.A (LinearOperator, default=None) – Encoding operator. With one, the estimate is taken from
|A^H y|, as for a non-Cartesian acquisition; without one, from the k-space centre, as BART’sestscalingdoes.percentile (float, default=None) – Percentile of the sorted magnitudes to take in place of BART’s rule.
compat (bool, default=False) – Take the median, BART’s legacy estimate. Only with
A.
- Returns:
The scaling. Zero when the estimate failed, which
picsreplaces by one.- Return type:
float
Notes
Without
Athe estimate is BART’sestimate_scaling: the root-sum-of-squares image of the fully sampled central region of k-space, at most 32 samples along each axis, corrected for the region’s size, and the 90th percentile of its voxel magnitudes – or their maximum, when the maximum exceeds the 90th percentile by at least twice the difference between the 90th percentile and the median. WithAthe same rule is applied to the magnitudes ofA^H y.A solve on the divided data returns the image divided by the same factor; multiplying by the scaling restores the data’s units, as
pics -Sandbartorch.apps.pics()do.Examples
>>> y = bartorch.fftmod(kspace * pattern, axes=(-1, -2, -3), inverse=True) >>> scale = optim.data_scaling(y) >>> x = optim.FISTA(priors.Wavelet((-1, -2), 0.01))((y / scale).squeeze(1), A)