PERK

Contents

PERK#

class torchsim.PERK(acquisition=None, *, n_features=1000, length_scale=None, regularization=1e-5, chunk_size=65536, feature_seed=None, complex_mode='cartesian', normalize=False, stream=False, uncertainty=True)[source]#

Bases: Estimator

Parameter estimation via regression with kernels.

This is the random-Fourier-feature form of PERK [1]. Training accumulates the required covariances in chunks, so memory depends on the feature order rather than the number of simulated training samples. Estimation uses only cos and matrix multiplication and therefore dispatches to optimized Torch CPU/CUDA kernels without a separate native implementation.

Parameters:
  • acquisition (Simulator, optional) – The sequence being inverted: a simulator that ships with TorchSim, one written by subclassing Simulator, or any other Simulator. Every tissue property that is neither unknown nor measured separately is fixed on it beforehand, with the constructor or bind(). Leave it out to fit from signals handed to fit() directly.

  • n_features (int, optional) – Number of random Fourier features. The default is 1000.

  • length_scale (float or tensor, optional) – Gaussian-kernel length scale for every signal/known-parameter feature. None estimates it from the training standard deviation.

  • regularization (float, optional) – Tikhonov parameter added to the feature covariance. The default is 1e-5.

  • chunk_size (int, optional) – Maximum samples transformed at once. The default is 65536.

  • feature_seed (int, optional) – Seed used for the fixed random feature map. Separate from the seed fit() draws the training set with.

  • complex_mode ({"cartesian", "magnitude"}, optional) – Representation used for complex signals. Magnitude data are often preferable when image phase is a nuisance parameter.

  • normalize (bool, optional) – Normalize every signal vector before feature projection. This removes an unknown global scale when it is not itself a target.

  • stream (bool, optional) – Simulate the training set a chunk at a time and accumulate the covariances as it goes, so memory follows the feature order rather than the number of training samples. The dictionary is never held, and so cannot have a basis estimated from it: a rank given to fit() needs the default. A basis fitted elsewhere, passed to fit() as subspace=, streams perfectly well – each chunk is projected as it is simulated.

Notes

Cartesian complex signals are represented as interleaved real/imaginary features. The learned estimator remains differentiable with respect to its input, which permits its use inside a larger reconstruction network.

References

Methods

fit

Fit the estimator over a sampling of the tissue it will meet.

from_coefficients

Map coefficients that are already in this estimator's basis.

map

Estimate the tissue a measurement came from.

training_set

Simulate a training set: signals, unknowns, and knowns.

uncertainty_of

The standard deviation the measurement noise leaves on each map.

property fitted#

Whether training statistics have been fitted.