DictionaryMatcher#

class blochsim.estimators.DictionaryMatcher[source]#

Bases: Estimator

Match signals to dictionary atoms by normalized complex inner product.

Parameters:
  • acquisition (Simulator, default=None) – The sequence being inverted, with every property that is neither unknown nor measured separately already fixed. Omit to give dictionary or signals to fit().

  • dictionary (torch.Tensor, default=None) – Atoms (n_atoms, n_contrasts), real or complex.

  • parameters (torch.Tensor, default=None) – Parameter values (n_atoms, n_parameters) of the atoms. Without them a call returns atom indices.

  • query_chunk_size (int, default=4096) – Measured signals compared at once.

  • dictionary_chunk_size (int, default=16384) – Atoms compared at once.

  • top_k (int, default=1) – Candidates kept by match(); the first is the estimate.

  • groups (int, default=None) – Cluster the dictionary into this many groups and score group representatives first, discarding groups before scoring their atoms [1]. See grouping.

  • prune (float, default=5e-3) – Fraction below its best group score within which a voxel still considers a group. Larger keeps more groups. The default was tuned on 280 groups of 700 atoms; raise it for smaller dictionaries.

  • coarse (int, default=None) – For a dictionary simulated on a lattice of parameter values (a product of one list per parameter, some combinations possibly left out), score every coarse-th value along each parameter first, then the 2 coarse + 1 values around the winner along each. Needs parameters; not with groups. See lattice.

  • refine (bool, default=True) – With coarse, search around the coarse winner; False returns the coarse lattice’s best atoms alone, which an iterative reconstruction can match against until its last iteration. An attribute that may be set between calls.

Notes

The coarse-to-fine search assumes the signal changes smoothly along the lattice, so the best atom lies within coarse steps of the coarse winner; on a 3 % logarithmic (T1, T2) grid of 37 000 atoms a stride of 3 scores about 4 200 + 49 atoms per voxel.

A rank given to fit() compresses the dictionary to (atoms, rank) before grouping. The estimator also returns an M0 map, computed from the match score and atom norms without touching atoms. Volumes are streamed as map(execution=...) says.

References

Methods

fit

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

from_coefficients

Map coefficients already in this estimator's basis.

map

Estimate the tissue parameters of a measured volume.

match

Find the best-matching atoms of each measured signal.

training_set

Simulate a training set from the properties given to fit().

uncertainty_of

Uncertainty of each map, as a standard deviation in the map's units.

property fitted#

Whether the matcher holds a dictionary.

property grouping#

Clustering of the dictionary, or None without groups.

Its condition is the condition number of the representatives and compression the factor by which in-group inner products shorten.

property lattice#

Where each atom sits on its parameters’ lattice, or None without coarse.

match()[source]#

Find the best-matching atoms of each measured signal.

Parameters:

signals (torch.Tensor) – Measurements (..., contrasts).

Returns:

Fields shaped (..., top_k).

Return type:

MatchResult

Raises:
  • RuntimeError – If there is no dictionary.

  • ValueError – If the contrast count differs from the dictionary’s.