nlop.ModelOperator#
- class bartorch.nlop.ModelOperator#
Bases:
NonlinearOperatorSignal model as a nonlinear operator from parameter maps to contrast images.
The value, derivative and adjoint are the model’s
A,A_jvpandA_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 ofnames. The codomain is(contrasts, *shape).initial()andsplit()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 provideschannelsandnames;A(x),(..., channels)to(..., contrasts);A_jvp(x, d)andA_vjp(x, v), the Jacobian-vector product and its adjoint under the real inner product;initial(shape, **values)andsplit(x), from and to named maps in physical units; and optionallybounds,{name: (low, high)}, whichmoba()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=valuein each property’s physical units, asinitial()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 ofxis 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.
T1in ms and a complexamplitude.- Return type:
dict of str to torch.Tensor
Also has the methods and properties of NonlinearOperator.