optim.data_scaling#
- bartorch.optim.data_scaling()#
Normalization factor for the data of a reconstruction.
Dividing the data by it makes a regularization weight independent of the data’s overall scale, and is the normalization BART’s own reconstructions apply before solving.
- Parameters:
y (torch.Tensor) – Data as the solve will see it: for a Cartesian encoding, after the sampling pattern and
fftmod(..., inverse=True). Coils must be on their own axis in BART’s layout rather than the squeezed layout an operator takes, because the estimate is read off the k-space centre and a misplaced coil axis moves it.A (LinearOperator, default=None) – The encoding. With one, the estimate used for a non-Cartesian acquisition: the spread of
|A^H y|from its order statistics. Without one, the k-space-centre estimate BART’sestscalingmakes, used for a Cartesian acquisition.percentile (float, default=None) – Take this percentile of the sorted magnitudes instead of BART’s rule.
compat (bool, default=False) – Take the median, as BART’s older estimate did. Only with
A.
- Returns:
The scaling. Zero means the estimate failed, and a scaling of one should be used instead.
- 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.The solution of a solve on scaled data is scaled by the same factor, and is conventionally left so rather than divided back.
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)