nlop.ModelOperator#

class bartorch.nlop.ModelOperator#

Bases: NonlinearOperator

Signal model as a nonlinear operator from parameter maps to contrast images.

The value, derivative and adjoint are the model’s A, A_jvp and A_vjp. The domain is (channels, *shape): the model’s variables (bounded parameters in their transformed form, the amplitude as real and imaginary parts) in the real part of a complex tensor, in the order of names. The codomain is (contrasts, *shape). initial() and split() convert from and to named maps in physical units.

Parameters:
  • model (object) – Signal model over real parameter maps stacked on the last axis, such as blochsim.ModelOperator. It provides channels and names; A(x), (..., channels) to (..., contrasts); A_jvp(x, d) and A_vjp(x, v), the Jacobian-vector product and its adjoint under the real inner product; initial(shape, **values) and split(x), from and to named maps in physical units; and optionally bounds, {name: (low, high)}, which moba() reads to smooth a map.

  • shape (tuple of int, default=()) – Voxel shape, C order.

  • contrasts (int, default=None) – Number of contrast images; evaluated from the model when None.

channels#

Number of channels of the domain.

Type:

int

contrasts#

Number of contrast images of the codomain.

Type:

int

Examples

>>> import blochsim
>>> from blochsim.simulators import MultiEchoSimulator
>>> model = blochsim.ModelOperator(
...     MultiEchoSimulator(TE=echo_times), "T2", bounds={"T2": (10.0, 300.0)}
... )
>>> M = nlop.ModelOperator(model, (128, 128))
>>> M.ishape, M.oshape
((3, 128, 128), (8, 128, 128))
>>> images = M(M.initial(T2=80.0))

Under an encoding:

>>> F = encoding @ M
>>> maps = nlop.IRGNM()(kspace, F, x0=M.initial(T2=80.0))
>>> M.split(maps)["T2"]
property names#

Name of each channel of the domain, in order.

initial()#

Pack starting maps into the operator’s domain.

Parameters:

**values – name=value in each property’s physical units, as initial() takes them; a scalar or a map of the voxel shape. Properties not given take the model’s default.

Returns:

Complex64 tensor of ishape.

Return type:

torch.Tensor

split()#

Unpack a tensor of the domain into named maps in physical units.

The inverse of initial(); only the real part of x is read.

Parameters:

x (torch.Tensor) – Tensor of ishape, such as a fit’s result.

Returns:

One map of the voxel shape per unknown, e.g. T1 in ms and a complex amplitude.

Return type:

dict of str to torch.Tensor

Also has the methods and properties of NonlinearOperator.